To ensure high availability and also performance of Internet applications, it is currently common to usage a load-balancer.While some people provides layer 4 load-balancers, it can be at some point recommfinished to usage layer 7 load-balancers to be even more efficient via HTTP protocol.

You are watching: Why would you need to use single affinity

NOTE: To understand much better the distinction between such load-balancers, please check out the Load-Balancing FAQ.

Learn more by registering for our webinar: “Overview to muzic-ivan.info Stick Tables“

A load-balancer in an infrastructure

The picture below mirrors just how we usually install a load-balancer in an infrastructure:

*

This is a logical diagram. When working at layer 7 (aka Application layer), the load-balancer acts as a reverse proxy.So, from a physical allude of see, it have the right to be plugged almost everywhere in the architecture:

in a DMZin the server LANas front of the servers, acting as the default gatewaymuch ameans in an various other separated data centerThe obstacles of load-balancing web applications

Well, HTTP is not a associated protocol: it indicates that the session is entirely independent from the TCP relations.Even worst, an HTTP session can be spread over a couple of TCP connections…When tright here is no load-balancer involved, there won’t be any problems at all, since the single application server will be mindful the session indevelopment of all individuals, and whatever the number of client relationships, they are all redirected to the unique server.When utilizing numerous application servers, then the problem occurs: what happens as soon as a user is sfinishing repursuits to a server which is not mindful of its session?The user will acquire earlier to the login web page considering that the application server can’t access his session: he is thought about as a brand-new user.

To prevent this sort of problem, there are a number of ways:

Use a clustered web application server where the session are accessible for all the serversSharing user’s session information in a database or a file mechanism on application serversUse IP level information to keep affinity between a user and a serverUse application layer information to preserve persistence between a user and a server

NOTE: you have the right to mix different technc provided over.

Building a internet application cluster

Only a couple of assets on the industry allow administrators to create a cluster (favor Weblogic, tomcat, jboss, etc…).I’ve never before configured any of them, but from Administrators I talk as well, it does not seem to be a basic task.By the method, for Web applications, clustering does not mean scaling. Later, I’ll write an post explaining while even if you’re clustering, you still might need a load-balancer in front of your cluster to construct a robust and also scalable application.

Sharing user’s session in a database or a document system

This Technic uses to application servers which has actually no clustering features, or if you don’t want to permit cluster attribute from.It is pretty basic, you select a method to share your session, commonly a paper device like NFS or CIFS, or a Database choose MySql or SQLServer or a memcached then you configure each application server via appropriate parameters to share the sessions and to accessibility them if forced.I’m not going to give any details on exactly how to do it here, just google via appropriate keywords and you’ll get answers extremely easily.

IP resource affinity to server

An basic method to preserve affinity between a user and also a server is to use user’s IP address: this is dubbed Source IP affinity.Tbelow are a lot of concerns doing that and also I’m not going to information them right currently.The only thing you need to understand is that source IP affinity is the latest strategy to use as soon as you want to “stick” a user to a server.Well, it’s true that it will fix our problem as lengthy as the user use a single IP deal with or he never before readjust his IP resolve during the session.

Application layer persistence

Due to the fact that a internet application server has to identify each users individually, to avoid serving content from a user to an other one, we may usage this information, or at least attempt to reproduce the very same habits in the load-balancer to preserve persistence in between a user and also a server.The information we’ll usage is the Session Cookie, either set by the load-balancer itself or making use of one put up by the application server.

See more: What Does L Ecole Mean In French ? The French School System Explained ‍

The difference between persistence and also affinity

Affinity: this is once we usage an information from a layer below the application layer to maintain a client research to a solitary serverPersistence: this is as soon as we usage Application layer indevelopment to stick a customer to a solitary serversticky session: a sticky session is a session maintained by persistence

The main benefit of the persistence over affinity is that it’s a lot more specific, however periodically, Persistence is not doable, so we should count on affinity.

Using persistence, we intend that we’re 100% sure that a user will acquire redirected to a solitary server.Using affinity, we expect that the user may be redirected to the exact same server…

The interaction via load-balancing

In load-balancer you deserve to choose between numerous algorithms to pick up a server from a web farm to forward your client researches to.Some algorithm are deterministic, which means they deserve to use a customer side information to choose the server and also constantly send the owner of this information to the same server. This is wright here you typically execute Affinity