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

I have two IIS servers running using NLB. Unfortunately, I cannot use a shared session server, so each server uses its own session. How can I guarantee that all requests from the same user are redirected to the same IIS server?

+6
iis session nlb
source share
6 answers

I think you are looking for Sticky Sessions. However, sticky sessions are implemented by your load balancer. You probably need to configure an external load balancer (BIG-IP, HAProxy, etc.) that can perform sticky sessions.

+3
source share

Found this and decided to share with others:

Use the customer proximity function. When client binding is enabled, network load balancing routes all TCP connections to the same cluster node. This allows you to maintain session state in the host memory. You can enable client convergence in the Add / Edit Port Rules dialog box in Network Load Balancing Manager. Select Single or Class C 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 node maintains session state (for example, server cookies) between connections. For more information about the affinity of network load balancing, see the Help in the Network Load Balancing snap-in.

+15
source share

You can do this easily as long as none of your clients use a distributed proxy system:

In the simplest NLB clusters, the โ€œport rulesโ€ tab, you can select โ€œfiltering modeโ€ and affinity: you cannot choose โ€œnoโ€ because you do not have central sessions. But "simple" redirects each user to the same server, while ip remains unchanged. If you, for example, Proxy servers with the AOL anti-alias, then "class C" may be a safe choice (although, perhaps, load balancing will decrease slightly), since the same class C network goes to the same server.

I assume that it is easy to implement MS so that both nodes know which ip is even or odd, or which class C triplet of the network is even or odd and distributes the load always the same depending on the IP address

+1
source share

Why do you need this? If this is due to the state of the session, then you must have a database or server outside the process configured in a common place, and all links to them are referenced.

0
source share

I would consider a reverse proxy that sits in front of any server and remembers which external users use which servers.

I know (because of its use in this way) Cherokee supports IPHash proxies, but I'm sure there are many more.

0
source share

To add an answer to Lloyd, you should avoid using a session in a load-balanced environment. The whole purpose of using a session is to avoid database queries; if you end up storing session data in a database, you usually get nothing.

The reason is that 1. you now need to make 2 calls to the database for each page load (retrieve and save) and 2. this data should now pass through the serialization / deserialization boundaries. In most cases, this becomes a more expensive operation than just getting the data you want to start with.

Now, to your actual question. You have the ability to store session data in a view state. You can opt out of the session and use cookies instead. If you go along this route, be sure to encrypt them at the exit and decrypt them when received.

0
source share

All Articles