I have a nodejs sveltekit app and a unmanaged postgres app, the sveltekit app connects to the postgres via it’s internal hostname and this works fine when the sveltekit app is constantly running.
However if I set it to auto suspend when it comes out of suspend it seems to not be able to connect for quite a while, giving me a 500 page since the database is not reachable.
I’m using pg’s pool with a pool size of 10 which creates clients as they are needed, and disconnects clients when not in use.
My theory was that a user would visit my website, the app would create a client in the pool and connect to the postgres database, the client is then disconnected automatically when not in use.
The app would go in suspend, a user would visit, the app would come out of suspend, create a client in the pool and connect.
This works fine some of the times, but sometimes it also hangs for a long time unable to reach the database.
Is this expected? The timeout is set to 5-10 seconds and it will still happen, which to me seems weird since the database is always running, its just the sveltekit app that goes to suspend.