Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Cold start latency of 5+ seconds even after using the preferRest option for firebase-admin #2195

Open
HarshitPersona opened this issue May 26, 2023 · 8 comments
Assignees

Comments

@HarshitPersona
Copy link

HarshitPersona commented May 26, 2023

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- #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.

@HarshitPersona
Copy link
Author

@alexander-fenster @lahirumaramba can you please help on this

@johnnyoshika
Copy link

I'm also still seeing slow cold starts (> 5 seconds) after implementing preferRest.

@juniorforlife
Copy link

@johnnyoshika @HarshitPersona have you found the fix? I am also experiencing super slow cold start with Vercel serverless when using the admin sdk

@johnnyoshika
Copy link

@juniorforlife I had to disable preferRest because of this issue.

@juniorforlife
Copy link

@johnnyoshika then how do you fix the slow cold start issue? Isn't preferRest supposed to fix it?

@johnnyoshika
Copy link

@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 😔

@juniorforlife
Copy link

it's a shame the firebase team keeps ignoring this problem 😔

@johnnyoshika
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants