Hot answers tagged

25

edit: My answer only covers the original unedited question, which was whether this sort of thing is typical in load balancers/reverse proxies. I'm not sure whether nginx/product X has support for this, 99.9% of my reverse proxying experience is with HAproxy. Correct. HTTP Keep-Alive on the client side, but not on the server side. Why? If you break down a ...


12

There are two main downsides: Your load isn't evenly distributed. Sticky sessions will stick, hence the name. While initial requests will be distributed evenly, you might end up with a significant number of users spending more time than others. If all of these are initially set to a single server, that server will have much more load. Typically, this ...


6

yes it is called session persistance http://support.f5.com/kb/en-us/products/lc_9_x/manuals/product/lc_config_guide_10_1/lc_persist_profiles.html


6

I would suggest doing all your SSL processing in HAProxy and using the proxy protocol (send-proxy and accept-sslproxy) so client information gets passed from the ssl processor to the frontend+backend. That looks something like: listen ssl-proxy bind 1.2.3.4:443 ssl crt /etc/ssl/mycert.pem npn http/1.1 mode tcp bind-process 2 3 4 server http ...


5

Nginx supports keep-alive on both sides. client side: http://nginx.org/r/keepalive_timeout backend side: http://nginx.org/r/keepalive


5

I recently read a great article in TechNet regarding "Providing Scalability for ASP.NET Applications". It went into the pros and cons of each possible solution. Take a read: TechNet June 2009 - Providing Scalability for ASP.NET Applications


4

PHP store it's session in plain files. Have you tried storing them on a common storage? Similiar question: Share PHP sessions in cloud file system Here is an article about this specific issue and different approaches: http://kevin.vanzonneveld.net/techblog/article/enhance_php_session_management/


3

In addition to the excellent answer from Christopher, sticky sessions mean that you've lost a couple of the huge benefits of redundant servers -- the ability to take one or more down for maintenance, and transparency in the face of system failure. I consider sticky sessions a strong indicator of poor application architecture and/or poor programming. "Avoid ...


3

HAProxy 1.5 (the current development version) implements stickiness on response with the stick store-response command. The command would be like this: stick store-response hdr(X-Session) stick on url-param(session) # the session ID is in a query parameter # if the session ID is in the path, like /session/{session ID}/doSomething # in this case, the ...


3

We us an F5 Big-IP LTM for this. Configuration is straightforward. Most modern hardware load balancing solutions can do this; software solutions like Zeus should be able to as well. Many cloud providers like Rackspace and AWS provide software load balancers based on Zeus or similar technologies, if you happen to be using one of these platforms.


2

I finally got the config to work. I had to to add following settings in the JBoss7 config (standalone.xml): <system-properties> <property name="jvmRoute" value="node1"/> <property name="UseJK" value="true"/> </system-properties> and: <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" ...


2

Sticky sessions are IP-based, so different browsers will still go to the same backend because the source IP address remains the same.


2

