Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am exploring the potential scenario for Varnish/Nginx/Apache implementations and have a few questions about this setup.

I am looking to use all three in conjunction, not to replace Apache by Nginx.

At the moment I am not sure whether if Varnish should be put in front of Nginx, which will serve static content and pass dynamic content to Apache or put it between Nginx and Apache?

Should I enable Nginx cache or even enable it and not use Varnish at all?

I have a number scripts which process stats based on Apache logs, what can I do to let my scripts process logs in whole, not just Apache's logs which will hold only dynamic request stats?

How do I make Varnish pass access stats to Apache/bginx since access to cached files will not be logged by Apache/Nginx?

share|improve this question

2 Answers 2

It really depends on the content of the site in question and the caching scheme you're using.

I looked at this scenario previously for a very high traffic site (1M+ uniques daily) and we ended up using Nginx and Apache, without Varnish. This was due to existing caching methods and the amount of dynamic content on page so we would have only been able to have Varnish cache images and static files like css and js. During testing it became an Nginx or Varnish question, since like you we wanted to keep Apache in the configuration. The benchmarking we did showed Nginx performed faster than Varnish at high volume so thats the way we went.

One thing that we could've done but didn't would be to load dynamic page sections in a separate request and then insert the content in browser, that would have allowed us to use Varnish to cache more objects, while passing the dynamic elements to Apache and serving static content via Nginx on cache misses.

As far as the logging issue, you will most likely need to write scripts that will parse/merge your logs together and then you can run your stats scripts against the merge logs. I believe there are some good log merging tools out there, but can' think of one at the moment.

share|improve this answer

Varnish does not support HTTPS. If you want to use it then put Nginx on the outside, talking to clients.

For a low-traffic server I have decided to use only Nginx+Apache. For higher load it might be useful to compare Nginx and Varnish for their caching performance.

share|improve this answer
    
I've yet to see anybody show a benchmark where Varnish beat nginx proxy_cache (where the OS is the same, and the filesystem cache is enabled and given as much RAM to work with as Varnish). My own simple tests showed that nginx proxy_cache was slightly faster when serving a real mix of my content (replayed from production logs using a load testing tool). So the simplicity of using nginx alone for both proxying, SSL, and caching is great. Plus it's event based, so you can use keepalives without having your server fall over. –  rmalayter Sep 9 '10 at 3:49
    
may i ask you, what do you use Apache for - isn't nginx enough? –  mykhal Oct 19 '12 at 12:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.