Next.js SSR Site Times Out on First Visit After Inactivity, Then Loads Fine on Refresh
- 0
- Self Hosted
- Sites
Hey everyone,
I'm running a Next.js SSR site on a self-hosted Appwrite server (v1.9.0), and I've noticed a strange behavior that I'm hoping someone can help me understand.
The site is deployed through Appwrite Sites and is currently pre-launch, so it gets very little traffic.
Whenever the site hasn't been visited for a while, the first request often ends up showing an Appwrite timeout/error page (as shown in the screenshot). However, if I refresh a few seconds later, the site loads normally and works perfectly.
This feels similar to a cold-start issue, but I'd expect the initial request to simply take longer rather than eventually timing out and showing an error page.
My concern is that most visitors won't refresh after seeing an error page - they'll assume the site is broken and leave.
Has anyone else experienced this with Next.js SSR deployments on self-hosted Appwrite?
A few questions:
- Is this expected behavior when an SSR site has been idle for some time?
- Is there a configuration that can prevent the first request from timing out?
- Are there recommended timeout, container, or scaling settings for self-hosted Appwrite Sites running Next.js SSR?
I'd appreciate any guidance or suggestions on what to check.
Thanks!
All sites have a timeout to free up resources when not used.
To increase that there is some envs : https://appwrite.io/docs/advanced/self-hosting/configuration/environment-variables
_APP_COMPUTE_INACTIVE_THRESHOLD
version >= 1.7.0 The minimum time a function or site must be inactive before it can be shut down and cleaned up. This feature is intended to clean up unused containers. Containers may remain active for longer than the interval before being shut down, as Appwrite only cleans up unused containers every hour. If no value is provided, the default is 60 seconds.
But it first seams strange that nextjs take a very long time to spin up.
Could you check for example, when you make the first request, do you see a new container spin up instantly or like 20 second after ? If it spin up instant, that might be that nextjs takes too much time to start with the resources constraints/specification it have (a 0.5cpu-0.5g might timeout where a 2cpu-2g might not)
Last small question you said it was a site, but the UI shows "function" is it a real site (and so just a UI bug showing the wrong resource), or a function ?
In response to this, it's a real site. I am as clueless as to why it shows functions error
Last small question you said it was a site, but the UI shows "function" is it a real site (and so just a UI bug showing the wrong resource), or a function ?
As for the container inspection, I will check this shortly
also if you have a lot of functions and others things running, it's possible that you need to scale up a bit some containers to allow more elements to run in parallel
Recommended threads
- I'm getting an error on the console "j?....
On my self hosted instance version 1.8.1 the console is giving me this error when trying to view the rows for a table I recently created. My application is read...
- local build `composer installer:dev` iss...
setup - dev container (default linux universal) WSL (test with gh codespace too) - php 8.5.7 - all extensions installed - `composer install` fine - `composer...
- Suspicious access pattern detected when ...
Hello, I am having trouble restoring my project. In the past it worked with no problems, but today I get an error "Suspicious access pattern detected". How can ...