Over a million developers have joined DZone.

Announcing UDP Load Balancing in NGINX and NGINX Plus

NGINX and NGINX Plus have both just introduced support for UDP load balancing. Read on to find out the why and the how about this new feature.

Evolve your approach to Application Performance Monitoring by adopting five best practices that are outlined and explored in this e-book, brought to you in partnership with BMC.

We are proud to announce the addition of an exciting new capability to open source NGINX and our application delivery platform, NGINX Plus – UDP load balancing. The new capability builds on our existing TCP and HTTP capabilities, making NGINX a powerful, easy-to-use, and consistent frontend for an even wider range of Internet applications and devices. We’re excited to extend the load balancing capabilities that power more than half of the world’s busiest applications to a new set of users building the Internet of Things (IoT).

Why Add Support for UDP Load Balancing?

Most Internet applications depend on HTTP for network communication. Advanced protocols like SOAP and REST are built on the foundation of HTTP, which can take advantage of a number of rich extensions – security using TLS, compression using Gzip, and most recently, performance enhancements using HTTP/2.

Nevertheless, many applications need to use multiple protocols for different purposes, and many of the core Internet protocols predate HTTP. For this reason, a complete solution for load balancing and reverse proxying needs to support a wide range of protocols, both TCP-based and UDP-based.

UDP is commonly used for lightweight protocols that are not transactional in nature, such as DNS (used to resolve domain names to addresses), syslog (used for lightweight logging), and RADIUS (used for authentication). These protocols don’t have strict reliability requirements – if a UDP message (datagram) is dropped, the client can safely resend the message after a timeout – but the services they provide are critical for the correct operation of Internet services. UDP is also emerging as one of the protocols of choice for new IoT applications due to its low bandwidth requirements.

A year ago, NGINX introduced TCP load balancing to our community of users and commercial customers. We’re now pleased to extend our load balancing capabilities with the addition of UDP load balancing. With NGINX and NGINX Plus, users can now deliver UDP-based services with reliability, scalability, and performance.

How Does UDP Load Balancing Work?

NGINX listens for UDP network traffic (protocols such as DNS, syslog, and RADIUS) on one or more ports, as defined by the administrator. These ports are published (for example, as NS records in DNS) so that clients know where to send requests for the desired service.

As for HTTP and TCP load balancing, the configuration for UDP load balancing defines an upstream group – the set of origin servers that provide the UDP-based service – and the algorithm to use when load balancing traffic across the servers (for example, Round Robin, Least Connections, or Hash based on source IP address). The configuration also defines a virtual server for each UDP port, with a proxy_pass directive naming the upstream group that provides the associated service:

# Load-balance UDP DNS traffic across two servers
stream {
  upstream dns_upstreams {
    server 192.168.136.130:53;
    server 192.168.136.131:53;
  }
  server {
    listen 53 udp;
    proxy_timeout 1s;
    proxy_pass dns_upstreams;
    error_log logs/dns.log;
  }
}

When NGINX receives a UDP datagram on a port, it uses the configured load balancing algorithm to select which server in the upstream group will process it. Where appropriate, NGINX waits for a response from the server and forwards that response (and any subsequent packets received within the timeout period) back to the client.

If a server fails to respond to a request, NGINX marks it as ‘failed’ and temporarily stops sending datagrams to it. Every few seconds NGINX retries the server, sending it a client datagram to see if it has recovered.

NGINX Plus R9 will include an application (also called synthetic) health checks for UDP services, similar to those for HTTP and TCP traffic. You’ll be able to configure NGINX Plus to send special UDP requests to the upstream servers, and define the type of response the servers must return to be considered healthy.

Other features supported with UDP load balancing include logging of transactions to a web-server–style access log, IP address-based access control lists and a range of rate-limiting features.

In NGINX Plus R9 the set of live activity monitoring statistics provided by the Status module will include UDP metrics, and you’ll be able to reconfigure UDP upstream groups on the fly, using an HTTP-based API and DNS, as you currently can for HTTP and TCP servers.

Use Cases for UDP Load Balancing

UDP load balancing addresses two key use cases: high availability and horizontal scaling. By design, UDP does not guarantee end-to-end delivery of data and therefore requires the client software to deal with network-level errors and retransmissions. UDP protocols typically define a pair of servers; if a client cannot connect to its preferred server, it must wait a defined timeout period before trying the other server. This can introduce lengthy delays into UDP transactions.

Deploying NGINX or NGINX Plus as a highly available and reliable load balancer in front of your UDP servers can eliminate or reduce delays of this kind. Clients send UDP requests to NGINX or NGINX Plus, which monitors the health and availability of UDP servers and does not send requests to failed or overloaded servers. Clients don’t experience connection or request failures and so don’t suffer the timeouts associated with retrying requests.

Using NGINX or NGINX Plus as a load balancer also makes it possible to scale a UDP application to handle heavy traffic. In a typical UDP deployment, clients are aware of at most two UDP servers, but scaling up to satisfy high demand requires many more UDP servers. In this scenario, clients send their UDP requests to the one or two known NGINX or NGINX Plus instances, which load balance the requests across the larger number of UDP servers actually required to handle the load.

UDP load balancing with NGINX and NGINX Plus is suitable for any UDP-based application that sends data and optionally expects one or more responses. NGINX can also load balance proprietary UDP-based protocols such as those found in IoT environments.

Getting Started

The specific timing of availability of UDP load balancing in our releases is as follows:

  • Today – We have committed the first version of the code for UDP load balancing to the open source NGINX software repository. Early adopters and those looking to test our implementation can clone the source and build an NGINX binary with UDP load balancing capabilities. We welcome your feedback on the Nginx mailing list.
  • March 22, 2016 – NGINX version 1.9.13 will be released and include UDP load balancing (as will the prebuilt binaries based on that version).
  • April 2016 – NGINX Plus Release 9 (R9) will include UDP load balancing. NGINX Plus, our commercial application delivery platform, will extend the UDP load balancing features in open source with additional features for building out and monitoring reliable, scalable UDP-based services.

NGINX and NGINX Plus provide a complete load-balancing and application-delivery platform for a broad array of Internet protocols. Whether you’re delivering HTTP-based applications, lower-level TCP applications, or UDP-based protocols, you can rely on NGINX and NGINX Plus to deliver high availability, reliability, scalability, and performance in a single, lightweight application. We’re very excited about the new UDP load balancing feature and it's potential to bring high-performance load balancing and flawless application delivery to a whole new host of devices.

Want to familiarize yourself with NGINX Plus in advance of the release of UDP load balancing in Release 9? Start your free 30-day trial today or contact us for a live demo.

Learn tips and best practices for optimizing your capacity management strategy with the Market Guide for Capacity Management, brought to you in partnership with BMC.

Topics:
nginx ,nginx plus ,load balancing ,udp ,feature

Published at DZone with permission of Patrick Nommensen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}