How to find out a single failing backend from a round-robin director? (Inline-C)

Stefan Pommerening pom at
Wed Feb 9 11:47:00 CET 2011

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 

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;

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_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,


*Dipl.-Inform. Stefan Pommerening
Informatik-Büro: IT-Dienste & Projekte, Consulting & Coaching*

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list