6 months ago
Description of the issue:
I’m running into a cold start issue with my setup. The very first API request after some idle time takes anywhere from 15–22 seconds, but every request after that drops down to literally <1 second.
Error messages:
No explicit error messages, just extremely slow response times on the first request, but subsequent ones are super fast.
Logs:
Server logs show execution time for the first request being several seconds, while subsequent calls to the same endpoint are processed in milliseconds. I feel like this suggests some kind of warm-up or initialization overhead.
Setup:
Backend: NestJS on Railway
Database: Supabase (Postgres)
Additional service: Separate AI server also hosted on Railway
Both backend and AI servers are being pinged every ~2.5 minutes for health checks
Question:
Is there a recommended way to prevent this DB cold start issue / is anyone running into the same thing?
Any best practices for avoiding this long “first call” penalty would be greatly appreciated.
5 Replies
6 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
6 months ago
That would be up to your application. It might be loading something on that first load. You could add a healthcheck and it would "prewarm" that request
Status changed to Awaiting User Response Railway • 6 months ago
jake
That would be up to your application. It might be loading something on that first load. You could add a healthcheck and it would "prewarm" that requesthttps://docs.railway.com/reference/healthchecks
6 months ago
We have a health check on a 2.5min timer for both our servers
Status changed to Awaiting Railway Response Railway • 6 months ago
6 months ago
Then unfortunately there's not much else that can be done. You'll have to look at your app
Status changed to Awaiting User Response Railway • 6 months ago
4 days ago
Does the cold start problem come in "Hobby" plan as well?