I see a lot of talk about using nginx with Varnish and I do not understand why. Isn't nginx enough?

Nginx has SSI, has reverse proxy cache, is lightweight, has SSL, can work with cgi, fpm, etc.

Varnish has the same things, but no ssl, and no cgi support.

link|improve this question
"Better" is really subjective. It depends on your use cases... – voretaq7 Dec 21 '11 at 17:30
1  
Sometimes a simple question do the job better than complex ones. I am very concerned about actions like that from the people who closed this question assuming it was no good to the "original Q&A format". I am searching about this subject and I was very interested to see the outcome of this debate. – Roger Apr 29 at 7:29
feedback

closed as not constructive by WesleyDavid, Scott Pack, ErikA, Tom O'Connor, voretaq7 Dec 21 '11 at 17:27

This question is not a good fit to our Q&A format. We expect answers to generally involve facts, references, or specific expertise; this question will likely solicit opinion, debate, arguments, polling, or extended discussion. See the FAQ for guidance on how to improve it.

2 Answers

up vote 4 down vote accepted

I've found varnish ~5% faster for small static files than nginx -- varnish in front of apache, or varnish in front of a web app server would be big gains; but in front of nginx, the benefit is pretty negligible (especially with overheads and extra complexity taken into account)

link|improve this answer
feedback

First, to clarify: Nginx is a web server, with all of the features and complexity that entails. It also has caching capability, but that is not its primary design goal.

Varnish is not a web server. It cannot fill that role (not without a truly evil VCL, anyway). Its role is to cache content provided by another server. If needed, it can alter the request or the response.

If nginx can handle your traffic, then it is enough. If nginx is not able to keep up, then one way to increase its capacity is by placing a cache in front of it and having the cache handle as many of the requests as possible.

As an example, we use Apache to run a number of relatively complex PHP websites from a cluster of web servers. When we started to experience capacity problems, we placed a pair of Varnish servers in front of the Apache cluster. The Varnish hosts now handle 85% of all incoming requests without bothering the Apache backend.

link|improve this answer
feedback

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