Tuesday, January 22, 2013

Nginx - How to deploy code without service disruption

Let's say you have the following upstream settings (Nginx load balancing two servers):
# /etc/nginx/sites-available/backend
upstream backend {
        server backend1.example.com:8080;
        server backend2.example.com:8080;
}
To update backend1.example.com, mark it as down,


# /etc/nginx/sites-available/backend
upstream backend {
        server backend1.example.com:8080 down;
        server backend2.example.com:8080;
}

> service nginx reload

Now update your code and reload the server configs.

> service nginx reload

Similarly, for the second server

upstream backend {
        server backend1.example.com:8080;
        server backend2.example.com:8080 down;
}

> service nginx reload

Update code on second server

> service nginx reload

The reload command does not restart the Nginx server.

No comments:

Post a Comment