I am trying to create a rather complex setup using a combination of lighttpd, some custom Ruby proxies, rails/ramaze (running on Thin), and PHP. Currently it is setup like this:
A browser issues the request which hits the lighttpd frontend. lighttpd is setup with mod_proxy to route this request into one of many Ruby proxies that have been custom designed by me.
proxy.balance = "fair" proxy.server = ( "" => ( ( "host" => "127.0.0.1", "port" => 9090 ), ( "host" => "127.0.0.1", "port" => 9091 ) ) )
The request is forwarded into one of the Ruby processes, which then opens up a new connection to one of many thin instances running an application. It uses some load balancing magic along with a cluster of networked servers.
The thin instance generates the page, sends it back to the proxy, and the proxy sends the page back to lighttpd which serves it to the browser.
My question is, given the above architecture, what would be the best way to add PHP support into this cluster? PHP needs to be running behind the Ruby proxy, so that I can differentiate between PHP and Ruby requests and route them to the proper location, but I cannot find a thin-like server for PHP. Should I manually launch php-cgi on the cluster, then add FCGI support to my Ruby proxy? Or should I launch a new lighttpd instance on every server specifically to generate PHP pages (I feel this would be closest to my thin model with Ruby, but am worried about overhead and the lack of control this gives me)?
Keep in mind that every application needs to be jailed into it's own *nix account, with some applications taking up 10+ accounts across several servers. I also need a way to properly limit the amount of server resources that the PHP application uses (perhaps by only launching one or two php-cgi instances per *nix acount?).