44

We need a web content accelerator for static images to sit in front of our Apache web front end servers

Our previous hosting partner used Tux with great success and I like the fact it's part of Red Hat Linux which we're using, but its last update was in 2006 and there seems little chance of future development. Our ISP recommends we use Squid in reverse caching proxy role.

Any thoughts between Tux and Squid? Compatibility, reliability and future support are as important to us as performance.

Also, I read in other threads here about Varnish; anyone have any real-world experience of Varnish compared with Squid, and/or Tux, gained in high-traffic environments?

Cheers

Ian

UPDATE: We're testing Squid now. Using ab to pull the same image 10,000 times with a concurrency of 100, both Apache on its own and Squid/Apache burned through the requests very quickly. But Squid made only a single request to Apache for the image then served them all from RAM, whereas Apache alone had to fork a large number of workers in order to serve the images. It looks like Squid will work well in freeing up the Apache workers to handle dynamic pages.

Polsonby
  • 22,825
  • 19
  • 59
  • 74
  • 24
    reading just the title of this question, it sounds so hilarious. Like, "What should I wear to dinner tonight honey? Tux, Varnish or Squid?" – nickf Nov 15 '08 at 12:51
  • 4
    How about "What should we eat for dinner tonight honey? Tux, Varnish or Squid?" – Jayen Apr 04 '13 at 08:24

11 Answers11

38

In my experience varnish is much faster than squid, but equally importantly it's much less of a black box than squid is. Varnish gives you access to very detailed logs that are useful when debugging problems. It's configuration language is also much simpler and much more powerful that squid's.

scottynomad
  • 1,351
  • 11
  • 9
17

@Daniel, @MKUltra, to elaborate on Varnish's supposed problems with cookies, there aren't really any. It is completely normal not to cache a request if it returns a cookie with it. Cookies are mostly meant to be used to distinguish different user preferences, so I don't think one would want to cache these (especially if you they include some secret information like a session id or a password!).

If you server sends cookies with your .js and images, that's a problem on your backend side, not on Varnish's side. As referenced by @Daniel (link provided), you can force the caching of these files anyway, thanks to the really cool language/DSL integrated in Varnish...

InvertedAcceleration
  • 10,695
  • 9
  • 46
  • 71
Luc Stepniewski
  • 318
  • 2
  • 8
12

If you're looking to push static images and a lot of them, you may want to look at some basics first.

Your application should ensure that all correct headers are being passed, Cache-Control and Expires for example. That should result in the clients browsers caching those images locally and cutting down on your request count.

