Sergej Khackimullin - Fotolia


Some tricks to help manage load balancing in microservices

Load balancing is a critical, and potentially thorny, part of cloud-native microservices management. Consider these methods and tools that can help address these challenges.

As a business adds cloud-native microservices applications, it increases the need to adopt proper techniques for load balancing in order to attain an optimal user experience. Consider these essential concepts and tools to stay operational when working with these advanced applications and properly manage load balancing in microservices.

Depending on their purpose, applications will all handle their load differently. Some apps that deliver high throughput and large scale for requests require low latency. This is the technique used by search engines and real-time monitoring applications. Others, such as a video processing application, may not need low latency but rather require high availability and stability.

Applications may also have other requirements, like ensuring bidirectional flow of requests or handling requests that span complex back-end architectures. In each case, requests between client and server need to function according to the application's requirements. This detail is where load balancing matters.

Once requests exceed a single server's request load limit, the remaining requests start to pile up, which can compromise the user experience. Load balancing handles requests when they stretch beyond the standard capacity of available servers. It's especially necessary in cloud applications, with their unpredictable traffic and need for horizontal scalability.

Scaling in the cloud is different

In the past, IT shops would simply buy more servers and expand load capacity to address these traffic spikes. As applications moved to the cloud, architects needed to learn how to manage traffic loads there, too. When applications run in the cloud, system failures or latency shouldn't bring the application to a halt. Load balancing in the cloud is one of the key features that makes cloud-native applications resilient.

Think service-to-service

When building microservices applications, the predominant direction of communication becomes service-to-service rather than client-to-server. Traditional networking and load balancing were not designed for this type of communication, which is why we need proven service-to-service communication tools to manage load balancing in microservices.

Moving from server-centric to service-centric

Networking for monolithic applications revolved around IP addresses, domain name system (DNS) ports and TCP/IP protocols. These components were easier to manage but harder to scale and not prepared for modern cloud applications. With microservices applications, on the other hand, it's about how you manage the various services that constitute the application. Never mind terms like IP and DNS; think about service discovery and load balancing.

Rather than manually configuring networking within the application, a microservices architecture offloads networking tasks, such as service discovery and load balancing, to cloud networking tools. Developers once accomplished this task by coding the network configuration into the application, and it worked well because the developers could maintain and change the application layer independent of the networking layer. However, modern cloud tooling can now configure automated rules that handle load balancing in the cloud instead of manually handling load balancing.

Options for load balancing

One option for load balancing in the cloud is to use a tool from a cloud vendor, such as AWS Elastic Load Balancing (ELB). AWS provides an application load balancer, a network load balancer and a classic load balancer. However, load balancers from cloud vendors tend to be proprietary. Additionally, they don't provide as much flexibility in terms of horizontal scalability.

Another option is something like Nginx, a platform-agnostic load balancer. While Nginx is better known as a web server, it provides quite robust load-balancing features. It runs on any cloud platform, data center or Docker container. It also scales load balancers horizontally on cheap infrastructure, which is ideal for distributed microservices applications.

For some, service mesh tools are the de facto method to manage load balancing in microservices and cloud-based environments. Kubernetes is the dominant cloud orchestration platform today, and its related open source service mesh tools are the new order with load balancing. Tools like Istio, Linkerd and gRPC excel at managing service-to-service communication at massive scale.

Applications today are diverse and complex, and they present new load-balancing challenges. But there are new tools and approaches that can help manage load balancing in microservices architectures and the cloud.

Next Steps

Load sharing vs. load balancing: What's the difference?

Dig Deeper on Application development and design

Software Quality
Cloud Computing