Opinions

Why we never use Varnish with Nginx!

Disclaimer: I never used Varnish. So please do not treat this as Varnish v/s Nginx post. It will be wrong on my part to compare Nginx to something that I have never used.

Since we published WordPress-Nginx tutorials, we have been asked many times that why we haven’t posted anything about Varnish!

Here is my attempt to answer…

Short Answer: Using Varnish + Nginx is not worth my effort!

Long Answer…

Time-saving:

I never used Varnish. So I will have to spend some time learning Varnish. Apart from this, Varnish will increase one more package on Nginx + PHP + MySQL + APC/Memcache stack we commonly use. That means if something goes wrong, we will need to debug Varnish also apart from other packages!

So not only in learning but I will have to spend time in maintenance on ongoing basis.

Static-content:

Nginx can handle static files itself pretty fast. On larges sites, people generally use CDN to host static files (images, videos, js, css, etc).

Varnish is surely useful when used with Apache. If Apache has mod_php enabled, Apache performance significantly drops for static-file requests.

Load-Balancer, Reverse-Proxy:

Again, Nginx does this for me! In a client-setup, we have a micro Amazon EC2 instance running nginx as load-balancer in front of range of PHP, mysql.

Beauty of Nginx is that it can directly talk to other Nginx and PHP directly. It can read from memcache directly! So it works really well for us in multi-machine environment.

In second part of our WordPress-Nginx Tutorial Series, I will write in depth about load-balancing, reverse-proxy etc. (You can subscribe here for updates.)

Benchmarks…

I am not fond of benchmarks. Still, if Varnish + Nginx gives 5-10% performance improvement but cost in days to learn and hours every month in ongoing maintenance, I will prefer to leave that 5-10% of performance gain.

That being said I find this Varnish/Nginx benchmark quite good!

Finally…

My point is… rather than learning multiple tools partially, I will dig deeper into Nginx. I will master it to the point that it can cater to all our needs! 🙂

That’s it from my side! You can prove me wrong using comment-form below! 😉

Discuss your project
with our experts

No obligation. Limited slots.

Contact Form Business Enquiry

"*" indicates required fields

Please attach any RFP, project specification, or document that you would like to share.
Drop files here or
Max. file size: 5 GB.
    This field is for validation purposes and should be left unchanged.