← Back

Safer deploys behind a load balancer

Improvement

We've made a number of changes so deploys and outages on load balanced clusters don't take your site down:

  • Deploys wait for each web server. On clusters with two or more web servers behind a load balancer, a deploy now restarts one web server at a time, waits for your app to answer on it, and only then moves on to the next. Before, they could all restart at once. If your app doesn't come up on a server within two minutes, the deploy stops there, the load balancer routes around that server, and the rest keep serving the previous release.
  • Health checks are set up for you. Most Rails apps have a /up route, but few had it set as their health check. Hatchbox now checks for /up at the end of each deploy and turns it on when it answers. With a health check, the load balancer stops sending traffic to a server whose app has stopped responding. If the route later goes away, Hatchbox removes the health check again rather than taking your site down.
  • Dead servers are pulled faster even without a health check, and POST requests are no longer retried with an empty body.
  • Maintenance mode stays up. On clusters with a dedicated load balancer, the maintenance page used to disappear after about 30 seconds and leave visitors with an empty error page. The load balancer now serves the maintenance page itself.

You don't need to do anything to get these changes. Each cluster picks them up on its next deploy.