Logo

dev-resources.site

for different kinds of informations.

Random is a great load balancing policy

Published at
12/19/2024
Categories
softwareengineering
distributedsystems
softwaredevelopment
coding
Author
madflojo
Author
8 person written this
madflojo
open
Random is a great load balancing policy

Random is a great load-balancing policy


Image generated by AI

I have an unpopular opinion regarding load-balancing policies. Random selection is usually good enough. πŸ‘€

I work on many network-based applications, from custom service meshes to payments-based routing, and when we start thinking about routing or load distribution, load balancing policies are mentioned.

Most of the time, I recommend starting with a Random selection policy. 🎲

People often struggle with this statement. They want to optimize using more complex policies like least-connection or round-robin.

But in the quest to optimize, are you adding more complexity than is required?

The least-connection policy works by routing new connections to the service with the least current connections. This same approach could also be used with transactions, but to implement this, you need to implement a tracker that maintains connection or transaction status and distribution. πŸ“‰

Round-robin works by selecting the next service in a list and looping through it. It’s simple, but you need to maintain a position within the list. ♾️

Both approaches can become very complicated when you want to coordinate across multiple instances of the load-balancing system (don’t do that).

Random is simple. Maintain a list, and pick from that list randomly. There is no need or value in coordinating across instances; every instance is its own independent implementation.

Simple, straightforward, and reliable. πŸ’ͺ

That’s not to say that policies like round-robin or least-connection are not beneficial. They can benefit use cases that need them.

However, many use cases don’t need a complex load-balancing algorithm.

A random policy is often effective at distributing load and reducing the complexity of an application.

Like many things in technology, start with something simple initially and then optimize as needed. ✨


distributedsystems Article's
30 articles in total
Favicon
Rethinking distributed systems: Composability, scalability
Favicon
Mastering RabbitMQ: Reliable Messaging for Modern Applications
Favicon
CDNs in Distributed Systems: Beyond Caching for Better Performance
Favicon
RabbitMQ Architecture and Its Role in Modern Systems
Favicon
Kafka vs rabbitmq
Favicon
Asynchronous transaction in distributed system
Favicon
Advanced Perspectives on Multiprocessing and Task Queueing in Distributed Architectures
Favicon
Advanced Perspectives on Multiprocessing and Task Queueing in Distributed Architectures
Favicon
Edge Computing: Low-Latency paradigm for Distributed Systems
Favicon
HTTP Caching in Distributed Systems
Favicon
Idempotent database inserts: Getting it right
Favicon
Don’t Just Draw It, Design It: Making System Diagrams Useful
Favicon
Consistent Hashing in System Design
Favicon
Eventual Consistency Patterns in Distributed Systems
Favicon
Random is a great load balancing policy
Favicon
Ensuring Atomicity in Modern Databases
Favicon
Consensus in Distributed Systems
Favicon
From Lone Architects to Team Players: How System Design Has Evolved
Favicon
Amazon Aurora DSQL: The New Era of Distributed SQL
Favicon
Building Reliable Messaging Patterns in AWS with SQS and SNS
Favicon
Build a Distributed Task Scheduler Using RabbitMQ and Redis
Favicon
Treds - Fastest Prefix Seach Server
Favicon
Downstream Resiliency: The Timeout, Retry, and Circuit-Breaker Patterns
Favicon
Database Indexing Internals Part III
Favicon
A Comprehensive Guide to Understanding Kubernetes: The Power of Container Orchestration
Favicon
Implementing the Saga Pattern With MassTransit
Favicon
Understanding Application-Oriented Distributed Operating Systems: Architecture, Benefits, and Use Cases
Favicon
Handling Sharded Data in Distributed Systems: A Deep Dive into Joins, Broadcasts, and Query Optimization
Favicon
Building scalable ML workflows
Favicon
Database Indexing Internals Explained

Featured ones: