10 months ago
It is possible to configure a strategy with a load balancer to route requests to projects that are not building. When a production project is building and finishing its ready-to-serve run, it pauses and stops, and if the user tries to log in, it displays a Railway error message stating that the service is unavailable.
In some other projects and servers I've managed, I've configured a load balancer to provide two options for the service to be open to the public. This way, first, the deployment is performed on Service A, and while the build is being performed, all incoming requests go to Service B. Then, when Service A is 100% available, the deployment is switched to Service B, routing all requests to Service A.
This way, we avoid service downtime, especially those running on Node.js, which take a long time to deploy.
Is it possible to do this type of configuration with you?
How can I do it?
5 Replies
10 months ago
Hello,
You linked to Postgres but I assume you meant to link to Directus, running with that assumption.. we do this by default with health checks, but since Directus has a volume we cannot do zero downtime deployments given two deployments cannot be connected to the same volume, so we have to clean shut down the previous deployment before starting the new one, and in that time frame is where the downtime comes from.
The solution for Directus is not to use a volume. Directus supports S3 as a storage backend, so you can use the MinIO template instead of a volume.
Best,
Brody
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
I think it was a mistake to include my project in the form because it's not that specific one.
When I push to project repositories with Nexjs, for example, where the build takes a little longer, the site goes down for a few seconds or minutes.
In a project with high traffic, this could affect the experience, so switching instances while the build is being completed on one and pointing to the other is an important strategy to always manage projects that require active builds.
I didn't understand your answer because my case isn't related to Directus but to Nextjs, for which I don't have enough volume and could configure replicas.
If I configure replicas and instances greater than one, could this be resolved, or does it require a more advanced strategy to configure load-balancing routes while building applications?
Status changed to Awaiting Railway Response Railway • 10 months ago
10 months ago
To be brief:
How can I prevent a NextJS site from going down when I push to the repository and it automatically builds, causing the site to go down for a few seconds or minutes?
Status changed to Awaiting User Response Railway • 10 months ago
10 months ago
Thanks
Status changed to Awaiting Railway Response Railway • 10 months ago
Status changed to Solved ponceleon • 10 months ago