简体   繁体   中英

Load balancing and session management with CakePHP

first question on this wonderful site ;)

Note: I'm using CakePHP 2.6.2

So, here is my problem: I have a load balancer and 2 webservers behind. I put a website on those servers and since the load balancer doesn't use session stickiness (and I can't activate it, the servers aren't mine), I'm encountering problems with sessions (when the balancer switch me from one server to the other).

The only shared ressource between the servers is the database, so I though about using the CakePHP database session storage.

But at this point I'm wondering if there is any built-in solution in cakephp that allow to switch or duplicate a session between servers.

Thank you!

Not using file based sessions is really important, as you've probably figured out. Instead you have to use database, redis, or memcached based sessions.

Ideally you don't want to prevent people from moving between servers. Sticky sessions seem like a good solution until you lose a server due to some issue. Instead I find it is much better to aim for a shared nothing architecture where all your webservers are easily replaced.

Another thing you may need to solve is file uploads. In a multi-server setup, you cannot simply save uploaded files to local disk, as the following request may not hit the same server. Instead, I would recommend you look at blob storage providers like Amazon S3, Azure blob storage, and Rackspace cloud files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM