Overall, I serve very small files. Think about images and small videos. Caching these with Varnish is like a breeze and doesn't give me any issues.
The problem I am having, is when I am downloading a 6 GB file. When doing so, I see the memory being used by Varnish to rise till the moment it crashes. Then it starts over till it crashes again.
- I want to avoid Varnish from crashing
- The download is therefor paused everytime and very slow. It should just download the 6 GB file. Period.
I already tried with file and RAM cache storage, but no different.
I was capable of avoiding a crash, by setting the transient memory;
DAEMON_OPTS="-s Transient=malloc,512m"
However, this only leads to the moment Varnish is using 512MB, after which it will crash again.
I've tried in vcl_backend_response
, as a test case, both
if (std.integer(beresp.http.Content-Length, 0) > 5242880) {
set beresp.do_stream = true;
return (deliver);
}
and
if (std.integer(beresp.http.Content-Length, 0) > 5242880) {
set beresp.uncacheable = true;
return (deliver);
}
Neither of those however make sure that the file is nicely downloaded with my browser.
VarnishLog throws this error, but I guess it just means that memory got full and therefor crashed.
FetchError Could not get storage
What am I missing here, to avoid the download from being halted? Is varnish somehow caching the file anyway?
Note: HAProxy is running in front of Varnish. Apache is the actual web server.