![]() |
![]()
| ![]() |
![]()
NAMEvmod_saintmode - Saint mode backend director SYNOPSISimport saintmode [as name] [from "path"] VOID denylist(DURATION expires) STRING status() new xsaintmode = saintmode.saintmode(BACKEND backend, INT threshold) DESCRIPTIONThis VMOD provides saintmode functionality for Varnish Cache 4.1 and newer. The code is in part based on Poul-Henning Kamp's saintmode implementation in Varnish 3.0. Saintmode lets you deal with a backend that is failing in random ways for specific requests. It maintains a denylist per backend, marking the backend as sick for specific objects. When the number of objects marked as sick for a backend reaches a set threshold, the backend is considered sick for all requests. Each denylisted object carries a TTL, which denotes the time it will stay denylisted. Saintmode in Varnish 4.1 is implemented as a director VMOD. We instantiate a saintmode object and give it a backend as an argument. The resulting object can then be used in place of the backend, with the effect that it also has added saintmode capabilities. Any director will then be able to use the saintmode backends, and as backends marked sick are skipped by the director, this provides a way to have fine grained health status on the backends, and making sure that retries get a different backend than the one which failed. Example: vcl 4.0; import saintmode; import directors; backend tile1 { .host = "192.0.2.11"; .port = "80"; } backend tile2 { .host = "192.0.2.12"; .port = "80"; } sub vcl_init { VOID denylist(DURATION expires)Marks the backend as sick for a specific object. Used in vcl_backend_response. Corresponds to the use of beresp.saintmode in Varnish 3.0. Only available in vcl_backend_response. Example: sub vcl_backend_response { STRING status()Returns a JSON formatted status string suitable for use in vcl_synth. sub vcl_recv { Example JSON output: { new xsaintmode = saintmode.saintmode(BACKEND backend, INT threshold)new xsaintmode = saintmode.saintmode( Constructs a saintmode director object. The threshold argument sets the saintmode threshold, which is the maximum number of items that can be denylisted before the whole backend is regarded as sick. Corresponds with the saintmode_threshold parameter of Varnish 3.0. Example: sub vcl_init { BACKEND xsaintmode.backend()Used for assigning the backend from the saintmode object. Example: sub vcl_backend_fetch { INT xsaintmode.denylist_count()Returns the number of objects currently denylisted for a saintmode director object. Example: sub vcl_deliver { BOOL xsaintmode.is_healthy()Checks if the object is currently denylisted for a saintmode director object. If there are no valid objects available (called from vcl_hit or vcl_recv), the function will fall back to the backend's health function. DEPRECATEDALIAS blacklist()Deprecated alias for denylist(). ALIAS xsaintmode.blacklist_count()Deprecated alias for xsaintmode.denylist_count().
|