BBlack has submitted this change and it was merged.
Change subject: VCL: grace-mode only in frontend caches
......................................................................
VCL: grace-mode only in frontend caches
We've observed an issue where, due to the fact that we pass
requests through 2-3 distinct layers of varnish cache, if the
lower layers (backends) use grace-mode and serve slightly-expired
content, this triggers the next cache up the stack receiving such
a response to create a 120s hit-for-pass object due to beresp.ttl
<= 0s.
This is one possible solution: simply don't allow expired "grace"
responses in backend caches, only in the frontends directly facing
the client.
Change-Id: I32d4f25756b1b36588de461e831e4f68311b1d52
---
M modules/varnish/templates/vcl/wikimedia.vcl.erb
1 file changed, 20 insertions(+), 3 deletions(-)
Approvals:
BBlack: Verified; Looks good to me, approved
diff --git a/modules/varnish/templates/vcl/wikimedia.vcl.erb
b/modules/varnish/templates/vcl/wikimedia.vcl.erb
index 2a7d6e9..7c3eb56 100644
--- a/modules/varnish/templates/vcl/wikimedia.vcl.erb
+++ b/modules/varnish/templates/vcl/wikimedia.vcl.erb
@@ -553,6 +553,15 @@
error 403 "HTTP method not allowed.";
}
+<% if @vcl_config.fetch("layer", "") == "frontend" -%>
+ set req.grace = 5m;
+<% else -%>
+ // disable grace in backends, so we do not serve stale content to
+ // frontends, which would trigger hit-for-pass there (a value of zero
+ // is buggy in varnish 3.x and uses the default 10s value)
+ set req.grace = 0.000001s
+<% end -%>
+
<% if @vcl_config.fetch("has_def_backend", "yes") == "yes" -%>
/* Select the default backend/director, which is always the one named
'backend'.
* If an instance has no default 'backend', it must declare
has_def_backend==no,
@@ -560,11 +569,11 @@
*/
set req.backend = backend;
- if (req.backend.healthy) {
- set req.grace = 5m;
- } else {
+<% if @vcl_config.fetch("layer", "") == "frontend" -%>
+ if (!req.backend.healthy) {
set req.grace = 60m;
}
+<% end -%>
<% end -%>
<% if @vcl_config.fetch("layer", "") == "frontend" -%>
@@ -624,7 +633,15 @@
}
}
<% end -%>
+
+<% if @vcl_config.fetch("layer", "") == "frontend" -%>
set beresp.grace = 60m;
+<% else -%>
+ // disable grace in backends, so we do not serve stale content to
+ // frontends, which would trigger hit-for-pass there (a value of zero
+ // is buggy in varnish 3.x and uses the default 10s value)
+ set beresp.grace = 0.000001s
+<% end -%>
<% if @vcl_config.fetch("do_gzip", false) -%>
// Compress compressible things if the backend didn't already
--
To view, visit https://gerrit.wikimedia.org/r/259697
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I32d4f25756b1b36588de461e831e4f68311b1d52
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BBlack <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Mark Bergsma <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits