1

I manage a few servers and for the sake of the question let's consider these three:

  • nginx server: it only runs nginx and serves static files, responses from the disk cache, or passes requests to the API server
  • API server: it returns data and it connects to the database server
  • database server: it hosts the database, Redis and some other stuff

This setup allows us to perform maintenance with zero downtime. That is also the case for upgrades. If we want to add more memory to the database server, we just spin up a new instance, physically clone the database, and destroy the old server.

Roughly the same thing can be done with the API server. However, sooner or later we will need to upgrade the nginx server. How do we do that without downtime, if the upgrades require a shutdown? The nginx instance has to have a fixed IP to be reached from the external world.

user168317
  • 145
  • 8
  • 1
    Instead of saying "zero downtime" (impossible), describe your real requirements. How much downtime is acceptable? – anx Aug 07 '18 at 06:36

1 Answers1

2

One possibility is to install a second nginx server and set up keepalived on both of them.

Each server has its own unique IP address. In addition, keepalived allows you do define a floating IP address that is shared by both servers. That floating address is active on one server only at any time. By shutting down keepalived on the active server, the floating IP address becomes active on the other server automatically. The same also happens if the server is powered off or if it crashes for whatever reason.

This allows you to do maintenance on the webservers without interrupting your service.

Just focus on the VRRP part of keepalived, and don't let yourself distract with load balancing and other fancy features as you probably won't need them at this point. Maybe you will also need a notify script that gets called if the floating IP address is added or removed so you can reload nginx to make sure it listens on the new IP address.

Oliver
  • 5,973
  • 24
  • 33
  • Very interesting, I didn't know about this possibility. It works in a way similar to `upstream { server backup }` in nginx. – user168317 Aug 07 '18 at 06:49