Search code examples
deploymentload-balancingweb-deploymenthaproxy

Deploy a WebApp and always keep it running


I have a web application spread over multiple servers and the incoming traffic is handled by HAProxy in order to balance the load. When we do the distribution, we do it at night because the users are much less and therefore we are less in service. To make the distribution we use the following strategy:

  • we shut down half of the servers
  • we deploy on servers that are turned off
  • we reactivate the servers that are turned off
  • we perform the same procedure on the other servers

The problem is that in any case I turn off the servers we close connections to users. Is there a better strategy for doing this? How could I improve this and avoid disservices and maybe be able to make distributions even during the day? I hope I was clear. Thanks


Solution

  • I strongly suggest to use health checks for the servers. Using HAProxy as an API Gateway, Part 3 [Health Checks]

    You should have a URL ("/health") which you can use for health check of the backend server and add option redispatch to the config.

    Now when you want to maintain the backend server just "remove" the "/health" URL and haproxy automagically routes the user to the other available servers.