By using AWS re:Post, you agree to the AWS re:Post Terms of Use

NLB not distributing traffic between 2 servers

0

We have a two mail servers listening on 587. No matter what I do all traffic seems to be routed to mail server 1. I've tried stopping mail server 1 and requests see to trickle in to mail server 2 even though mail server 1 is marked unhealthy. Also, it seems mail tests to 587 hang intermittently. What parameters control the load balancing, I plan to replace mail server 1 with one running AL2023, but I am nervous when I take mail server 1 offline requests will start failing. Please advise.

asked 22 days ago48 views
2 Answers
1

See point 2.

Cross-Zone Load Balancing: By default, NLB does not enable Cross-Zone Load Balancing (CZLB). If your mail servers are in different Availability Zones, this could lead to uneven distribution. Consider enabling CZLB, but be aware that this may incur additional data transfer charges.

profile picture
EXPERT
answered 21 days ago
  • Thanks Gary, I assume putting the in the same AZ would make it balance better as well, right? Seems to default the whole idea of a load balancer if you ask me.

  • I'd keep the servers in different AZs for redundancy reasons.

0

The issue you're experiencing with your Network Load Balancer (NLB) not distributing traffic evenly between your two mail servers could be due to several factors. Let's address the potential causes and solutions:

  1. Load Balancing Algorithm: NLB uses a flow hash algorithm to route traffic. This means that for a given set of parameters (source IP, source port, destination IP, destination port), traffic will consistently route to the same target. This can sometimes lead to an uneven distribution, especially if you have a small number of clients or if most of your traffic comes from a limited set of source IPs.

  2. Cross-Zone Load Balancing: By default, NLB does not enable Cross-Zone Load Balancing (CZLB). If your mail servers are in different Availability Zones, this could lead to uneven distribution. Consider enabling CZLB, but be aware that this may incur additional data transfer charges.

  3. Health Checks: The behavior you're seeing where requests trickle to mail server 2 when server 1 is marked unhealthy is expected. NLB has a fail-open mode where it routes requests to all registered targets (including unhealthy ones) when all targets are considered unhealthy.

  4. Connection Draining: When replacing mail server 1, you should implement a strategy to gradually drain connections. NLB doesn't have built-in connection draining, so you'll need to manage this at the application level.

  5. Intermittent Hangs: The hanging issues on port 587 could be related to the NLB's TCP idle timeout. By default, this is set to 350 seconds. You might want to adjust this setting to better suit your application's needs.

To address these issues and prepare for replacing mail server 1:

  1. Check your target group settings and ensure both servers are properly registered and passing health checks.

  2. Consider enabling Cross-Zone Load Balancing if your servers are in different Availability Zones.

  3. Implement a strategy to gradually drain connections from mail server 1 before taking it offline.

  4. Monitor NLB metrics like ActiveFlowCount, HealthyHostCount, and UnHealthyHostCount to ensure proper distribution and health of your targets.

  5. Adjust the TCP idle timeout if necessary to address the hanging issues.

  6. If possible, implement a canary or synthetic monitoring to test the behavior when transitioning between servers.

By taking these steps, you can improve the traffic distribution and minimize the risk when replacing mail server 1. Remember to thoroughly test your setup before making any production changes.
Sources
Network Load Balancer (NLB) troubleshooting guide | AWS re:Post
Troubleshoot your Network Load Balancer - Elastic Load Balancing
Introducing NLB TCP configurable idle timeout | Networking & Content Delivery
Elastic Load Balancer: Maximizing Benefits and Keeping Costs Low | Networking & Content Delivery
Application, Network, and Gateway Load Balancing - Difference Between Load Balancing Types - AWS

profile picture
answered 22 days ago
profile picture
EXPERT
reviewed 21 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions