I’m using lighttpd as webserver for php application server. The avg. load on this server is about 2-3. MySQL database is separated to another server (it’s load ~0.4). How could I scale php application server?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In a few words, a solution, generally speaking, is to :
The load-balancing server can be some specialized hardware ; or a reverse-proxy, using Apache (see
mod_proxy_balancerfor example), nginx (see Load Balancing with Nginx, for example), varnish, …The most important problems you’ll generally face when using several PHP servers instead of ones are related to the filesystem : with several servers, each server has its own disks and filesystem.
For example, if a user is randomly balanced on server 1 for one page, and server 2 for another page, you cannot use file-based sessions : the session will be created on server 1, but will not be found on server 2, later.
In this specific case, you’ll have to use another mecanism to store sessions — store them in a database, or memcached, for example.
Same things with images (uploaded by users, for example) : you’ll have to either :
Edit after the comment : For the deployment, with several servers, I generally do exactly as I would with only one server.
For more informations on the kind of process I often use, you can take a look at the answer I gave a while back on this question : Updating a web app without any downtime.
The explanation given there is for one server, but to do the same thing on several servers, you can :
(I’ve done this with up to 7 servers, for one application, and never had any problem)