Can you explain the role of a load balancer in microservice communication?
Short answer: A load balancer distributes incoming network traffic across multiple instances of a microservice to ensure no single instance is overwhelmed and to improve the system’s reliability and scalability.
Explain a bit more
Traffic Distribution: The load balancer routes traffic to available instances of a service based on different algorithms (round-robin, least connections, etc.). Fault Tolerance: The load balancer detects unhealthy instances and routes traffic only to healthy ones. Scaling: As the system scales horizontally (more instances of a service), the load balancer ensures that requests are distributed evenly.
Example code
A Payment Service might have multiple instances running, and a load balancer (e.g., NGINX, HAProxy) ensures that payment requests are distributed across them, balancing the load and ensuring high availability.
Real-world example (ShopNest)
ShopNest splits Catalog, Cart, Order, and Payment into services so teams can deploy catalog changes without redeploying payments.
Say this in the interview
- Define — one clear sentence (the short answer above).
- Example — relate it to a project like ShopNest or your real work.
- Trade-off — when you would not use it.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png