Learn
2 min readJul 12, 2022

--

Photo by Derek Finch on Unsplash

Load balancer
A layer in front of your array of app servers/web servers to control traffic — the simplest being round robin.

Health Check
Load balancer sends health check pings to the target groups(app servers) to see which ones are healthy so that the requests from the client can be routed to the healthy ones.

HTTP load balancer
As the name indicates, the HTTP load balancer load balances HTTP traffic. So it does an HTTP health check to the target group and expects an HTTP Status of 200 OK back if the target group is healthy.

Target group is where your application is running. And your application mandates authentication and respond with 401 status code to a ping. The load balancer sees that as unhealthy and eventually stops sending requests to it. So for the client, your application is down even when it is up as the load balancer thinks it is down.

Solution in the AWS ecosystem
On the ALB, Health Check settings tab, you have the ability to give a range of status codes as “200–404” in place of “200” that would be there by default.

Once you do this, the ALB accepts 401 from your application as a healthy sign. Your application is now seen as alive by the clients coming through the ALB.

CloudFormation Matcher tag
Now, if you had to replicate the same solution in CloudFormation, you would need to use the “Matcher” parameter with “HttpCode” attribute set as “200–404”.

--

--