Varnish, Nginx, Apache – Is This a Good Architecture?

apache-2.2Architecturenginxvarnish

I'm thinking about the architecture for a new Webserver. Would having Varnish as a cache in front of Nginx as a reverse-proxy and serving static files in front of apache for all heavy lifting be a good idea?

I'm going to run php and ruby on rails applications.

Will there be too much overhead passing php requests to apache through two other processes?

Thanks a lot!

Best Answer

Yeah, it's valid. My personal approach would be to use Varnish up front and use VCL to split the traffic between static NGINX requests and your heavy lifting (whether that be Apache or Passenger or... it doesn't matter). This is especially true if it is on the same machine as you don't need the extra overhead. It doesn't necessarily buy you anything.