Page 1 of 1

Clustering PHP : How to do it?

Posted: Tue Jan 31, 2012 9:43 pm
by bgundal88
Dear developers,

I have a plan to host my PHP script in a server first, then adding more servers in the future when the users reach the limit. but there are lots of question popping in my mind such as :

1. if in the beginning the code was designed to be run in a single server, but later on this server is not 'strong' enough to handle the hits per day or number of users. Can I just buy the second server and put the code there?

by adding this new server into my DNS list, will it automatically handle the request? what if this code has 'session', such as 'login area'? how to make user 'stick' with the server one so that the 'session' not broken, while other user can be handled by server two?

2. I have read about Zend Server Cluster Manager, but the cost is too high, I think. Is there any affordable ways to do this clustering thing?

3. Also, I have information about Yii framework and how fast it is. but, I don't see Yii has some kind like Zend Server Cluster Manager. Is that mean if I have Yii code it will be difficult to be clustered?

thanks...

Re: Clustering PHP : How to do it?

Posted: Wed Feb 01, 2012 12:52 am
by Christopher
You can use memcache for sessions and load balance users across multiple servers.

Re: Clustering PHP : How to do it?

Posted: Wed Feb 01, 2012 2:08 am
by bgundal88
Hi Chris,

Thanks for your reply, but I have more questions about memcache.

Let's say I have 3 servers and I have a plan to use this servers as following order :

Server 1 : database server only
Server 2 : web server only
Server 3 : memcache server only

In the future, if I have to buy another server, the fourth server will become web server and so on... In this scenario, database and memcache server are centralized.

Or alternatively :

Server 1 : database server only
Server 2 : web server + memcache server
Server 3 : web server + memcache server

In this second scenario I will use every new server as web and memcache server at the same time.

Which scenario do you think is better, chris? Thanks!

Re: Clustering PHP : How to do it?

Posted: Thu Feb 02, 2012 1:39 am
by Christopher
Memcache is a distributed system, each node runs a daemon. So the second example is how it works.