How to find out a single failing backend from a round-robin director?(Inline-C)
Stefan Pommerening
pom at dmsp.de
Thu Feb 10 10:33:39 CET 2011
Hi Thiago,
Am 09.02.2011 22:55, schrieb Thiago Figueiro:
> I believe varnishlog has all you need:
>
> 54 BackendOpen b backend_name source_ip source_port dest_ip dest_port
>
> Just track the id on the left (54 in this case) for the request and
response and you should be able to find the culprit.
That's correct - in my case the following (example):
417 VCL_call c recv
417 VCL_return c lookup
417 VCL_call c hash
417 VCL_return c hash
417 VCL_call c miss
417 VCL_return c fetch
31 BackendClose - cmsweb5f3cae1
31 BackendOpen b cmsweb5f3cae1 10.40.XXX.YYY 37607 10.40.XXX.ZZZ 80
417 Backend c 31 group5cae1 cmsweb5f3cae1
31 TxRequest b GET
Unfortunately the inline-C expression VRT_backend_string(sp) gives me
only the director name, which is 'group5cae1'.
What I need to get in my inline C is the specific backend choosen from
the director, 'cmsweb5f3cae1' in this example.
How to get this? Any VRT_something for this?
-- stefan
> From: varnish-misc-bounces at varnish-cache.org
[mailto:varnish-misc-bounces at varnish-cache.org] On Behalf Of Stefan
Pommerening
> Sent: Wednesday, 9 February 2011 9:47 PM
> To: varnish-misc at varnish-cache.org
> Subject: How to find out a single failing backend from a round-robin
director?(Inline-C)
>
>
>
> Hi all,
>
> I'm working with a set of varnish-caches (2.1.3) in front of some
round-robin director configured backends.
> Sometimes I experience a 503 error due to some unforseeable
circumstances like network hiccups, content server problems and other
magic... ;-)
> Nevertheless all backends are healthy regarding the large majority of
other requests (and watchdog of course), we deal with sporadic failures
here.
>
> Obviously I don't want those 503's to go through to the user.
>
> I inserted the following code in my vcl_fetch:
>
> if (beresp.status == 503) {
> set beresp.saintmode = 2s;
> restart;
> }
>
> This works quite well, the failed (503 delivering) request is
forwarded to the next backend in the director and is successfully served
then.
>
> What I am missing is the exact backend information which backend did
not serve the request or better said: where did the 503 come from?
> I already included some inline-C in order to send info to syslog, but
I am missing some VRT_(r_)something to find out the failing backend
without searching the backend's logfiles directly.
>
> My current syslog()-msg is:
>
> syslog (LOG_LOCAL7 | LOG_INFO, "VarnishLog(vcl_fetch): %s/%s[%s]
[REST=%02d] %s http://%s%s",
> VRT_backend_string(sp), VRT_r_server_hostname(sp),
VRT_IP_string(sp,VRT_r_server_ip(sp)),
> VRT_r_req_restarts(sp), VRT_r_req_request(sp), VRT_GetHdr(sp,
HDR_REQ, "\005host:"), VRT_r_req_url(sp));
>
> I managed to get the backend definition, but not the specific backend
machine name (or IP) from the backend director.
>
> ... and: is there some sort of overview on which VRT_magic fields
(for use with inline-C) exists?
>
> Thanks in advance,
> Stefan
--
Dipl.-Inform. Stefan Pommerening
Informatik-Büro: IT-Dienste & Projekte, Consulting & Coaching
http://www.dmsp.de
More information about the varnish-misc
mailing list