If your backend servers (tomcat) are clustered, they should replicate sessions too. In the event of an http failure, connections to 1 http node should go to another node. The jsessionid parameter should give the http / mod_jk enough info to know which node to route to (e.g. jsessionid=lkj234lkj2ljk234lj.jvmRoute1 will tell mod_jk that this session is due for ...


2

There seems to be a related issue: http://www.coderanch.com/t/87863/Tomcat/Tomcat-Cluster-Woes The workaround is to add: org.apache.catalina.ha.session.ClusterSessionListener.level = SEVERE to your logging.properties file.


2

if your app is sensitive to users switching app servers while in a session, then you want the sticky hold time set to at least as long as the expiration time of the session cookie. your sticky table is set to expire entries after 30 minutes. so while your users may continue to send the same session id, if they pause for more than 30 minutes then their ...


2

A response was provided here on the haproxy mailing list excerpt simply update the line below in your configuration to: stick on url_param(SIMULATE_STICKY_SESSION,;) table simulate By default, url_param search for a parameter after the question mark (?). The configuration above overwrite this by looking for your cookie from the semi-colon ...


2

If you define a peer for the server, even if it is only one and it is the local one, at each soft restart of haproxy, the state should be replicated to the new process. Documentation


2

Yes, you can solve all those problems and more with the use of a centralised session store. Without knowing your application, it's impossible to point you at a definitive guide for implementing it (and it would be a Stack Overflow question anyway), but it's usually as simple as either setting an option (in frameworks like Rails) to writing a few lines of ...


2

From: http://wiki.nginx.org/HttpUpstreamModule#ip_hash The key for the hash is the class-C network address of the client. Also from: nginx-0.8.53/src/http/modules/ngx_http_upstream_ip_hash_module.c: 91 static ngx_int_t 92 ngx_http_upstream_init_ip_hash_peer(ngx_http_request_t *r, 93 ngx_http_upstream_srv_conf_t *us) 94 { ... ...


2

While this question is quite old and the answer is correct, after some digging to resolve my own load balancing problem I found that there is a newer option to make the client ip based on the X-Forwarded-For or X-Real-IP and when combined with the ip_hash directive it properly balances load using the user's actual IP as the hash. ...


2

Thanks to @Shane Madden's comments, I re-read the tomcat cluster docs in http://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html, especially in this part -> "If your Tomcat instances are running on the same machine, make sure the tcpListenPort attribute is unique for each instance, in most cases Tomcat is smart enough to resolve this on it's own by ...


2

Usually when you are using a cookie it comes in a response from the back-end server with a "set-cookie" header. This is usually in response to a login. If this doesn't happen then HAProxy will not be able to stick you to the same back-end server This option allows HAProxy to "learn" about a cookie based on a HTTP Request not just a HTTP Response with ...


1

IME, there's little overhead between using file based sessions and database sessions (last time I looked at this in some detail I used master/master replication on 3 mysql nodes) - but the latter more often entails an additional network trip compared to the former (accessing a local mysql instance the difference wan't measurable compared with a local-only ...


1

The drawback of sticky-sessions is that with a growing number of nodes (in the range of > 100, > 1000) the probability of failure increases. Then it's preferable that it doesn't matter which node serves the request. However there are issues that have to be solved with sticky sessions differently, which of course depends on the requirements and the ...


1

I believe that sticky sessions are defined with the advance-balance statement. If you don't specify advanced-balance for a content, CSS won't use stickyness. Like this: content content-appA add service server1 add service server2 url "/appA/*" advanced-balance arrowpoint-cookie protocol tcp port 80 vip address 1.2.3.4 active ...


1

There's nothing available to solve this out of the box. But you could subclass MemcachedBackupSessionManager and use the backgroundProcess method (that's invoked by tomcat every second or every 10 secs, not sure about this) to ping your configured memcacheds. A very simple implementation looks like this: package de.javakaffee.web.msm; public class MyMsm ...


1

I'm not super happy about this but it realiable works; I have inserted a cookie in to the client requests instead of tracking the ASP .NET session ID: listen app-servers 127.0.0.1:80 cookie server insert balance roundrobin option persist option redispatch server appserver1 10.0.0.1:80 cookie srv1 server appserver2 10.0.0.2:80 ...


1

Are the balancer members setting the correct route ID in their session cookies? Yes, you'll need to define the routes on the BalancerMember lines. Something like this in your BalancerMember lines: BalancerMember ajp://1.1.1.1:8010/testing keepalive=On loadfactor=1 ping=10 ttl=600 route=testing1 And the associated ID in your Tomcat config must match: ...


1

You may get uneven balancing due to proxies, heavy users sharing the same IP, etc. And obviously if a machine fails you lose all your sessions when users are shifted to the other machine. A disadvantage that you don't have with a hybrid system with cached state loaded from a shared backend.


1

Do you really need to use Lighttpd as your load balancer? You might be better off using something like HAproxy that supports source address hashing



Only top voted, non community-wiki answers of a minimum length are eligible