We are trying to deploy a Nest.js API using Vercel functions, but we are experiencing a small cold start hovering around 4 seconds. I have read a few articles about it and I have noticed that once one article even suggested us to setup a cronjob to keep hitting the API so that it never spins down, but that suggestion is not there anymore.
What do I need to know, and what do I need to do in order to either keep the service up fulltime or drastically reduce the cold start in a Nest.js API?
Cross-posting this from another thread, which may be helpful:
I asked v0 on specific recommendations, and it recommended the following:
Consider implementing module caching in your main.ts
Use lazy loading for non-critical modules
Minimize your dependency tree
The old approach of using cron jobs to prevent spin-down isn’t recommended anymore, as Vercel has made significant improvements to function performance, including Rust-powered functions and bytecode caching.
How does the “hot” start feature work on paid plans? I have read some documentations but didn’t find anything explaining that. Is it something I have to manually enable or is it automatic?
I was testing it in a preview environment, so this is probably the reason why I’m having cold starts, right? I’ll deploy it in production and see what happens, and if it works, I’ll mark this conversation as resolved.
Thanks again!
Ok, I’m still facing some cold start. It hovers around 4 or 5 seconds, not too high, but more than I wanted it was. Is this the normal warm start or is there anything else I should do in order to reduce it to near zero?
I have already deployed the Api in a production environment, deployed at orium-nest-api-orium-network.vercel.app. You can se a hello world when you navigate to this link.