Cold Start Issue
Hello, I recently deployed a NodeJS server on Railway that acts as the backend to a React App that I'm hosting on Vercel, but I'm facing an issue of the server going to sleep after enough time passes by with inactivity. How can I fix this? The server needs to be ready to serve content at all times.
Solution:Jump to solution
read the caution blurb
https://docs.strapi.io/dev-docs/configurations/database#database-pooling-options...
20 Replies
Project ID:
N/A
n/a
App Sleeping isn't enabled right?
I don't see that setting in the server configuration settings, do you know where I could find that?
it's in the service settings, it's off by default and if you don't know about it then it's still off
when it's off, there is no cold starts
Its not in the settings, i'm looking at the docs exactly where the screenshot says it should be (right next to the healthcheck settings) and its not there.
If theres no cold starts then does anyone here have an idea why this could be happening with my application?
my first thoughts are after a while the idle timeout for your database passes and then on the next request your app has to reconnect to the database
it's not in the settings because it's a beta feature, but like I said it's off by default
Is it something I can fix within the frontend? It's hard to debug because once the server is up and running the bug wont reproduce for another couple hours or so and the timeout occurs again.
no this is backed related, are there errors in the backend? and what kind of Backend is it?
Strapi CMS w/ NodeJS
send your database.js
Connection Error: Connection ended unexpectedly
This is in my logs when I made the request and it failed
the initial request, everything after is 200
make this same change in your database.js file
https://github.com/railwayapp-templates/strapi/blob/main/config/database.js#L9
GitHub
calm-shrub-website/server/config/database.js at main · angelplusult...
a website for the artist, Calm Shrub. Contribute to angelplusultra/calm-shrub-website development by creating an account on GitHub.
here is my database.js
revise the pool field?
set
pool.min
to 0
as shown by the database.js file I linkedI will try that out, thank you for the suggestion
if done right, this will work, it's mentioned in strapis docs
Solution
read the caution blurb
https://docs.strapi.io/dev-docs/configurations/database#database-pooling-options
in fact I'm confident enough to do this