[prev in list] [next in list] [prev in thread] [next in thread]
List: varnish-misc
Subject: Difference between adjusting set req backend in vcl_recv and vcl_backend_fetch
From: Hamidreza Hosseini <hrhosseini () hotmail ! com>
Date: 2021-09-06 14:21:11
Message-ID: MW2PR16MB2361E7753DAD78BD8646077AD9D29 () MW2PR16MB2361 ! namprd16 ! prod ! outlook ! com
[Download RAW message or body]
Hi,
This is part of my varnish configuration file for sharding:
```
cat /etc/varnish/default.vcl
vcl 4.1;
import directors;
probe myprobe {
.request =
"HEAD /healthcheck.php HTTP/1.1"
"Connection: close"
"User-Agent: Varnish Health Probe";
.timeout = 1s;
.interval = 5s;
.window = 5;
.threshold = 3;
}
backend b-01 { .host = "b-01"; .port = "80"; .probe = myprobe; }
backend b-02 { .host = "b-02"; .port = "80"; .probe = myprobe; }
backend b-03 { .host = "b-03"; .port = "80"; .probe = myprobe; }
sub vcl_init {
new hls_cluster = directors.shard();
hls_cluster.add_backend(b-01);
hls_cluster.add_backend(b-02);
hls_cluster.add_backend(b-03);
new p = directors.shard_param();
hls_cluster.set_rampup(30s);
# hls_cluster.set_warmup(0.5);
hls_cluster.reconfigure();
hls_cluster.associate(p.use());
}
acl purge {
"localhost";
}
sub vcl_recv {
set req.backend_hint = hls_cluster.backend();
}
sub vcl_backend_fetch {
p.set(by=KEY, key=hls_cluster.key(bereq.url));
set bereq.backend = hls_cluster.backend(resolve=LAZY, healthy=CHOSEN);
}
```
1. there are two set backend in this config, one is on vcl_recv:
"set req.backend_hint = hls_cluster.backend();"
and one in vcl_backend_fetch:
"set bereq.backend = hls_cluster.backend(resolve=LAZY, healthy=CHOSEN);"
should I remove set in vcl_recv cause I think if I adjust it , all requset will go \
through this backend list and configs like healthy=CHOSEN in vcl_backend_fetch \
wouldnt be applied! Am I true?
2.Actually what is difference between vcl_backend_fetch and vcl_recv?
3.should I remove "set req.backend_hint" from vcl_recv?
Best regards,Hamidreza
[Attachment #3 (text/html)]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> Hi,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> This is part of my varnish configuration file for \
sharding:</div> <div style="font-family: Calibri, Arial, Helvetica, sans-serif; \
font-size: 12pt; color: rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> ```</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> <div>cat /etc/varnish/default.vcl </div>
<div><br>
</div>
<div>vcl 4.1;</div>
<div><br>
</div>
<div>import directors;</div>
<div><br>
</div>
<div><br>
</div>
<div>probe myprobe {</div>
<div> .request =</div>
<div> "HEAD /healthcheck.php HTTP/1.1"</div>
<div> "Connection: close"</div>
<div> "User-Agent: Varnish Health Probe";</div>
<div> .timeout = 1s;</div>
<div> .interval = 5s;</div>
<div> .window = 5;</div>
<div> .threshold = 3;</div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
<div>backend b-01 { .host = "b-01"; .port = "80"; .probe = \
myprobe; }</div> <div>backend b-02 { .host = "b-02"; .port = \
"80"; .probe = myprobe; }</div> <div>backend b-03 { .host = \
"b-03"; .port = "80"; .probe = myprobe; }</div> <div><br>
</div>
<div><br>
</div>
<div>sub vcl_init {</div>
<div><br>
</div>
<div><br>
</div>
<div> new hls_cluster = directors.shard();</div>
<div> hls_cluster.add_backend(b-01);</div>
<div> hls_cluster.add_backend(b-02);</div>
<div> hls_cluster.add_backend(b-03);</div>
<div><br>
</div>
<div><br>
</div>
<div> new p = directors.shard_param();</div>
<div> </div>
<div> hls_cluster.set_rampup(30s); </div>
<div># hls_cluster.set_warmup(0.5);</div>
<div><br>
</div>
<div> hls_cluster.reconfigure();</div>
<div> hls_cluster.associate(p.use());</div>
<div><br>
</div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>acl purge {</div>
<div> "localhost";</div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
<div>sub vcl_recv {</div>
<div><br>
</div>
<div> set req.backend_hint = hls_cluster.backend();</div>
<div><br>
</div>
<div>}</div>
<div><br>
</div>
<div><br>
</div>
<div>sub vcl_backend_fetch {</div>
<div><br>
</div>
<div> p.set(by=KEY, key=hls_cluster.key(bereq.url));</div>
<div> set bereq.backend = hls_cluster.backend(resolve=LAZY, \
healthy=CHOSEN);</div> <div><br>
</div>
<div>}</div>
<div><br>
</div>
<div>```</div>
1. there are two set backend in this config, one is on vcl_recv:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> "set req.backend_hint = \
hls_cluster.backend();"</div> <div style="font-family: Calibri, Arial, \
Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"> and one in \
vcl_backend_fetch:</div> <div style="font-family: Calibri, Arial, Helvetica, \
sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"> "set bereq.backend = \
hls_cluster.backend(resolve=LAZY, healthy=CHOSEN);"</div> <div \
style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> should I remove set in vcl_recv cause I think if I adjust it , all \
requset will go through this backend list and configs like healthy=CHOSEN in \
vcl_backend_fetch wouldnt be applied! Am I true?</div> <div style="font-family: \
Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> 2.Actually what is difference between vcl_backend_fetch and \
vcl_recv?</div> <div style="font-family: Calibri, Arial, Helvetica, sans-serif; \
font-size: 12pt; color: rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> 3.should I remove "set req.backend_hint" from \
vcl_recv?</div> <div style="font-family: Calibri, Arial, Helvetica, sans-serif; \
font-size: 12pt; color: rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> Best regards,Hamidreza<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; \
color: rgb(0, 0, 0);"> <br>
</div>
</body>
</html>
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
--===============5995090706646482778==--
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic