backend health check

Yutaro Shimamura yu at irx.jp
Fri Feb 27 19:15:08 CET 2009


Hi,

I'm tring Backend_health check by .probe in backend{} vcl.
got a problem, cannot get read() in vbp_poke().

-------------------------
Server OS: Debian libev-based httpd
Client OS: FreeBSD 7.1 amd64, varnish rev 3827
-------------------------

Working server fine with IPv4,
but varnishlog appeared

 > 0 Backend_health - api_88 Still sick 4--X-S--- 0 3 10 0.000000  
0.000000

Don't apperaed R, H flags.


So I was check response by telnet and C based client .
But they were work fine, this is a dump of telnet response.

 >>
yu at yu:/root> telnet 210.135.99.88 12345
Trying 210.135.99.88...
Connected to 210.135.99.88.
Escape character is '^]'.
GET / HTTP/1.1

HTTP/1.1 200 OK
Content-Type: text/javascript; charset=UTF-8
Date: Fri, 27 Feb 2009 16:55:38 GMT
Content-Length: 18

HOGEHOGE PIYOPIYO
<<

C based client is very simple, write(), shutdown(SHUT_WR) and read().
It was work fine, too.


So debug with gdb.
In vbp_poke(), I got some strange responses.

[[[[[ 1 ]]]]]
read() was return 0, errno = 9 (EBADF),
0 byte in vt->resp_buf.
so varnishlog is empty after "0.000000 0.000000".

( read() not return -1, so I didn't check errno.
   but I tried errno = 0; above read(), it changed 0 -> 9 )



[[[[ 2 ]]]]
commentout shutdown(s, SHUT_WR),
varnishlog return
 >>
     0 Backend_health - api_88 Still sick 4--X-S--- 0 3 10 0.000000  
0.000000 HTTP/1.1 200 OK
Content-Type: text/javascript; charset=UTF-8
Date: Fri, 27 Feb 2009 17:15:40 GMT
Content-Length: 18

HOGEHO
<<

this reply, vbp_poke() returned here.
 >>
195   do {
196     pfd->events = POLLIN;
197     pfd->revents = 0;
198     tmo = (int)round((t_end - t_now) * 1e3);
199     if (tmo > 0)
200       i = poll(pfd, 1, tmo);
201     if (i == 0 || tmo <= 0) {
202       TCP_close(&s);
203       return;
204     }
<<

poll return 0,
i = 0; -> TCP_close & return.

so don't work sscanf(vt->resp_buf, "HTTP/%*f %u %s", &resp, buf),
and didn't get R and H flags..
(is this work fine?
  I don't know whether poll return 0 is excepted work here.)

anyway, shutdown() not using,
it was work fine compare shutdown() use.
I can't understand shutdown(SHUT_WR) affected read()...

:vcl:
 >>
backend api_88 {
         .host = "210.135.99.88";
         .port = "12345";
         .probe = {
           .request =
             "GET / HTTP/1.1";
           .timeout = 1 s;
           .interval = 2 s;
           .window = 10;
           .threshold = 3;
         }
}

director dic_apis random {
   { .backend = api_88; .weight = 1;}
}


sub vcl_recv {

   set req.backend = dic_apis;
   set req.http.host = "dic.hoge.com";
   lookup;
}
<<

:varnishd args:
 >>
/root/sbin/varnishd -T 127.0.0.1:10401 -f /root/etc/test.vcl\
   -s malloc -p client_http11=on -p backend_http11=on \
   -p ping_interval=200000 -p cc_command="cc -fpic -shared -O3 -Wl,-x - 
o %o %s" \
   -w2,300,300 -a 0.0.0.0:12345
<<


Thanks for your help.

regards,


=================
島村 優太郎 / Yutaro Shimamura
yu at irx.jp



More information about the varnish-dev mailing list