Getting Cold start latency of 5+ seconds even after using the preferRest option for firebase-admin
I was getting a cold start latency of 5+ seconds while using firestore database. I came across this age old issue- https://issuetracker.google.com/issues/158014637 and the solution here- https://github.com/firebase/firebase-admin-node/pull/1901 but even after implementing the solution as mentioned, I am still getting a latency of 5-6 seconds.
"firebase-admin": "^11.8.0" is the only dependencies I have.
Please find below my code snippet- `` const { initializeApp } = require("firebase-admin/app");
const { initializeFirestore } = require("firebase-admin/firestore");
if (!isAlreadyInitialized) {
const app = initializeApp();
db = initializeFirestore(app, { preferRest: true });
isAlreadyInitialized = true;
}
const query = db.collection("apps").where("apiKey", "==", apiKey);
const querySnapshot = await query.get();
`` Do let me know in case of any other queries.
@alexander-fenster @lahirumaramba can you please help on this
I'm also still seeing slow cold starts (> 5 seconds) after implementing preferRest.
@johnnyoshika @HarshitPersona have you found the fix? I am also experiencing super slow cold start with Vercel serverless when using the admin sdk
@juniorforlife I had to disable preferRest because of this issue.
@johnnyoshika then how do you fix the slow cold start issue? Isn't preferRest supposed to fix it?
@juniorforlife Sadly I'm still living with painfully slow cold starts on some functions. For critical ones, I set a minInstances of 1 or greater to reduce cold starts. On other ones, I have a uptime monitoring service pinging it every minute to keep it warm. They're all costly options 😔
it's a shame the firebase team keeps ignoring this problem 😔
I enabled preferRest in my projects again. I'm not getting the ECONNRESET error anymore but the cold start doesn't seem to be any better than before preferRest was enabled. Cold start seems to be > 7 seconds or so.