【问题标题】:GCloud AppEngine nodejs application returns 404 on first requests but subsequent ones are successfulGCloud App Engine 节点 js 应用程序在第一次请求时返回 404,但后续请求成功
【发布时间】:2019-06-13 03:46:49
【问题描述】:

我正在 GCloud AppEngine 标准环境中部署 nodejs 服务器 (graphql) 应用程序,有时第一个请求会失败,但后续请求(5 秒内)可以正常工作。我正在使用以下配置:

runtime: nodejs10
instance_class: F2
service: ...
env_variables:
  ...
  ...

日志如下(404见最后几行):

OPTIONS 204 310 B 4.1 s Chrome 71 /graphql OPTIONS 204 310 B 4.1 s Chrome 71 
OPTIONS 204 310 B 4.1 s Chrome 71 /graphql OPTIONS 204 310 B 4.1 s Chrome 71 
[start] 2019/01/18 20:46:21.506468 no entrypoint specified, using default entrypoint: /serve 
[start] 2019/01/18 20:46:21.511900 no entrypoint specified, using default entrypoint: /serve 
[start] 2019/01/18 20:46:21.539860 starting app 
[start] 2019/01/18 20:46:21.540272 Executing: /bin/sh -c exec /serve 
[start] 2019/01/18 20:46:21.540122 starting app 
[start] 2019/01/18 20:46:21.540403 Executing: /bin/sh -c exec /serve 
[start] 2019/01/18 20:46:21.560976 waiting for network connection open. subject:"app/invalid" Address:127.0.0.1:8080 
[start] 2019/01/18 20:46:21.561742 waiting for network connection open. subject:"app/valid" Address:127.0.0.1:8081 
[start] 2019/01/18 20:46:21.561786 waiting for network connection open. subject:"app/invalid" Address:127.0.0.1:8080 
[start] 2019/01/18 20:46:21.562055 waiting for network connection open. subject:"app/valid" Address:127.0.0.1:8081 
[serve] 2019/01/18 20:46:21.586374 serve started 
[serve] 2019/01/18 20:46:21.586831 args: {runtimeName:nodejs10 memoryMB:256 positional:[]} 
[serve] 2019/01/18 20:46:21.587680 serve started 
[serve] 2019/01/18 20:46:21.588167 args: {runtimeName:nodejs10 memoryMB:256 positional:[]} 
[serve] 2019/01/18 20:46:21.593780 execing to: /bin/sh -c exec node ./dist/index.js 
[serve] 2019/01/18 20:46:21.594081 execing to: /bin/sh -c exec node ./dist/index.js 
[start] 2019/01/18 20:46:25.122334 wait successful. subject:"app/valid" Address:127.0.0.1:8081 attempts:701 elapsed:3.560382686s 
[start] 2019/01/18 20:46:25.122604 starting nginx 
Go to http://localhost:8081/graphql to run queries! 
[start] 2019/01/18 20:46:25.127939 wait successful. subject:"app/valid" Address:127.0.0.1:8081 attempts:687 elapsed:3.56541476s 
[start] 2019/01/18 20:46:25.128135 starting nginx 
[start] 2019/01/18 20:46:25.128836 waiting for network connection open. subject:"nginx" Address:127.0.0.1:8080 
Go to http://localhost:8081/graphql to run queries! 
[start] 2019/01/18 20:46:25.163712 waiting for network connection open. subject:"nginx" Address:127.0.0.1:8080 
[start] 2019/01/18 20:46:25.179456 wait successful. subject:"nginx" Address:127.0.0.1:8080 attempts:6 elapsed:50.397788ms 
[start] 2019/01/18 20:46:25.184531 wait successful. subject:"nginx" Address:127.0.0.1:8080 attempts:4 elapsed:20.559325ms 
2019/01/18 20:46:25 [alert] 33#33: prctl(PR_SET_DUMPABLE) failed (22: Invalid argument) 
2019/01/18 20:46:25 [alert] 33#33: prctl(PR_SET_DUMPABLE) failed (22: Invalid argument) 
POST 404 505 B 176 ms Chrome 71 /graphql POST 404 505 B 176 ms Chrome 71 
POST 404 505 B 185 ms Chrome 71 /graphql POST 404 505 B 185 ms Chrome 71 
OPTIONS 204 310 B 4 ms Chrome 71 /graphql OPTIONS 204 310 B 4 ms Chrome 71 
POST 200 679 B 73 ms Chrome 71 /graphql POST 200 679 B 73 ms Chrome 71 
OPTIONS 204 310 B 3 ms Chrome 71 /graphql OPTIONS 204 310 B 3 ms Chrome 71 
POST 200 651 B 61 ms Chrome 71 /graphql POST 200 651 B 61 ms Chrome 71 
OPTIONS 204 310 B 4 ms Chrome 71 /graphql OPTIONS 204 310 B 4 ms Chrome 71 
OPTIONS 204 310 B 2 ms Chrome 71 /graphql OPTIONS 204 310 B 2 ms Chrome 71 
POST 200 677 B 131 ms Chrome 71 /graphql POST 200 677 B 131 ms Chrome 71 
POST 200 653 B 127 ms Chrome 71 /graphql POST 200 653 B 127 ms Chrome 71 

有人知道可能出了什么问题吗?谢谢

【问题讨论】:

    标签: node.js express google-app-engine http-status-code-404 express-graphql


    【解决方案1】:

    我想您指的是以下日志条目。你说这种情况偶尔会发生,有什么规律吗?您的查询是由什么组成的?从日志来看,这两个请求似乎是部署后的第一个请求,可能是因为应用程序没有完全服务,或者流量仍然从以前的版本重定向而导致失败。您是在应用已部署时还是仅在新部署后遇到这些错误?

    POST 404 505 B 176 ms Chrome 71 /graphql POST 404 505 B 176 ms Chrome 71 
    POST 404 505 B 185 ms Chrome 71 /graphql POST 404 505 B 185 ms Chrome 71 
    

    【讨论】:

    • 模式是应用缩小到0个实例后出现,收到第一个请求时需要放大。所以它是标准环境实例管理的一部分。
    • 好的,这是正常的升温伪影,您可以通过始终运行 1 个实例来解决此问题,或者在流量开启之前扩大规模。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 1970-01-01
    • 2017-12-30
    • 1970-01-01
    • 2017-03-13
    • 2015-03-06
    • 2015-05-25
    相关资源
    最近更新 更多