Sharding with Varnish

Enno van Amerongen enno at
Wed Aug 1 14:46:33 CEST 2012

Hey guys,

I was wondering if any of you have implemented sharding using varnish.

We're considering the following setup:

Let's say we have 3 shards, where each shard consists of 2 servers.
So this would mean 3 directors with 2 backends each.
In VCL I want to determine which shard to use, using a simple ID mod N.

1. Client requests a file
2. Cache Miss
3. Calculate which shard must handle the request
4. Set backend to correct shard
5. Serve the file

I'm pretty confident this setup works, the only complicated issue is
determining the correct shard.
Has anyone done anything like that yet? With inline C it shouldn't be too
hard, or maybe someone has already written a VMOD?
Any examples would be greatly appreciated.

Thanks in advance

Enno van Amerongen

More information about the varnish-misc mailing list