This page describes the settings that are supported when using Varnish High Availability 6.
Global settings must be configured in vcl_init. Each setting is shown with its default value.
vha6_opts.set("token", "[secret]");HMAC signing key used in all transactions. This key is used for signing and is never exposed in an actual transaction. It must be identical across all nodes.
After setting the key, call vha6_token_init; must be used. Not setting a token or calling the init function will prevent Varnish from successfully loading the VCL.
vha6_opts.set("broadcaster_scheme", "http");http or httpshttps, make sure Broadcaster is configured for HTTPS.vha6_opts.set("broadcaster_host", "localhost");vha6_opts.set("broadcaster_port", "8088");vha6_opts.set("broadcaster_group", "");nodes.confvha6_opts.set("broadcaster_ssl_verify_peer", "true");vha6_opts.set("broadcaster_ssl_verify_host", "false");vha6_opts.set("broadcast_limit", "200");Note: available since 6.0.13r14.
VHA_BROADCAST requests.broadcast_rate_limit is used as a fallback.See limits for more information.
vha6_opts.set("broadcast_rate_limit", "200");Note: available since 6.0.13r14.
VHA_BROADCAST requests per second.max_requests_sec is used as a fallback.See limits for more information.
vha6_opts.set("request_rate_limit", "500");Note: available since 6.0.13r14.
VHA_BROADCAST and VHA_FETCH requests.2.5 * broadcast_rate_limit is used as a fallback.See limits for more information.
vha6_opts.set("origin_scheme", "");nodes.confhttps is used, otherwise http.vha6_opts.set("origin", "");nodes.conf, otherwise server.ipvha6_opts.set("origin_port", "");nodes.confvha6_opts.set("origin_ssl", "");nodes.conforigin_scheme overrides this value.vha6_opts.set("origin_ssl_sni", "true");vha6_opts.set("origin_ssl_verify_peer", "true");vha6_opts.set("origin_ssl_verify_host", "false");vha6_opts.set("allow_locahost", "false");vha6_opts.set("allow_stale", "false");vha6_opts.set("fetch_timeout", "");vha6_opts.set("force_fast304", "false");vha6_opts.set("force_update", "false");vha6_opts.set("keep_alive", "120s");timeout_idle to this valuebackend_idle_timeout to maximize the re-use of connections from other
nodesvha6_opts.set("min_ttl", "3s");ttl value equal to or less than this value, the object won’t be replicated.vha6_opts.set("max_requests_sec", "200");Note: deprecated since 6.0.13r14.
The max_requests_sec setting used to serve three different purposes and was
replaced by new settings:
broadcast_limitbroadcast_rate_limitrequest_rate_limitIt is still present for existing VHA6 setups and serves as a fallback when the
new settings are omitted from the configuration with a notable exception: the
request_rate_limit setting falls back to 2.5 * max_requests_sec when all
three new settings are unset.
See limits for more information on the new settings.
vha6_opts.set("max_bytes", "25000000");Content-Length larger than this value, it’s not replicated.vha6_opts.set("peer_stream", "true");vha6_opts.set("token_ttl", "2m");vha6_opts.set("vcs", "true");vha6_opts.set("vcs_key", "vcs-key");vha6_opts.set("origin_backend_linger", "10s");Request settings must be configured in vcl_backend_fetch or vcl_backend_response and are shown with the default values.
vha6_request.set("skip", "false");true, this request won’t be replicated.vha6_request.set("force_update", "false");In a cluster with VHA6, a cache insertion results in a broadcast to inform the other members of the cluster. The other members of the cluster may in return request the new contents to populate their own caches.
From a Varnish server’s perspective, it means that one outgoing broadcast can result in an amplification of up to N-1 incoming fetch requests from Varnish peers in a cluster of N servers as a consequence. In addition to the fetch requests, a Varnish server will receive broadcasts from its N-1 peers.
This traffic between Varnish nodes and the amplification factor could disturb traffic dedicated to actual clients despite an eventual higher hit ratio due to the continuous cache warm-up enabled by VHA6.
The content replication limits can be adjusted to keep VHA6 traffic under control:
A Varnish server will broadcast in theory up to broadcast_rate_limit cache
insertions per second. If all members of a cluster broadcast at full capacity
one node should expect an amplification of:
(N-1) * broadcast_rate_limit incoming broadcast requests(N-1) * broadcast_rate_limit incoming fetch requestsAt full broadcast capacity, request_rate_limit should in theory be adjusted
to 2 * (N-1) * broadcast_rate_limit to allow a node to process all incoming
VHA6 requests without dropping anything.
In a cluster of 3 nodes, with a broadcast_rate_limit of 200, the value for
request_rate_limit should in theory be 800 to process all VHA6 traffic. The
fallback value however is computed as 2.5 * broadcast_rate_limit when the
request_rate_limit setting is not set. This conservative fallback assumes
a cluster of 3 nodes that will not process all the VHA6 traffic when all
nodes broadcast at full capacity, but can still absorb cache insertion spikes
happening sporadically on individual nodes.
The error_rate_limited counter is incremented when either rate limit is
reached.
The other mechanism to reduce VHA6 replication pressure is broadcast_limit
falling back to broadcast_rate_limit when the former is not set. This match
between the two settings means that a broadcast request have a default budget
of 1s on average at full replication capacity. One reason for broadcast
requests to take time is the corresponding fetch requests coming back while a
cache insertion is still being fetched by the Varnish origin that triggered
the broadcast. A slow backend increases the chances of saturating the
broadcast_limit before reaching the broadcast_rate_limit.
The error_max_broadcasts counter is incremented when this limit is reached.
See varnishstat on VHA6 monitoring for other noteworthy counters.
Hooks allow for custom VCL code to execute during specific VHA6 states. To set up hooks, run the following commands:
mkdir -p /etc/varnish/vha6/hooks
cp /usr/share/varnish-plus/vcl/vha6/hooks/states.vcl /etc/varnish/vha6/hooks
This implements a default VHA6 hooks file at /etc/varnish/vha6/hooks/states.vcl.
Edit this file to add custom VCL to the defined VHA6 hooks.
vha.skip_ban()vha.skip_ban() is a function in vmod_vha that skips request-time ban
evaluation for the current lookup. It can only be called from vcl_recv and
vcl_hash.
When set, a banned object that has not yet been removed by the ban lurker is returned as a normal hit. The flag is per request, is not exposed as a VCL variable, and resets on every request.
The bundled VHA6 VCL calls vha.skip_ban() in two places:
VHA_BROADCAST, for the “do I already have
this object?” lookup.VHA_FETCH, so the just-inserted object can
be served to the peer even if a ban test would fire during lookup.VHA lookups are internal bookkeeping, not client traffic. VHA deliberately leaves ban processing to real client requests and the ban lurker rather than having replication traffic evaluate and act on bans.
vha.skip_ban() yourself; the bundled VHA6 VCL already does. It only becomes relevant if you write your own replication VCL or VHA hooks and need internal lookups to bypass bans.
Ban membership is positional: an object inserted after a ban never matches that ban. A freshly replicated copy on a peer is therefore immune to all pre-existing bans on that peer, while bans issued after the replication apply normally.
VHA does not propagate bans between peers. Cache invalidation must reach each node separately, for example via the Broadcaster. See cache invalidation.
When a ban is followed by a replication, a peer can answer PEER HIT and skip
the replication, even though the object was just banned:
VHA_BROADCAST with skip_ban active. B’s old, banned copy
of X is still physically resident, because the ban lurker ignores bans younger
than ban_lurker_age (default 60s). The lookup hits the old copy and B
answers 200 PEER HIT, skipping the replication.This is expected behavior, not data loss. The object is still invalidated for
clients on B, because client lookups do evaluate bans. However, the
fetch_peer_hit counter and the PEER HIT response right after a ban and a
replication can look wrong without this explanation.
Note that the window is controlled by ban_lurker_age (default 60s, the ban
lurker ignores bans until they are this old), not by ban_lurker_holdoff
(default 0.010s, a lock-contention sleep). The related ban_lurker_sleep
(default 0.010s) controls how often the lurker runs; setting it to 0
disables the ban lurker entirely.
To avoid losing the replication in this scenario:
vha6-force: true header with the replication. This
sets hash_always_miss on the peer, bypassing the PEER HIT and forcing the
fresh copy in.ban_lurker_age to shrink the window in which a banned object can
still answer a peer lookup.This behavior can be observed through:
fetch_peer_hit counter. See
varnishstat.VHA_BROADCAST PEER: cache hit line in varnishlog.PEER HIT synth reason on the peer response.