Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep user requests on the same server when using IIS NLB?

Tags:

iis

session

nlb

I have two IIS servers running using NLB. Unfortunatelly I cannot use shared session server, so every server is using its own session. How can I ensure, that all requests from the same user are forwarded to the same IIS server?

like image 375
Sergejus Avatar asked May 14 '09 22:05

Sergejus


Video Answer


3 Answers

Found this and decided to share with others:

Use the client affinity feature. When client affinity is enabled, Network Load Balancing directs all TCP connections to the same cluster host. This allows session state to be maintained in host memory. You can enable client affinity in the Add/Edit Port Rules dialog box in Network Load Balancing Manager. Choose either Single or Class C affinity to ensure that only one cluster host will handle all connections that are part of the same client session. This is important if the server application running on the cluster host maintains session state (such as server cookies) between connections. For more information about Network Load Balancing affinity, see Help in the Network Load Balancing snap-in.

like image 105
Sergejus Avatar answered Oct 22 '22 06:10

Sergejus


I think what you're looking for is Sticky Sessions. Sticky sessions are implemented by your load balancer though. You probably need to setup an outside load balancer (BIG-IP, HAProxy, etc.) that can do sticky sessions.

like image 31
Min Avatar answered Oct 22 '22 05:10

Min


You can do that easily as long as none of your customers use a distributed proxy system:

In the protieries of the NLB cluster, tab "port rules" you can choose the "filtering mode" and the affinity: You cannot choose "none" because you don't have central sessions. But "simple" would redirect every user to the same server as long as the ip stays the same. If you e.g. anticiapte AOL proxy servers then "class C" might be a secure choice (albeit maybe reducing the load balancing a little bit), because the same class C net goes to the same server.

I guess that is easily implemented by MS in a way that both hosts know which ip is even or odd or which triplet of the class C net is even or odd and distribute the load always in the same way depending on the IP-address

like image 34
Christian Avatar answered Oct 22 '22 07:10

Christian