• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Multi Server - Load Balancing - Session Affinity Control?

Bill.D

Active member
#1
Hey All,

This may have been discussed before and if so please direct me.

I am currently running a Xenforo System over 2 EC2 instances in Amazons AWS. Both instances are located in the same zone and are load balanced with "sticky sessions".

(This prevent's the problem of being logged out by going to a different server in the network. It does this by ensuring you consistently go to the same server past the Load Balancer via a cookie)

Problem: If that zone goes down; our site is down.

I am trying to develop a more redundant and fault tolerant system.

Problem: in a multi zone installation the "sticky session" option in the load balancer does not work.. It is hidden in the background that each zone will have a load balancer that is subsequently Load Balanced which messes up the sticky sessions.

Is there a way with-in Xenforo to Manage Session affinity for multi server installations?

Thanks,
-Bill
 

Bill.D

Active member
#5
Could you not store the session in memcached cluster?
Ok, I did some research and this is looking like a great solution.. One question though.. 1st a am a bit of a n00b to this.. But just to make sure.. PHP sessions to which this solution works with; is this also what manages people staying logged into xenforo while there usage trafic hopes between load balanced servers? If so you have made my day!

Thanks,
-Bill
 
Last edited:

Bill.D

Active member
#6
LMAO.. So memcached was the catalyst word for me.. I found this in Xenforo Help: http://xenforo.com/help/cache/
Here is the section to solve all of my problems :D with the use of MemCached :D
If you wish to read and write XenForo sessions to the cache, add the following line to your library/config.php file:
Code:
$config['cache']['cacheSessions'] = true;
Note that your cache must have enough space to hold the sessions, or users may not be able to login properly. We do not recommend writing sessions to the cache if you are using APC as your cache back-end.
 

Bill.D

Active member
#8
So you have memcache installed on both servers, and have both of them in the array set in config.php?
I haven't done a test set up yet but, from what I have been seeing it seems you want a single memcached server so all load balanced servers have a single point for session control that way it wont matter what server your on. I was thinking of using an AWS ElasticCache Server which from what I can find out: is Memcached, but we'll see ;-P
 

MattW

Well-known member
#9
I know you can have the cache replicated across your memcache servers. I had 3 running at one point (just because I had 3 VPS to mess about with), so you'd have redundancy in them if you were to loose the memcache server

PHP:
$config['cache']['backendOptions']=array(
        'compression'=>false,
        'servers' => array(
                array(
                        'host'=>'localhost',
                        'port'=>'11211'
                ),
                array(
                        'host'=>'95.154.207.118',
                        'port'=>'11211'
                ),
                array(
                        'host'=>'109.169.51.105',
                        'port'=>'11211'
                )
        )
);