PHP/FCGI balancing

Igor Clark igor at pokelondon.com
Tue Jun 17 19:36:04 MSD 2008


Hi there, two related questions, one quickie, one more involved :-)

1) Is it possible to specify weighting between upstream FastCGI  
servers? If not in nginx config, then using some clever scheme?

2) Your thoughts on the following situation would be welcome!

Our application is 80% Flash with many AMF callbacks to dynamic PHP/ 
MySQL services. A majority of the actual bandwidth going out will be  
on SWFs and images.

Today we're pushing 20mbps in the pre-launch sign-up phase; the main  
campaign doesn't launch till next week.

We have 4 servers, quad-core Xeon 2.33ghz. 2 have 8GB RAM, the other 2  
have 4GB.

The current set up is thus:

- one 8GB is nginx, front-end reverse proxy and static web server;
- one of the 4GB boxes is php/fcgi;
- the other 4GB box is mysql.

The second 8GB has only just become available as it was being used on  
another, now closed, project.

The 3 deployed boxes are all handling the current traffic without  
breaking a sweat, low loads, high idle CPU percentages, plenty of RAM  
free, no waiting on IO. However of course as the new gear has become  
available and will be sitting around doing nothing otherwise, I want  
to use it to best effect in next week's campaign.

We have a hardware load balancer available, weighted round robin, in  
front of the 2 8GB boxes.

I'm considering whether to:

- leave all web serving to 8GB box 1, and dedicate 8GB box 2 to PHP  
application serving, or

- load-balance web traffic between both 8GB boxes, say 70% to existing  
box and 30% to new box, and run PHP app server on new 8GB box.

As per Q1, I'd like to be able to specify some weighting on the  
fastcgi-->PHP traffic so that I could tune which box processes what a  
bit more finely, but from what I can see in the nginx documentation,  
this isn't possible.

The latter way seems to spread the load, but the former way dedicates  
machines to doing one thing at a time. Given that the nginx box is  
currently running at loads of less than 0.1 and has over 2GB of RAM  
free, perhaps the extra nginx muscle isn't necessary.

There is a bit of processing overhead on the PHP side, as the AMF  
codec processing has to be done in PHP (the PHP AMF C extension has a  
bug with AMF3 which breaks our app) - although we're using APC, which  
seems to speed things up nicely.

What do you think would be most sensible?

Many thanks for any thoughts.
Igor

--
Igor Clark • POKE • 10 Redchurch Street • E2 7DD • +44 (0)20 7749 5355  
• www.pokelondon.com




More information about the nginx mailing list