【发布时间】:2020-02-05 03:41:18
【问题描述】:
我有一个谷歌云功能,在闲置一段时间或重新部署后似乎超时。对端点的后续调用工作正常,只是初始调用不起作用。以下是我的云功能的过度简化版本。我基本上使用快速应用程序作为处理程序。也许问题在于 express 应用程序不是第一次运行,而是在后续调用中运行?
const express = require('express');
const app = express();
const cors = require('cors');
app.use(cors())
app.get('/health', (req, res) => {
res.send('OK');
});
module.exports = app;
目前已设置为 60 年代,像健康路线这样的路线应该不会花那么长时间。
一些有趣的日志条目
"Function execution took 60004 ms, finished with status: 'timeout'"
textPayload: "Error: Retry total timeout exceeded before any response was received
at repeat (/srv/functions/node_modules/google-gax/build/src/normalCalls/retries.js:80:31)
at Timeout.setTimeout [as _onTimeout] (/srv/functions/node_modules/google-gax/build/src/normalCalls/retries.js:113:25)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)"
【问题讨论】:
-
Google Functions 的冷启动非常缓慢。函数的超时时间是多少?
-
60 秒。
-
没有 cors 的行为是否相同?
-
我可以尝试删除该中间件,但我希望它会是一样的。
-
这是你的整个程序吗?如果您在 60 秒后超时,则说明发生了其他事情。请在您的问题中提供更多详细信息。包括来自 Stackdriver 的日志。
标签: express google-cloud-platform google-cloud-functions serverless