ALB vs NLB decision in AWS - Performance Comparison
When choosing between Application Load Balancer (ALB) and Network Load Balancer (NLB), it's important to understand how the number of requests affects the load balancer's operations.
We want to know how the processing work grows as more requests come in.
Analyze the time complexity of handling incoming requests with ALB and NLB.
// Pseudocode for ALB and NLB request handling
for each incoming request {
if using ALB {
parse HTTP headers;
route request based on content;
} else if using NLB {
forward TCP/UDP packet to target;
}
}
This sequence shows how ALB inspects and routes HTTP requests, while NLB forwards packets without deep inspection.
Each incoming request triggers operations:
- Primary operation: ALB parses HTTP headers and routes; NLB forwards packets.
- How many times: Once per request, repeated for every incoming request.
As the number of requests increases, the load balancer performs its operations for each one.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 parsing or forwarding operations |
| 100 | 100 parsing or forwarding operations |
| 1000 | 1000 parsing or forwarding operations |
Pattern observation: The work grows directly with the number of requests.
Time Complexity: O(n)
This means the processing time increases in direct proportion to the number of requests.
[X] Wrong: "The load balancer processes all requests instantly regardless of count."
[OK] Correct: Each request requires processing, so more requests mean more work and time.
Understanding how request volume affects load balancer work helps you explain real-world system behavior clearly and confidently.
"What if the load balancer added caching for repeated requests? How would the time complexity change?"