Load balancer traffic redirection

Racheal 226 Reputation points
2023-05-23T12:42:51.7033333+00:00

HI ,

 

We have configured standard load balancer to distribute traffic to VMs in backend pool.

When one of the VM is unhealthy users who are in that VM will be redirected to the other healthy VM but always end up in session expired page.  so the progress is lost . How can we handle this issue? 

 

Does session persistence : clientIP needs to be changed to None . hope that will not address this issue.

Could some one help on this?

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

Accepted answer
  1. VasimTamboli 3,810 Reputation points
    2023-05-23T12:52:29.3966667+00:00

    When using a load balancer to distribute traffic to VMs in a backend pool, it's important to consider session persistence or session affinity. Session persistence ensures that a user's requests are consistently directed to the same backend VM during their session. By default, the load balancer uses the client's IP address for session persistence, which means that requests from the same client IP will be directed to the same backend VM.

    In the scenario you described, when an unhealthy VM is detected, the load balancer correctly redirects the users to other healthy VMs. However, since the session persistence is based on the client's IP address, the users may end up on a different VM than the one they initially connected to. This can result in a session expired page because the session state is not maintained across VMs.

    To address this issue, you have a few options:

    Change the session persistence to "None": If you change the session persistence to "None" or "Source IP Affinity," the load balancer will distribute the requests evenly across the available backend VMs without considering the client's IP address. This can help in avoiding the session expired issue, but it may also lead to uneven distribution of traffic.

    Implement session state sharing: If your application relies on session state, you can consider implementing session state sharing across the backend VMs. This involves using a shared session state store, such as a database or a distributed cache, where the session data is stored and can be accessed by any of the backend VMs. This way, even if the user's request is redirected to a different VM, the session data can be retrieved and the progress can be maintained.

    Sticky sessions: Another option is to enable sticky sessions or cookie-based session affinity. This involves the load balancer inserting a cookie into the client's browser upon the first request, and subsequent requests from the same client will be directed to the same backend VM based on the cookie. This ensures that the session remains on the same VM, maintaining the session state and avoiding session expired issues.

    The choice of solution depends on the specific requirements and architecture of your application. Consider the trade-offs between distributing the traffic evenly, maintaining session state, and the complexity of implementing session state sharing.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful