Home

Keebler/Blog

« FoxNews: Are you f**king serious?!
Me like-a the Minka »

Varnish HTTP Accelerator + ASP.NET + IIS

For the past couple of days I’ve been trying to figure out the best way to run an HTTP accelerator on the front-end of ScribbleLive. To handle the really spiky loads (20,000 GET/s) we get around large events, we do a lot of memory caching using .NET static variables and memcached for the bigger items that need to be distributed. But we’re still limited by IIS’s ability to serve the requests, which adds on a lot of WindowsAuth, OutputCaching, etc. overhead that really isn’t needed if we’re just serving static files. And it would be great to use something running on Linux (cheaper licensing and servers) on Amazon EC2 (easier to add new servers when we need them).

I’ve known about high performance servers like lighttpd that have been around for a while, and the new up-and-comer Nginx. I tried them out and they are amazing at serving-up content (PHP, Perl, mono, Rails) but their proxy abilities are still in their infancy. For example, Nginx when acting as a proxy has a Memcached Module which can check Memcached for an object, before going back to the origin/upstream server. However, you have to load your cached items into Memcached yourself, so it’s very useful yet. (Sidenote: the Nginx project is very impressive and I’m definitely going to watch them over the next year). Squid is the obvious choice when it comes to “proxy” and “caching”, but the other projects seem to perform much better under stress; not to mention, Squid configuration for a reverse-proxy is horrible.

After a lot of messing around in /etc config files, I stumbled on Varnish. Varnish isn’t a proxy product or a server like the others. It was built from-the-ground-up to be an HTTP accelerator, and it shows. Configuration is very straight-forward if you’ve used a CDN before, and it can do a lot of URL rewriting, managing cookies, edge-server includes (ESI), backend health polling, and support for inline C. The docs leave a lot to be desired, but you can’t have everything ;)

I got Varnish running on a Fedora virtual machine in Amazon EC2 with ./configure && make && make install. Then you just have to set-up a configuration via /usr/local/etc/varnish/default.vcl and launch the daemon.

On ScribbleLive, we use an ASP.NET session (stored in Memcached, with SQL 2005 failover) to keep track of your login. But until you login, we don’t use the session for anything. So my caching strategy is this: cache everything (images, stylesheets, etc) including ASPX files without any Set-Cookie headers until you login, then don’t cache ASPX files. Logging in is done via an HTTP POST, so I just told Varnish to not cache POSTs, and strip all cookies from cached responses unless an “ASP.NET_SessionId” cookie was sent in the request.

Here’s the configuration file I’m using which seems to work great. It remains to be seen if I actually roll this out into Production sometime soon, but using it myself in our Staging environment, it gives a massive improvement in page loads and origin offload, so I wouldn’t be surprised if someday soon when you visit ScribbleLive, you’ll be going through Varnish ;)

Tags: asp.net, http accelerator, iis, varnish

Related Posts

  • Here I am: http://tinyurl.com/…
  • Stormtroopers’ 9/11 http://tin…
  • Wordpress.com HTTP header: X-h…
  • Me and iPhone “reconnect” http…
  • English Bay http://twitpic.com…

This entry was posted on Sunday, February 1st, 2009 at 12:56 pm and is filed under My Releases, Web Development. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses to “Varnish HTTP Accelerator + ASP.NET + IIS”

  1. kat says:
    February 1, 2009 at 11:35 pm

    OH EM GEE.

    You are such a geek, Jonathan!!!

  2. Vidar Markussen says:
    March 12, 2009 at 8:01 am

    HI,

    I really would like to get this up an running,
    do you have a how-to to get this up an running, what I need to install during main install etc.

    I tried with Ubuntu, but didn’t get it to work.

    Maybe you’ve got an vmware image I could download?

    Best regards
    Vidar

  3. Jonathan says:
    March 14, 2009 at 9:39 am

    Did you get it installed but just couldn’t get the configuration working? I just did a ./configure && make && make install, and after that it was just messing around in the config file.

    Sorry, I don’t have a VMWare image but I’ll help you as much as I can.

  4. Varnish, installasjon | VidarMarkussen.com says:
    March 16, 2009 at 7:42 am

    [...] hvertfall at nå virket alt etter planen. Jeg søkte etter IIS, og Varnish på google, og fant denne blogg posten, og la inn hans vcl fil, og det funket [...]

Leave a Reply

Click here to cancel reply.

  • Blog Home

  • Tags

    90210 alessandra ambrosio animals asp.net audrina patridge battlestar galactica bikini bunny bush C# canada canada election ctv ctvglobemedia development Election Entertainment/Celebrity facebook Gordon Ramsay gorilla gossip girl hayden panettiere iphone last.fm liveblog liveblogging mesh08 muchmusic Music obama palin rachel bilson scribblelive shenae grimes subway telemarketers the hills the killers the office toronto ttc toronto tv us election video yeah yeah yeahs

    WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.

  • Recent Posts

    • Trying to convince @idiotbante…
    • I wonder if the CTV “Save Loca…
    • Just finished dinner which I m…
    • I shouldn’t get as excited abo…
    • Stormtroopers’ 9/11 http://tin…
  • Categories

    • Election
    • Entertainment/Celebrity
    • Fake News
    • Featured
    • Funny
    • Keebler/Show
    • Music
    • My Releases
    • On-the-Road
    • RedDot
    • Reviews
    • Science/Technology
    • ScribbleLive
    • Security
    • Software
    • Torrent Live Stats
    • Tweets
    • Uncategorized
    • Web Development
  • Blogroll

    • Kitten-Monkey’s Cell
    • :: kattekylling ::
    • Adam Finley
    • blog-j
    • fuzzz.gaulin.ca
    • Idiot Banter
    • mad.greyarea.com
    • ob.blog
    • PollyPrissyPants
    • RedDot CMS Users Google Group
    • ScribbleLive Official Blog
  • My Sites

    • Flickr2Facebook
    • RedDot CMS
    • ScribbleLive
    • Where are my f(acebook)ing friends?
    • WhyYouShould