Microsoft Azure have three options for load balancing:
- NGINX Plus,
- the Azure load balancing services, or
- NGINX Plus in conjunction with the Azure load balancing services.
The following aims to give you enough information to decide which best works for you and shows you how using NGINX Plus with Azure Load Balancer can give you a highly available HTTP load balancer with rich Layer 7 functionality.
Microsoft Azure gives its users two choices of a load balancer: Azure Load Balancer for basic TCP/UDP load balancing (at Layer 4, the network layer) and Azure Application Gateway for HTTP/HTTPS load balancing (at Layer 7, the application layer). While these solutions work for simple use cases, they do not provide many features that come standard with NGINX Plus.
The table below provides a of NGINX features with Azure Options:
Comparing NGINX Plus and Azure Load Balancing Services
NGINX Plus offers a choice of several load‑balancing methods. In addition to the default Round Robin method there are:
- Least Connections – A request is sent to the server with the lowest number of active connections.
- Least Time – A request is sent to the server with the lowest average latency and the lowest number of active connections.
- IP Hash – A request is sent to the server determined by the source IP address of the request.
- Generic Hash – A request is sent to the server determined from a user‑defined key, which can contain any combination of text and NGINX variables, for example the variables corresponding to the Source IP Address and Source Port header fields, or the URI.
All the methods can be extended by adding different weight values to each backend server.
Azure Application Gateway provides only a round‑robin method.
Session persistence, also known as sticky sessions or session affinity, is needed when an application requires that all requests from a specific client continue to be sent to the same backend server because client state is not shared across backend servers. NGINX Plus supports three advanced session‑persistence methods:
- Sticky Cookie – NGINX Plus adds a session cookie to the first response from the upstream group for a given client. This cookie identities the backend server that was used to process the request. The client includes this cookie in subsequent requests and NGINX Plus uses it to direct the client request to the same backend server.
- Sticky Learn – NGINX Plus monitors requests and responses to locate session identifiers (usually cookies) and uses them to determine the server for subsequent requests in a session.
- Sticky Route – A mapping between route values and backend servers can be configured so that NGINX Plus monitors requests for a route value and chooses the matching backend server.
NGINX Plus also offers two basic session‑persistence methods, implemented as two of the load‑balancing methods described above:
- IP Hash – The backend server is determined by the IP address of the request.
- Hash – The backend server is determined from a user-defined key, for example Source IP Address and Source Port, or the URI.
Azure Load Balancer supports the equivalent of the NGINX Plus Hash method, although it is limited to 3- or 2-tuple for source IP affinity.
Azure Application Gateway supports the equivalent of the NGINX Plus Sticky Cookie method with the following limitations: you cannot configure the name of the cookie, when the cookie expires, the domain, the path, or the HttpOnly or Secure cookie attribute.
Further reading: Using Microsoft Azure Load Balancers and NGINX Plus