Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load balancing and sessions

What is the better approach for load balancing on web servers? My services run in .NET and Mono, so they could be hosted on IIS or Apache2, and the will have to provide SSL connection.

I've read two main approaches, store the state in a common server and use sticky sessions, there is any other else?

I've read 3 diffent things about sticky sessions:

1)the load balancing device will know with which server did you start the connection and all the further connections from that host will be routed to the same server.

2)the load balancing devide read a cookie named: JSESSIONID

3)the load balancing devide read a cookie named: ASPSESSIONID

I'm a little bit confused, what will happen exactly? As the connections will be SSL there is not a chance for the load balancing devide of read the cookies, so then what?

About store the estate in a common server, what solutions do you know? I've read memcache is a good solution but is there any other else?

Cheers.

like image 671
vtortola Avatar asked Apr 22 '10 18:04

vtortola


People also ask

What is session affinity in a load balancer?

Session affinity, also known as “sticky sessions”, is the function of the load balancer that directs subsequent requests from each unique session to the same Dgraph in the load balancer pool.

What is load balancing and its types?

Elastic Load Balancing supports the following types of load balancers: Application Load Balancers, Network Load Balancers, and Classic Load Balancers. Amazon ECS services can use these types of load balancer. Application Load Balancers are used to route HTTP/HTTPS (or Layer 7) traffic.

What is a load balancer used for?

A load balancer is a device that acts as a reverse proxy and distributes network or application traffic across a number of servers. Load balancers are used to increase capacity (concurrent users) and reliability of applications.

Is session affinity a load balancing algorithm?

Session affinity overrides the load-balancing algorithm by directing all requests in a session to a specific application server. For some applications to work correctly, the application requires session affinity between the client and the application server.

What are the two approaches of load balancing?

There are two primary approaches to load balancing. Dynamic load balancing uses algorithms that take into account the current state of each server and distribute traffic accordingly. Static load balancing distributes traffic without making these adjustments.


2 Answers

When using SSL with a load balancer, it is common to put the SSL certificate on the load balancing server, and not on the back end servers. In this way you only need 1 certificate on 1 server. The load balancer then talks to the back end servers using plain HTTP. This obviously requires that your back end servers are not directly accessible from the internet.

So, if the load balancer is responsible for decrypting the request, it will also be able to inspect the request for a jsessionid.

Sticky sessions work well with Apache as load balancer. You should check out the Apache modules mod_proxy and mod_proxy_balancer.

like image 153
Eric Eijkelenboom Avatar answered Oct 17 '22 12:10

Eric Eijkelenboom


Generally SSL load balancing means that the client is talking to the load balancer over HTTPS, and the load balancer is talking to the web server via HTTP.

Some load balancers are smart enough to establish an SSL session with the web server (so it can read cookies) and maintain a separate SSL session with the client.

And, some load balancers can maintain stickiness without using web server cookies. My load balancers are able to send their own cookies to the client (they have a bunch of other stickiness settings as well).

like image 1
Seth Avatar answered Oct 17 '22 13:10

Seth