Varnish
De Hegyd Doc.
(Différences entre les versions)
(Page créée avec « == Memento == === Configuration et commandes du daemon === Elle se fait dans le fichier "/etc/default/varnish", nous pourront utiliser les paramètres suivants : <pre> -a <[h… ») |
|||
| Ligne 1 : | Ligne 1 : | ||
== Memento == | == Memento == | ||
=== Configuration et commandes du daemon === | === Configuration et commandes du daemon === | ||
| + | * Configuration | ||
Elle se fait dans le fichier "/etc/default/varnish", nous pourront utiliser les paramètres suivants : | Elle se fait dans le fichier "/etc/default/varnish", nous pourront utiliser les paramètres suivants : | ||
<pre> | <pre> | ||
| Ligne 10 : | Ligne 11 : | ||
-s <storagetype,options> # where and how to store objects (file for file backend and malloc for memory bakend) | -s <storagetype,options> # where and how to store objects (file for file backend and malloc for memory bakend) | ||
</pre> | </pre> | ||
| + | |||
| + | * Commandes | ||
| + | Test de la configuration et la recharge si valide : | ||
| + | <pre>service varnish reload</pre> | ||
=== Le language VCL === | === Le language VCL === | ||
| Ligne 27 : | Ligne 32 : | ||
* vcl_timeout : Called by the reaper thread when a cached document has reached its expiry time. | * vcl_timeout : Called by the reaper thread when a cached document has reached its expiry time. | ||
| - | ==== Backends === | + | ==== Backends ==== |
* Configuration d'un hôte avec test : | * Configuration d'un hôte avec test : | ||
<pre> | <pre> | ||
| Ligne 39 : | Ligne 44 : | ||
"Connection: close"; | "Connection: close"; | ||
} | } | ||
| + | } | ||
| + | backend hostname2 { | ||
| + | .host = "XXX.XXX.XXX.XXX"; | ||
| + | .port = "80"; | ||
| + | .probe = { | ||
| + | .request = | ||
| + | "GET / HTTP/1.1" | ||
| + | "Host: localhost" | ||
| + | "Connection: close"; | ||
| + | .timeout = 120s; | ||
| + | .window = 5; | ||
| + | .threshold = 2; | ||
| + | .interval = 5s; | ||
| + | } | ||
} | } | ||
</pre> | </pre> | ||
| - | * Round robin | + | * Multiples backend (Round robin, random) |
Il faut utiliser une directive director : | Il faut utiliser une directive director : | ||
<pre> | <pre> | ||
| Ligne 48 : | Ligne 67 : | ||
{ .backend = hostname1; } | { .backend = hostname1; } | ||
{ .backend = hostname2; } | { .backend = hostname2; } | ||
| + | } | ||
| + | director WebSiteB random { | ||
| + | { .backend = hostname1; .weight = 1; } | ||
| + | { .backend = hostname2; .weight = 2; } | ||
} | } | ||
</pre> | </pre> | ||
| + | |||
| + | |||
[[Catégorie:Administration serveurs]] | [[Catégorie:Administration serveurs]] | ||
Version du 20 juin 2012 à 07:32
Sommaire |
Memento
Configuration et commandes du daemon
- Configuration
Elle se fait dans le fichier "/etc/default/varnish", nous pourront utiliser les paramètres suivants :
-a <[hostname]:port> # listen address -f <filename> # VCL file -p <parameter=value> # set tunable parameters -S <secretfile> # authentication secret for management -T <hostname:port> # Management interface -s <storagetype,options> # where and how to store objects (file for file backend and malloc for memory bakend)
- Commandes
Test de la configuration et la recharge si valide :
service varnish reload
Le language VCL
Subroutines
Ci-dessous les différentes section configurable du cache en utilisant le lagnuage VCL.
- backends & directors : Backend servers configuration. It may be multiple backend & director sections.
- vcl_recv : Called at the beginning of a request, after the complete request has been received and parsed. Its purpose is to decide whether or not to serve the request, how to do it, and, if applicanle, which backend to use.
- vcl_hit : Called after a cache lookup if the requested document was found in the cache.
- vcl_miss : Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use.
- vcl_fetch : Called after a document has been retrieved from the backend, before it is inserted into the cache.
- vcl_timeout : Called by the reaper thread when a cached document has reached its expiry time.
Backends
- Configuration d'un hôte avec test :
backend hostname1 {
.host = "XXX.XXX.XXX.XXX";
.port = "80";
.probe = {
.request =
"GET / HTTP/1.1"
"Host: localhost"
"Connection: close";
}
}
backend hostname2 {
.host = "XXX.XXX.XXX.XXX";
.port = "80";
.probe = {
.request =
"GET / HTTP/1.1"
"Host: localhost"
"Connection: close";
.timeout = 120s;
.window = 5;
.threshold = 2;
.interval = 5s;
}
}
- Multiples backend (Round robin, random)
Il faut utiliser une directive director :
director WebSiteA round-robin {
{ .backend = hostname1; }
{ .backend = hostname2; }
}
director WebSiteB random {
{ .backend = hostname1; .weight = 1; }
{ .backend = hostname2; .weight = 2; }
}
