Score:0

Varnish seems to not be using my `file` storage configuration

sd flag

I've configured Varnish to use a file storage. Varnish seems to be working, but the cache seems to be a fraction of the size I've specified and the file I've specified for the storage does not seem to have been created.

I've been running service varnish reload to restart the service after making config changes. Is that sufficient?

Running varnishstatus shows an ever-increasing MAIN.n_lru_nuked value, which I assume means it thinks it's run out of cache space however SMA.s0.c_bytes (which I believe is the size of the storage back-end?) is only at 3.46G.

Any ideas how I can debug this? Is my config not getting picked up?

Config portion of /etc/default/varnish

VARNISH_LISTEN_PORT=80
DAEMON_OPTS="-a :80 \
             -T localhost:6082 \
             -b s3.amazonaws.com:80 \
             -u varnish -g varnish \
             -S /etc/varnish/secret \
             -s disk=file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,30G"

/etc/varnish/default.vcl

vcl 4.0;

backend default {
    .host = "cdn.webampskins.org.s3.amazonaws.com";
    .port = "80";
}

sub vcl_recv {
    set req.http.Host = "cdn.webampskins.org.s3.amazonaws.com";
}

sub vcl_backend_response {
    set beresp.ttl = 3y;
    set beresp.storage_hint = "disk";
    # I've confirmed that in my response I see this header
    set beresp.http.x-storate = "disk";

}

sub vcl_deliver {
    # Empty
}

Update:

It seems that my file storage config is not getting picked up:

~# varnishadm storage.list
Storage devices:
    storage.s0 = malloc
    storage.Transient = malloc

Not sure why, or how to debug.

Score:0
in flag

If your operating system uses Systemd, don't use /etc/default/varnish to configure the runtime parameters.

Please use the following command to edit these settings:

sudo systemctl edit varnish

Once you're done editing, restart Varnish using the following command:

sudo systemctl restart varnish

See https://www.varnish-software.com/developers/quick-start/#through-the-systemctl-edit-command for more information about managing Varnish via the systemctl binary.

Word of warning: we strongly discourage the use of the file stevedore. Although it allows you to extend the size of your cache compared to memory, it does not offer any persistence. That might be something you can live with.

However, our experience with the file stevedore is that it is very prone to disk fragmentation over time. The only way to get rid of the fragmentation is by fully restarting the varnishd process via sudo systemctl restart varnish on a regular basis.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.