May 11, 2011
1 min read time

Streaming in Varnish 3.0

Varnish Cache 2.1 does what you can call store-and-forward proxying. It gets the request, then it turns around, gets the whole object from the backend, then turns around and delivers it to the client. If your backend takes time to deliver the object the client might get restless.

If you just want to pass the object to the client, without actually caching it, it is even worse. Delivering a big file, like an ISO image, it can take ages before the download starts and we've seen people do all sorts of weird stuff to work around this.

This has been addressed in Varnish Cache 3.0. You can now, in vcl_fetch, set beresp.do_stream to true and Varnish will deliver the object as it arrives.

There is one caveat, however. The object will be set to busy while it is streamed. Other clients will be put on hold. Furthermore, the rate at which the object is fetched by the client dictates how fast Varnish will fetch it from the backend. These limitations might be addressed in later releases, however. These limitations do not limit the use of pass, however.

Compression and decompression should work flawlessly with streaming.

Image is copyright 2006 makelessnoise and used under a Creative Commons (CC BY 2.0) licence.