I'm considering installing Varnish cache in front of my forum platform to speed it up even further.

It already runs Percona MySQL DB, PHP 5.5.8 (which has Opcode caching built in, and running) and memcached. The site runs through a CDN, which also caches some resources.

EDIT: There's no clustering, it's a single server.

Is Varnish a duplication/conflict of any of my current caching layers, or will it be a good addition to my existing caches?



I would venture that you are not asking the right questions of your site.

What is slow and what is fast are subjective, and only meaningful when they are defined in a controlled context; and some things are out of your control. For e.g., all things equal, your site's response times will be lower over LAN connections, than on mobile service provider's connections.

If you want to generally improve performance, start profiling your application and its relevant layers using monitoring and load testing tools. Set benchmarks for the various layers in your stack and then work to improve them. Tuning applications and systems to perform is a mix of art and science (translation: it takes time and effort).

Varnish is best for anonymous users as Michael Hampton has pointed out. For a forum, you'll be well advised to examine other avenues of improving your site's performance. Good luck!

  • Thank you. You're right I need to be more methodical, set benchmarks and aim to make marginal gains. :) – i-CONICA Feb 18 '14 at 20:55
  • Thanks for the advice. I've since discovered and implemented mod_pagespeed and omg it's the mutts nuts. So I've got tweaking and tuning to do with that for the next few weeks before I'll re-evaluate if varnish is worth the extra layer of complication. Thanks. – i-CONICA Feb 20 '14 at 9:45

Wether it's a good addition depends on your exact setup, for which there is not enough information here. For example, what resources are already cached by your CDN, are the expiries correctly set on your resources, what's the primary kind of content your forum, among other factors.

Also, don't expect a huge improvement (also, what's an improvement depends on the specific needs of your site) by just plopping down a varnish in front of your site, it also needs some tweaking, especially since your forum will most likely set Cookies, which will cause varnish to disregard the cache in the default configuration.

It shouldn't hurt though in most cases, and your best bet is to simply test it out and to play around with the tunables.

  • Hi, Thanks. I just setup a quick test but saw a zero hit rate, so I assume something is getting in the way. I'm going to have to RTFM and setup a test case, bypassing the CDN and I'll have to investigate the cookies thing, as that seems like a deal-breaker if not configured properly. – i-CONICA Feb 18 '14 at 12:13

Varnish only has a chance to help if most of the visitors to your site are anonymous, i.e. they never log in and participate. Requests by logged-in users cannot be safely cached at this level, and any reasonable web site will set Cache-Control: private (or perhaps no-cache if it's less well designed) to indicate this.

However, your forum software itself may work against you. For instance, SMF sets Cache-Control: private and cookies even for anonymous users; the former breaks caching and requires extreme gymnastics to work around. This is utterly broken behavior, but I don't expect it to change soon.

  • Hi, Thanks. Yes the forum is SMF, but a heavily customised version that's under source control, so it's "ours" now. The majority of visitors by percentage are anonymous, but I still want the site to be as fast as is possible and am running out of optimisation routes. It is already very fast, but as a developer I'm always looking for ways of further optimising... I already have tight cache control headers sent, but hadn't considered that for logged in users, they may or should change so I'll revisit that and investigate. Thanks. – i-CONICA Feb 18 '14 at 14:39
  • If it's already fast, I would suggest waiting until you actually have a performance problem to solve. Or at least hints of a future performance problem. – Michael Hampton Feb 18 '14 at 18:38
  • On the contrary, I understand your rationale for if it ain't broke don't fix it, but faster pages prove more favourable in search engine rankings, and also in user satisfaction, and I have the ability to measure that via NewRelic Apdex score. Thanks. – i-CONICA Feb 18 '14 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.