Anton Lindstrom (about, @twitter, @github)

Varnish and JenkinsCI

Published:

I have been playing around some with Continous Integration (CI) recently. The software I have tried is Jenkins. Unfortunately, untuned on a 512MB RAM virtual server it has got some slow moments.

Requests by Jenkins CI

I ran Jenkins with nginx but decided to try Varnish instead to get some caching in place. I also decided to find out what the requests made by Jenkins were. Turns out it does some requests to /static/, well that is good. Let us just cache /static/ and try to hit refresh.

Add the following to /etc/varnish/default.vcl, on top of your other tweaks:

sub vcl_recv {
    # Cache everything static
    if (req.url ~ "^/static/") {
      remove req.http.cookie;
      return (lookup);
    }
}

sub vcl_fetch {
    if ( req.url ~ "^/static/" ) {
      remove beresp.http.Set-Cookie;
    }
}

The result is that most of the static files gets cached and the dynamic content gets collected from the CI. Hits are shown as "|" and misses as "#".

Hits versus misses in Varnish

This has unfortunately not been tested on a large environment with many users and better hardware but I assume it would be a great difference in speed on better hardware as well.