Request always going to second server in load balancer

Shyam Kumar 846 Reputation points
2025-05-11T11:22:33.5366667+00:00

I have configured basic regional load balancer and it has 2 VMs backend pool

but request always is going to second server even 2 machines are available.

Please let me know how can I make request goes to both the servers and verify it?

Azure Load Balancer
Azure Load Balancer
An Azure service that delivers high availability and network performance to applications.
506 questions
{count} votes

Accepted answer
  1. Sai Prasanna Sinde 6,645 Reputation points Microsoft External Staff Moderator
    2025-05-12T06:04:43.6933333+00:00

    Hi @Diptesh Kumar

    We think there is an issue with the Session Persistence (Source IP Affinity) or Health Probe failures for the other server.

    • By default, Azure Load Balancer uses a five-tuple hash (Source IP, Source Port, Destination IP, Destination Port, Protocol) to distribute traffic. This generally provides good distribution across available healthy instances.

    However, if Session Persistence is enabled on your load balancing rule, it will attempt to direct all subsequent traffic from the same client IP address to the same backend server as the initial request.

    • If you are testing from a single machine or a single external IP address, this would explain why you always hit the same server (For your case, the second one).

    Go to your Load balancer > Settings > Load balancing rule > Session persistence > If it's set to anything other than None, change it to None (Default) > Save.

    Note: For Basic SKU load balancers, the only session persistence option is Client IP. For Standard SKU, you have more options, but disabling it is the key here.

    • The load balancer only sends traffic to backend instances that are reported as healthy by the configured health probe. If your first VM is unhealthy, traffic will be directed only to the second one if it's healthy.

    Go to your Load balancer > Monitoring > Backend health > select your BP > please verify the health status of each instance in the backend pool > The instances should be Healthy.

    • If one is unhealthy, troubleshoot the health probe configuration and ensure the application on that VM is running and responding correctly on the configured health probe port and path.
    • Once you've verified session persistence is off and both backend VMs are healthy, you need a way to see which server is receiving the request.

    On your first VM, modify the web page or API endpoint response to include something like "Response from Server 1" and for your second VM, modify the response to include "Response from Server 2" and access the load balancer public IP address or DNS name multiple times, and you should observe the response alternating between "Response from Server 1" and "Response from Server 2", indicating traffic is being distributed.

    For your reference: Troubleshoot Azure Load Balancer backend traffic responses

    Configure the distribution mode for Azure Load Balancer


    Kindly let us know if the above helps or you need further assistance on this issue.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2025-05-11T11:35:27.12+00:00

    Hi @Diptesh Kumar ,

    are you testing the load balancer from only one source computer? Or are you sending the requests from 2 different computers?

    Depending on the configured distribution mode the distribution of requests are based on different criteria. But the client/source IP is part of any distribution mode as far as I know.

    At the end: Every request of the same source/client IP will be using the same VM in the backend pool.

    If you sending the requests from different source/client IPs different VMs in the backend pool should be used.

    Source:

    Azure Load Balancer distribution modes

    Azure Load Balancer algorithm


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards

    Andreas Baumgarten

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.