Nginx vs. Squid

17 March 2009   3 comments   Linux

Mind That Age!

This blog post is 8 years old! Most likely, its content is outdated. Especially if it's technical.

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.

Follow @peterbe on Twitter

Comments

Ash Berlin
You should look at Varnish for replacing your caching needs. http://varnish.projects.linpro.no/
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.
http://wiki.nginx.org/NginxHttpProxyModule#proxy_cache
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.
Thank you for posting a comment

Your email will never ever be published


Related posts

Previous:
Too much Python makes Peter a shit Javascript developer 13 March 2009
Next:
British or American English or just English 18 March 2009
Related by Text:
Damn lies and benchmark comparing Apache and Nginx 03 June 2008
DoneCal homepage now able to do 10,000 requests/second 13 February 2011
Gzip and Slimmer optimization anecdote 30 January 2007
A great thing about Squid: Calamaris 04 July 2008
Is Nginx obsolete now that we have Amazon CloudFront? 28 July 2012