Nginx vs. Squid

17 March 2009   3 comments   Linux

Powered by Fusion×

We all know that Nginx is fast and very lightweight. We also know that Squid is very fast too. But which one is fastest?

In an insanely unscientific way I added some rewrite rules to my current Nginx -> Squid -> Zope stack so that for certain static content, Nginx could go straight to the filesystem (where the Zope product holds the static stuff) to bypass the proxy pass. Then I did a quick and simple benchmark with ab comparing how to get a 700 bytes GIF image:

squid: 2275.62 [#/sec] (mean)
nginx: 7059.45 [#/sec] (mean)

Let's not focus too much on the numbers because at these high ranges so many other factors are important. I ran the tests several times and indeed it goes up and down by a factor of 500-1000 #/sec. However the interesting thing here is that Nginx is faster. Squid is already very fast since it serves straight from RAM and it's built for speed but the problem I have with Squid is Squid itself. It's yet another thing that can go wrong and it costs CPU and memory.

This is just the first of many thoughts in this direction. At the moment I can't throw out Squid because it's used to cache certain HTML pages for short periods in my Zope sites. But what I've learned today is that Squid can easily be discarded if you can get it right with Nginx.


Ash Berlin
You should look at Varnish for replacing your caching needs.
Ryan Malayter
Nginx now includes proxy_cache. Haven't done any full benchmarks (micro-benchmarks like ab don't tell you much about real-world performance). But we replaced Squid anyway, just to simplify the stack. It "feels" faster, probably because of the reduced latency.
Peter Bengtsson
Interesting. So with nginx we can no do basic load balancing, proxy caching, static serving and dynamic proxying. It's catching up with apache in features but with speed.

Your email will never ever be published

Related posts

Too much Python makes Peter a shit Javascript developer 13 March 2009
British or American English or just English 18 March 2009
Related by keywords:
To readline() or readlines() 12 March 2004
bool is instance of int in Python 05 December 2008
Reciprocal lesson about gender perspectives 02 September 2011
IssueTrackerProduct now officially abandoned 30 March 2012
How and why to use django-mongokit (aka. Django to MongoDB) 08 March 2010
On the command line no one can hear you screen. Or can they? 03 May 2012
Nasty surprise of Django cache 09 December 2008
Random ID generator for Zope 02 September 2005
Google Calendar, iCalendar Validator but not bloody Apple iCal 09 April 2009
tempfile in Python standard library 07 February 2006
In Django, how much faster is it to aggregate? 27 October 2010
Google and Python code 22 February 2006