sharding with varnish: generating director identifier from an integer

Enno van Amerongen enno at
Thu Nov 15 17:21:35 CET 2012

From: Per Buer [mailto:perbu at]


On Thu, Nov 15, 2012 at 3:52 PM, Enno van Amerongen <enno at> wrote:
Hi List,

My coworkers and I are working on a sharding VMOD and we got to the point    
it's actually working (woohoo!).

Now, our implementation is pretty straightforward:    

 - get id from url
 - do a "id mod n" to pick correct shard ( = director)    
 - set req.backend = shardN

Any particular reason you didn't use the client director? This is more or less exactly what it does.    

You would set client.identity to the ID you pick and Varnish will use a hash algorithm to consistently pick a backend from the backends in the director.
yes, we didn't use it because we also need to be able to determine which backend should receive which images. We aren't only sharding the requests, but also the storage.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list