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.

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.

Your email will never ever be published.

Previous:
Too much Python makes Peter a shit Javascript developer March 13, 2009 JavaScript
Next:
British or American English or just English March 18, 2009 Web development
Related by category:
set -ex - The most useful bash trick of the year August 31, 2014 Linux
brotli_static in Nginx November 8, 2024 Linux
Be very careful with your add_header in Nginx! You might make your site insecure February 11, 2018 Linux
Linux tip: du --max-depth=1 September 27, 2007 Linux