10 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
10 months ago
Hey there! We've found the following might help you get unblocked faster:
- 🧵 KaisVault Platform Backend Deployment Failing with 502 Error
- 🧵 Container not running full time?
- 🧵 supabase error: connect ENETUNREACH
If you find the answer from one of these, please let us know by solving the thread!
10 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 • 10 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 request <https://docs.railway.com/reference/healthchecks>
10 months ago
We have a health check on a 2.5min timer for both our servers
Status changed to Awaiting Railway Response Railway • 10 months ago
10 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 • 10 months ago
4 months ago
Does the cold start problem come in "Hobby" plan as well?