Use a CDN (if it's in your budget), this brings the images closer to your clients (generally) and will result in a better user experience for them. For the CDN to be a productive investment you'll again need to make sure all your necessary caching headers are properly set, as per the point I made in the previous paragraph.

After all that if you are still going to use a reverse proxy, I recommend using nginx in proxy mode, over Varnish and squid. Yes Varnish is fast, and as fast as nginx, but what you're wanting to do is really quite simple, Varnish comes into it's own when you want to do complex caching, and ESI. So Keep It Simple, Stupid. nginx will do your job very nicely indeed.

I have no experience with Tux, so I can't comment on it sorry.

flungabunga
  • 390
  • 2
  • 9
6

It's interesting that no one mentioned the Apache Traffic Server (formerly, Yahoo! Traffic Server) http://trafficserver.apache.org/

Please have a look at it, it works beautifully.

Abbas
  • 61
  • 1
  • 1
6

For what it's worth, I recently set up nginx as a reverse-proxy in front of Apache on a 6-year-old low-power webserver (running Fedora Core 2) which was under a mild DDoS attack (10K req/sec). Pages loading was snappy (<100ms) and system load stayed low at around 20% CPU utilization, and very little memory consumption. The attack lasted 1 week, and visitors saw no ill effects.

Not bad for over half a million hits per minute sustained. Just be sure to log to /dev/null.

tylerl
  • 30,197
  • 13
  • 80
  • 113
4

We use Varnish on http://www.mangahigh.com and have been able to scale from around 100 concurrent pre-varnish to over 560 concurrent post-varnish (server load remained at 0 at this point, so there's plenty of space to grow!). Documentation for varnish could be better, but it is quite flexible once you get used to it.

Varnish is meant to be a lot faster than Squid (having never used Squid, I can't say for certain) - and http://users.linpro.no/ingvar/varnish/stats-2009-05-19 shows Twitter, Wikia, Hulu, perezhilton.com and quite a number of other big names also using it.

Richy B.
  • 1,619
  • 12
  • 20
3

both Squid and nginx are specifically designed for this. nginx is particularly easy to configure for a server farm, and can also be a frontend to FastCGI.

Javier
  • 60,510
  • 8
  • 78
  • 126
  • 4
    nginx's caching facilities are limited, in comparison with squid and varnish. – Frank Farmer Jan 13 '10 at 21:03
  • Squid is a forward proxy, it was _not_ designed for reverse proxying. Also, nginx was specifically designed to be a origin web server, not a proxy - which was added later. – perbu Mar 17 '14 at 11:37
3

I've only used squid and can't compare. We use squid to cache an entire site on a server in the USA (all data gets pulled from a machine in Germany). It was pretty easy to set up and works nicely. I've found the documentation to be kind of lacking unless you already know what to look for.

Lasar
  • 5,175
  • 4
  • 24
  • 22
2

Since you already have apache serving the static and dynamic content I would recommend you to go with Varnish.

In this way you can use your apache to deliver the static content and use varnish to cache it for you. Varnish is very flexible, giving you both caching and loadbalancing features for growing your website in the best ways.

Rafael Sanches
  • 1,823
  • 21
  • 28
1

Nobody mentions that Squid follows the HTTP specification to the letter (or at least they try to) whereas Varnish does not. In my opinion, this means Varnish is better suited for caching content for individual sites (by extensively tuning Varnish) and Squid is better for caching content for many sites (each of which will have to make their content "cachable" according to spec).

laughingbovine
  • 450
  • 5
  • 11
  • 5
    Care to elaborate on how "Varnish does not [follow the specs]"? – Andreas Oct 29 '13 at 13:13
  • @Andreas Basically, you can ignore caching headers. You can cache when the server says you shouldn't and vice versa. It's all fully programmable. IIRC Squid is not that flexible, ie. you need to try to get it to go off spec. – laughingbovine Jul 07 '16 at 17:52
  • 1
    So to rephrase that: "Varnish follows the specs unless you tell it not to". Correct? – Andreas Jul 08 '16 at 07:11
  • IIRC it's not 100% on point with the specs to begin with. I have nothing to back this up... it's been a while since I last used it. – laughingbovine Jul 11 '16 at 13:39
1

We are about to roll out a varnish 2.01 server in front of an IIS 6 installation. The only caveats we've had was with our SSL (as varnish can't handle SSL). So we've also installed Nginx to handle those requests.

In all our testing we've shown a 66% percent increase in the amount of traffic the site can handle.

My only gripe is that varnish doesn't handle cookies well, and the documentation is still a bit scattered.

MkUltra
  • 517
  • 4
  • 5
  • 4
    Can you elaborate on "varnish doesn't handle cookies well"? – Frank Farmer Jan 13 '10 at 21:09
  • 1
    http://www.code-emitter.com/blog/2008/10/added-varnish-just-works/ varnish won't cache a page if it has cookies. – Daniel Jan 19 '10 at 16:38
  • 9
    Caches generally don't cache pages with cookies. The assumption is that if you set a cookie then you expect to do something *different* with that request based on the contents of the cookie. Otherwise, there's no point to setting cookies. If you want to serve cached, then remove the cookie in your varnish configuration. – tylerl Feb 27 '10 at 07:15