Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
PHP session management and load balancing
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
cornish
n00b
n00b


Joined: 02 Oct 2007
Posts: 27

PostPosted: Mon Apr 14, 2008 4:09 pm    Post subject: PHP session management and load balancing Reply with quote

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
View user's profile Send private message
nixnut
Bodhisattva
Bodhisattva


Joined: 09 Apr 2004
Posts: 10974
Location: the dutch mountains

PostPosted: Mon Apr 14, 2008 6:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
daemonflower
Apprentice
Apprentice


Joined: 17 Jul 2004
Posts: 290

PostPosted: Mon Apr 14, 2008 7:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
kashani
Advocate
Advocate


Joined: 02 Sep 2002
Posts: 2032
Location: San Francisco

PostPosted: Mon Apr 14, 2008 8:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum