View previous topic :: View next topic |
Author |
Message |
cornish n00b
Joined: 02 Oct 2007 Posts: 27
|
Posted: Mon Apr 14, 2008 4:09 pm Post subject: PHP session management and load balancing |
|
|
I need to distribute http requests across two server but also mating the php sessions at the same time.
I thought of using DNS round robin but realized that the PHP sessions would be out of sync when a user clicks through the site.
Google has come up with some answers
Balance and Ultra Monkey
Does any one use this software and is it right for my needs?? |
|
Back to top |
|
|
nixnut Bodhisattva
Joined: 09 Apr 2004 Posts: 10974 Location: the dutch mountains
|
Posted: Mon Apr 14, 2008 6:27 pm Post subject: |
|
|
perhaps haproxy is what you're looking for
Code: | * net-proxy/haproxy
Available versions: ~1.3.13.1 ~1.3.14.1 {pcre}
Homepage: http://haproxy.1wt.eu
Description: A TCP/HTTP reverse proxy for high availability environments
|
_________________ Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered
talk is cheap. supply exceeds demand |
|
Back to top |
|
|
daemonflower Apprentice
Joined: 17 Jul 2004 Posts: 290
|
Posted: Mon Apr 14, 2008 7:59 pm Post subject: |
|
|
I don't know any of these proxies, but I think maybe it is easier to beef up the script that does the round robin distribution a little: let it store the client IPs in an array and always route the same client to the same server. Should be done quickly and less pain than installing and learning a full blown proxy solution.
2 cents and all that |
|
Back to top |
|
|
kashani Advocate
Joined: 02 Sep 2002 Posts: 2032 Location: San Francisco
|
Posted: Mon Apr 14, 2008 8:03 pm Post subject: |
|
|
Rather than discuss software I'll discuss the two methods you can use.
1. sticky
In load balancer terminology sticky on a virtual IP refers to sticking a user to a particular real server. Your load balancer would need to keep track of the incoming user's IP and the server it was handed off to. Additionally you will set a time period for the stickiness to last, I'd suggest at least one hour.
2. db
Rather than worry about locking a user to a webserver, why not keep session data in one place, namely the db. I recommend a seperate db, sitename_session, and using innodb because session tends to be write intensive.
The limitations with locking a user to a webserver is that if the webserver dies you lose all session data when users shift to the other servers. The limitations with sessions on a db is now you have the overhead of a db. Between the two I like the db solution best, but most of the websites I've worked with recently already had a db so it was an easy choice.
kashani _________________ Will personally fix your server in exchange for motorcycle related shop tools in good shape. |
|
Back to top |
|
|
|