AWS Elastic Load Balancing — effective troubleshooting

Ayoub Umoru
Nov 6 · 4 min read

When it comes to Elastic Load Balancing, a key element are listener rules. To get them right is very important — no compromises. Looking for a quick aha? Read on! :)

What is an Elastic Load Balancing again?

Elastic Load Balancing supports three types of load balancers: Application Load Balancers, Network Load Balancers, and Classic Load Balancers

Load balancer component
A load balancer serves as the single point of contact for clients. The load balancer distributes incoming application traffic across multiple targets, such as EC2 instances, in multiple Availability Zones. This increases the availability of your application. You add one or more listeners to your load balancer.

Listener component
A listener checks for connection requests from clients, using the protocol and port that you configure. The rules that you define for a listener determine how the load balancer routes requests to its registered targets. Each rule consists of a priority, one or more actions, and one or more conditions. When the conditions for a rule are met, then its actions are performed. You must define a default rule for each listener, and you can optionally define additional rules.

Target group component
Each target group routes requests to one or more registered targets, such as EC2 instances, using the protocol and port number that you specify. You can register a target with multiple target groups. You can configure health checks on a per target group basis. Health checks are performed on all targets registered to a target group that is specified in a listener rule for your load balancer.

Listener rules
You can configure listener rules to route requests to different target groups based on the content of the application traffic. Routing is performed independently for each target group, even when a target is registered with multiple target groups.

The following diagram illustrates the basic components.
An Application Load Balancer functions at the application layer.

Brief order
(1) After the load balancer receives a request, it (2) evaluates the listener rules in (3) priority order to determine which rule to apply, and then (4) selects a target from the target group for the rule action.

Our case - i came a cross two scenarios that might sound familiar to you?

Case 1 — Central LB setup

You have a single-alb for all setup, you want to have your listener rules right. You might start from having a more chaotic listener rule setup, and start to tighten it.

Suddenly you loose sight and it is not super clear to what rule exactly certain requests go and some requests do not go anywhere.

Case 2 — Troubleshooting a foreign LB setup without documentation

You are tasked to add another app to the LB and want to check with the existing listener rules. There is no documentation and you wonder where to start looking for clues.

Solution

Navigate to the Elasic Load Balancer of your choice and configure access logs. Wait a few days, or minutes — depending on the scenario you are in — basically until you have good collection of logs.

Navigate to the S3 bucket you have chosen and download the logs. Take a look at the following piece of documentation and look for “matched_rule_priority” and “target_group_arn”.

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html

This is what will helps you getting exactly the idea of what rules do what to your requests. The priority number is the only chance to identify the rule that has had an effect on the incoming request.

You — whoever you are — is welcome to reach out to me for clues, corrections and impulses. I am always happy to help.

Thank you for taking the time to read, i hope it was helpful. Please do not forget to give it a clap 👏 (you can also clap multiple times) and comment down below 👇. I would really appreciate it.

Ayoub Umoru

Written by

CTO of ZERODOTFIVE.COM and founder of Dynamic Horse

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade