Hey,
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!
-
The amount of overhead shouldn't be significant. I'm assuming part of the reason you want to have these two tiers is for scalability; in which case you would most likely see, relative to apache, that varnish and nginx aren't working very hard.
If you all three tiers on one machine, there should be less of a performance impact before you reach the capacity of the server itself.
As an alternative, why not varnish + nginx with passenger? I've used this setup in the past and nginx using passenger is relatively light, and ran pretty well. Might be worth thinking about if you're not married to apache running your rails stack.
Zoran Zaric : yeah i might switch from apache to nginx for rails, but giving customers the ability to use .htaccess files is a + for apache, for php at least.From Tony -
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.
Zoran Zaric : yeah this is a pretty good idea, since varnish should be pretty fast for thisFrom McJeff -
I am the sys admin for a startup ecommerce platform. We use varnish+nginx in front of our PHP/apache stack and it has worked wonders.
We have a high memory use application and the app was using around 15-20gigs of RAM per webnode and once we put varnish in front it is now around 8gig of RAM per node. They have never spiked.
So I highly recommend it.
Mike : You know varnish doesn't talk ssl right?From Mike -
Varnish doesn't (yet) support gzip compression, so it might be an idea to swap it around with nginx in front to compress what varnish sends back. Since varnish and nginx don't fight for the same resources (nginx uses CPU for gzip compression, while varnish uses memory) they should run smoothly on the same machine.
So (internet) --> (nginx, gzip) --> (varnish, caching) --> (application)
If you want apache in there too (for the ubiquitous mod_foobar support), I'd put it behind varnish.
ewalk : If whatever is serving content to varnish encodes it in gzip, then varnish will pass it on gzipped without complaining: http://varnish-cache.org/wiki/FAQ/Compression The only thing varnish doesn't do is take content which is uncompressed from the uncached application and reserve it compressed. Is this your understanding as well?user6738237482 : The only time you run nginx in front of varnish is when you are using ESI. Since you cannot do ESI assembly from compressed pages, and Varnish will not compress an assembled page, Nginx is placed in front of Varnish to provide that compression. If the origin serves the content compressed, Varnish will pass that data to the client in compressed form.mogsie : Yeah, ESI is one of the reasons why I'd recommend this configuration, but I guess that if your backend compresses and you don't use ESI, you could dispense with nginx, since I believe varnish can handle quite a lot of traffic without breaking a sweat.From mogsie
0 comments:
Post a Comment