External load balancing and Internal service-to-service load balancing
This is one of the biggest concepts to understand in modern microservices. Let's separate them clearly. 1. External Load Balancing (Client β Cluster) This load balancer receives requestsβ¦
This is one of the biggest concepts to understand in modern microservices. Let’s separate them clearly.
1. External Load Balancing (Client β Cluster)
This load balancer receives requests coming from outside your system (browser, mobile app, third-party APIs).
Example:
Internet
β
β
External Load Balancer
(AWS ALB / Nginx / Ingress)
β
β
API Gateway Service
β
-------------------
Kubernetes Cluster
The job is to distribute traffic coming from users.
Example:
User 1 βββββββββ
User 2 βββββββββ€
User 3 βββββββββ€
βΌ
External Load Balancer
β
βββββββββββ΄ββββββββββ
βΌ βΌ
Gateway Pod 1 Gateway Pod 2
If Gateway Pod 1 dies,
External LB
β
βΌ
Gateway Pod 2
Users never notice.
Who provides this?
Usually
- AWS ALB
- AWS NLB
- Azure Load Balancer
- Google Cloud Load Balancer
- Nginx Ingress
- HAProxy
2. Internal Service-to-Service Load Balancing
Now suppose API Gateway wants to call Payment Service.
Payment service has 4 replicas.
Payment Pod 1
Payment Pod 2
Payment Pod 3
Payment Pod 4
Gateway shouldn’t always hit Pod 1.
Instead,
Gateway
β
βΌ
Payment Service
β
ββββΌβββ¬βββ
βΌ βΌ βΌ βΌ
P1 P2 P3 P4
Kubernetes Service distributes traffic among all pods.
This is internal load balancing.
No internet involved.
Complete Flow
Browser
β
βΌ
External Load Balancer
β
βΌ
API Gateway
β
βΌ
Accounts Service
β
βΌ
Payment Service
β
βΌ
Database
Notice
Only the first request comes through the external load balancer.
Everything inside the cluster uses Kubernetes Services.
Example
Suppose Payment has three pods.
payment-service
β
βΌ
-----------------------
| Pod1 |
| Pod2 |
| Pod3 |
-----------------------
Accounts Service sends requests.
Request 1
Accounts
β
βΌ
payment-service
β
βΌ
Pod1
Request 2
Accounts
β
βΌ
payment-service
β
βΌ
Pod3
Request 3
Accounts
β
βΌ
payment-service
β
βΌ
Pod2
Accounts Service never knows which pod handled the request.
It only calls
http://payment-service
Before Kubernetes (Spring Cloud Netflix Era)
In older microservices architecture, we often used:
Accounts
β
βΌ
Spring Cloud LoadBalancer
β
βΌ
Eureka Server
β
βΌ
Payment Instance List
Flow:
- Payment instances register with Eureka.
- Accounts asks Eureka for available instances.
- Spring Cloud LoadBalancer chooses one instance.
- Request is sent directly.
Accounts
β
βΌ
Spring Cloud LoadBalancer
β
βΌ
10.0.0.11
10.0.0.12
10.0.0.13
With Kubernetes
No Eureka is required.
Accounts
β
βΌ
payment-service
β
βΌ
Kubernetes Service
β
ββββΌβββ¬βββ
βΌ βΌ βΌ βΌ
P1 P2 P3 P4
Kubernetes itself:
- Discovers pods
- Removes unhealthy pods
- Adds new pods automatically
- Balances requests
Modern Enterprise Architecture
Internet
β
βΌ
External Load Balancer
(AWS ALB / Nginx Ingress)
β
βΌ
API Gateway
β
ββββββββββββββββΌβββββββββββββββ
βΌ βΌ βΌ
Accounts Orders Customer
β β
β βΌ
β payment-service
β β
β Kubernetes Service
β β
βΌ βββββββββΌβββββββββ
βΌ βΌ βΌ
Payment1 Payment2 Payment3
- External load balancing: Handles traffic from clients into your cluster (e.g., to the API Gateway).
- Internal service-to-service load balancing: Happens inside the cluster. Services communicate using Kubernetes Service names (like
http://payment-service), and Kubernetes automatically distributes requests across healthy pod replicas.
This separation is one of the key differences between traditional microservice deployments and Kubernetes-native architectures.