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
You should look at Varnish for replacing your caching needs. http://varnish.projects.linpro.no/
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
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.