Is it better to upstream php processes via nginx or use a front facing load balancer?

Hi,
Is it better to use a hardware load balancer in front of multiple nginx
boxes, each running their own php processes or is it better to use
nginx’s
upstream functionality and round robin php requests?

How high traffic have your sites got?

In my system, Nginx plays a role of a LB and static file server. It
dispatches .php requests to a pool of Apache instances and PHP FCGI. It
works great for 600 000+ page views per day.

Ilan B. wrote:

Hi,
Is it better to use a hardware load balancer in front of multiple nginx
boxes, each running their own php processes or is it better to use
nginx’s
upstream functionality and round robin php requests?

1.6mm page views per day and growing (all dynamic php), this does not
inclue
a large number of static files (mostly mp3 files) being served as well.

Nginx is serving both PHP and static files all from the same server.

Main bottleneck right now is PHP processes getting overloaded, probably
due
to high number of connections (we are working on reducing this number -
we
have some inefficiencies where a single page may make over 120 requests
before completely loading). The other issue is the number of database
requests per page can be very high which delays PHP response times and
increases queue.

Regardless, we need to add another box, but I’m trying to figure out if
best
approach is physical LB in front of duplicate nginx boxes, i.e. each box
serving both PHP and static files OR more complex solution with one of
the
boxes acting as master and routing PHP requests via Nginx to other
boxes,
etc. as well as possibly adding a static server specifically for images
and
mp3 files.

We use nginx as a pure LB.

All php sessions and static files are shared to all apache 2 webheads
via OCFS2.

Then we use upstream fair, and removed the need for sticky sessions (
by using a clustered FS to share the session files to all nodes)

This lets every image/html/php request go to different webheads for
maximum response for the EU.

Also we wrote it so if nginx gets a proxy error, it marks the webhead
as bad and reprocess the request until it finds a good webhead to proxy
to.

Btw use use apache webheads so we can use php as a module rather than
fcgi and spawn php type methods.

Hope it helps
David