PHP cluster with nginx

Multiple PHP backends with single nginx instance.

Let's assume, that You have 5 php-fpm backends on 192.168.0.10 to 192.168.0.13, and a single nginx on 192.168.0.9.

After Your PHP code is propagated to each PHP backend, You have to declare in nginx:

upstream php-cluster {
    ip_hash; #sticky session (single user = single backend)
    server 192.168.0.10:9000 max_fails=5 fail_timeout=30s;
    server 192.168.0.11:9000 max_fails=5 fail_timeout=30s;
    server 192.168.0.12:9000 max_fails=5 fail_timeout=30s;
    server 192.168.0.12:9000 max_fails=5 fail_timeout=30s;
}

and in each virtual host that uses PHP:

location ~ \.php$ {
    fastcgi_pass php-cluster;
    fastcgi_index index.php;
    include fastcgi_params;
}

Possible problems: