Firebase云函数执行时间如此波动
我从谷歌云控制台得到了这个。我不明白为什么在函数执行后,它会在一段时间内变热。然而,在部署函数并调用它之后,我发现冷启动,然后下降到实际值,然后再次增加到冷启动。请帮忙Firebase云函数执行时间如此波动,firebase,google-cloud-functions,Firebase,Google Cloud Functions,我从谷歌云控制台得到了这个。我不明白为什么在函数执行后,它会在一段时间内变热。然而,在部署函数并调用它之后,我发现冷启动,然后下降到实际值,然后再次增加到冷启动。请帮忙 // index.js import * as functions from 'firebase-functions' import express from 'express' import cors from 'cors' import auth from 'controllers/auth' const authApp
// index.js
import * as functions from 'firebase-functions'
import express from 'express'
import cors from 'cors'
import auth from 'controllers/auth'
const authApp = express()
authApp.use(cors({ origin: true }))
authApp.use(auth)
authApp.use('*', unknownPathHandler, errorMiddleware)
const authApi = functions.https.onRequest(authApp)
exports.auth = authApi
// controllers/auth.js
app.post('/user', verifySecretKey, (req, res, next) => {
const { email, password } = req.body
return appFirebase.auth().signInWithEmailAndPassword(email, password)
.then(() => {
return appFirebase.auth().currentUser.getIdToken().then((token) => {
return res.end(token)
})
})
.catch((err) => next(err))
})
firebase版本
"firebase-admin": "5.12.0",
"firebase-functions": "1.0.2",
你的函数可能会有很多变化。它正在执行以下所有任务,但没有一项任务可以保证需要多长时间:
如果您有可靠的基准表明云功能的性能低于预期,请将其发送给Firebase支持部门 在不显示代码的情况下,堆栈溢出对您没有多大帮助。@DougStevenson感谢您的回答,我提供了一个api。这有帮助吗?非常感谢,但我有另一个api在firestore中使用简单查询。但是,行为是相同的(如上图所示,波动执行时间)。我不知道这是否与我使用的firebase函数版本有关?。此外,我怀疑在过去的几天里,API的速度明显比平时慢。