NGINX Plus can be configured into a high-availability cluster to ensure application availability. The cluster consists of an active/passive pair of NGINX Plus instances: a master that actively processes traffic and a backup that monitors the health of the master, becoming active and taking over if the master fails.
High Availability Architecture for Web Applications
The advanced load balancing and health monitoring features in NGINX Plus provide resiliency and scalability for your upstream application servers. Configuring NGINX Plus into a high-availability cluster provides further resiliency for applications, and eliminates any single points of failure in the application stack. If the master NGINX Plus instance becomes unable to process traffic, the backup instance takes over.
You can also extend the configuration to support multiple active/passive NGINX Plus instances for higher levels of redundancy, or if you need more throughput than a single NGINX Plus cluster can provide.
How It Works
The NGINX Plus high-availability solution is based on keepalived, which itself uses an implementation of the Virtual Router Redundancy Protocol (VRRP). After you install the nginx-ha-keepalived package and configure keepalived, it runs as a separate process on each NGINX instance in the cluster and manages a shared virtual IP address. The virtual IP address is the IP address advertised to downstream clients, for example via a DNS record for your service.
Based on initial configuration, keepalived designates one NGINX instance as master and assigns the virtual IP address to it. The master periodically verifies that keepalived and NGINX Plus are both running, and sends VRRP advertisement messages at regular intervals to let the backup instance know it’s healthy. If the backup doesn’t receive three consecutive advertisements, it becomes the new master and takes over the virtual IP address.
Installation and Configuration
Installing the NGINX Plus HA capability is very straightforward; it is distributed in the nginx-ha-keepalived package from the NGINX Plus repository:
# apt-get install nginx-ha-keepalived
Install the package on each NGINX Plus instance in your planned HA cluster, then run the included nginx-ha-setup script to configure and run the HA service.
High-availability failover takes place in the event of a catastrophic failure on the master NGINX instance – a hardware failure, operating system shutdown, or termination of the NGINX Plus software. Internal health checks can be extended to identify more failure situations if necessary.
With NGINX Plus you can synchronize configuration between the servers in a cluster. With configuration sharing you make changes to the designated “master” server and then push those changes to the remaining servers in the cluster.
This functionality is distributed in the
nginx-sync package from the NGINX Plus repository:
# apt-get install nginx-sync
Full details on configuration can be found in the NGINX Plus Admin Guide.
High Availability on AWS EC2
The HA solution based on keepalived is not supported for NGINX Plus on Amazon Elastic Cloud Compute (EC2). You can use Amazon Elastic Load Balancing (ELB) as a front-end high-availability solution for NGINX Plus. If ELB is not an option, you can use the solution described in the NGINX Plus on AWS deployment guide, which uses Corosync and Pacemaker.