Application Load Balancer (ALB) in AWS - Time & Space Complexity
We want to understand how the work done by an Application Load Balancer changes as more requests come in.
Specifically, how does the number of requests affect the number of operations the ALB performs?
Analyze the time complexity of this ALB request routing process.
// Pseudocode for ALB handling requests
for each incoming request {
check listener rules
select target group
forward request to target
}
This sequence shows how the ALB processes each incoming request by checking rules and forwarding it.
Look at what happens repeatedly as requests come in.
- Primary operation: Processing each incoming request (checking rules and forwarding)
- How many times: Once per request
As the number of requests grows, the ALB processes each one individually.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 10 request processings |
| 100 | 100 request processings |
| 1000 | 1000 request processings |
Pattern observation: The work grows directly with the number of requests.
Time Complexity: O(n)
This means the ALB’s work increases in a straight line as more requests arrive.
[X] Wrong: "The ALB processes all requests at once, so the time doesn’t increase with more requests."
[OK] Correct: Each request is handled separately, so more requests mean more processing steps.
Understanding how load balancers handle requests helps you explain system behavior clearly and shows you grasp real cloud workloads.
"What if the ALB had to check multiple complex rules for each request? How would the time complexity change?"
Practice
Application Load Balancer (ALB) in AWS?Solution
Step 1: Understand ALB's role in traffic management
ALB distributes incoming HTTP/HTTPS requests to multiple backend servers to balance load and improve availability.Step 2: Compare options with ALB's function
Options A, B, and C describe other AWS services, not ALB's main function.Final Answer:
To distribute incoming web traffic across multiple targets for better availability -> Option BQuick Check:
ALB = traffic distribution [OK]
- Confusing ALB with storage services
- Thinking ALB handles security monitoring
- Mixing ALB with network setup services
Solution
Step 1: Identify supported ALB listener protocols
ALB supports HTTP and HTTPS protocols for listeners, not TCP, FTP, or SMTP.Step 2: Match correct protocol syntax
ListenerProtocol: HTTPusesHTTP, which is valid for ALB listeners.Final Answer:
<code>ListenerProtocol: HTTP</code> -> Option AQuick Check:
ALB listener protocol = HTTP or HTTPS [OK]
- Using unsupported protocols like FTP or SMTP
- Confusing ALB with Network Load Balancer protocols
- Incorrect syntax for listener protocol
tg1 and tg2. The ALB uses a rule to route requests with path /api/* to tg1 and all other requests to tg2. What happens when a user requests /api/users?Solution
Step 1: Analyze the ALB routing rule
The rule states requests with path starting/api/go totg1.Step 2: Match the request path
The request path/api/usersmatches the/api/*pattern, so it routes totg1.Final Answer:
The request is routed to target group <code>tg1</code> -> Option AQuick Check:
Path /api/* routes to tg1 [OK]
- Assuming default target group handles all requests
- Thinking requests route to multiple target groups
- Ignoring path-based routing rules
Solution
Step 1: Understand HTTPS listener requirements
HTTPS listeners require a valid SSL certificate to establish secure connections.Step 2: Consequence of missing certificate
Without a certificate, TLS handshake fails, causing ALB to reject HTTPS requests.Final Answer:
The ALB will reject all HTTPS requests with a TLS handshake failure -> Option DQuick Check:
HTTPS needs SSL cert; missing cert = handshake failure [OK]
- Assuming ALB auto-generates SSL certificates
- Thinking ALB downgrades HTTPS to HTTP automatically
- Believing ALB routes unencrypted traffic on HTTPS listener
tg-mobile and desktop users to tg-desktop. Which ALB feature should you use to implement this?Solution
Step 1: Identify how to detect device type in requests
User device type is typically indicated in the HTTP User-Agent header.Step 2: Choose ALB feature for routing based on headers
ALB supports listener rules that route traffic based on HTTP headers like User-Agent.Step 3: Evaluate other options
Health checks do not detect device type; path-based routing requires URL changes; sticky sessions maintain session but don't route by device.Final Answer:
Use ALB listener rules with HTTP header-based routing on the User-Agent header -> Option CQuick Check:
Header-based routing = device type routing [OK]
- Using health checks to detect device type
- Relying on path-based routing without URL changes
- Confusing sticky sessions with routing logic
Ready to prove it?
Pass the test and this pattern moves unknown
