best varnishd config for static files

Kain Sascha s.kain at
Fri Apr 24 15:28:22 CEST 2009

Thanks a lot for the great Hints.

First of all, varnishtop -i TxURL hangs on my system, it shows 3-5 Entries, 
then freez and uses nearly 100%cpu on one of 8. Have to kill the pid.
varnishtop with no args works.

2.6.18-6-amd64 #1 SMP Mon Jun 16 22:30:01 UTC 2008 x86_64 GNU/Linux
varnishd (varnish-2.0.4)
Copyright (c) 2006-2009 Linpro AS / Verdens Gang AS

Here is our Answer-Header, so we provide the max-age.

Cache-Control max-age=2592000
Vary Accept-Encoding
Expires Wed, 29 Apr 2009 21:14:47 GMT
Content-Type image/jpeg
Etag "857407780"
Last-Modified Mon, 30 Mar 2009 20:35:52 GMT
Server lighttpd/1.4.20
Content-Length 1392
Date Fri, 24 Apr 2009 13:19:59 GMT
X-Varnish 623951818 451344757
Age 2131515
Via 1.1 varnish
Connection keep-alive

Thanks again for your hints


Am Freitag, 24. April 2009 14:21:52 schrieben Sie:
> On Fri, Apr 24, 2009 at 01:28:36PM +0200, Kain Sascha wrote:
> > /usr/local/sbin/varnishd -a :80 -b 89.250.xx.xx:80 -s malloc,15360M
> You may want to supply a -w. The default is really whimpy which could
> create problems during spikes of traffic. Try something like -w 400,800.
> Varnishstat n_wrk_limited and n_wrk_drop are values you don't want to
> increase after the initial startup. n_wrk_limited can increase a little
> every once in a while, but it should only happen on significant load
> spikes.
> > I didnt use a config file, because i think i dont need it for static
> > files only. is this correct?
> The default TTL is 120s if I am not much mistaken. You probably want it to
> be something closer to 500h or some other really long period of time. This
> has to be done in VCL if your backends don't deliver
> s-maxage/max-age/Expires: headers.
> For instance:
> vcl_fetch:
> set obj.ttl = 500h;
> > Is this a good solution?
> Yes, though you should make sure varnish caches as much as you want it to
> and watch the hitrate in varnishstat and check what is actually going to
> the backends most frequently with varnishtop -i TxURL. With varnishtop -i
> TxURL, you really shouldn't see many values above 1-3 for static content.
> > Sometimes im getting a 503 error when the static server has high load.
> > Also sometimes i am waiting a long time for some files that has to be on
> > RAM allready.
> The X-Varnish HTTP header can tell you if it is a hit or not. It gives you
> one or two numbers: One is a transaction id, and the last identifies the
> original transaction that fetched the object. One number: MISS; two
> numbers: HIT.

More information about the varnish-misc mailing list