vcl_synth

Madhusudan Ramanna m.ramanna at ymail.com
Wed Sep 10 06:36:59 CEST 2014


Hello, 

We're using 3.0.5 in production and currently testing 4.0.1. 

We have some urls for which we always construct synthetic responses. (/ping response pong)

In 4.x vcl,  I'm matching against the req url and returning synth with appropriate error code.

>>>>>>>>>>>>>>>

sub vcl_recv {
  if (req.url ~ "^/ping") {
    return (synth(1002, "OK"));
  }


sub vcl_synth {

  if (resp.status == 1002) {
    set resp.status = 200;
    set resp.http.Content-Type = "text/plain; charset=utf-8";
    synthetic("pong");
    return (deliver);
  }

}
<<<<<<<<<<<<<<<<<

However, when the backend is down, varnish does not return the synthetic response


< HTTP/1.1 503 OK
< Date: Wed, 10 Sep 2014 04:31:40 GMT
< Server: Varnish
< X-Varnish: 35
< Content-Length: 0
< Connection: keep-alive

Here is the varnishlog

-   ReqHeader      Host: localhost:6081
-   ReqHeader      Accept: */*
-   ReqHeader      X-Forwarded-For: 127.0.0.1
-   VCL_call       RECV
-   Debug          "VCL_error(1002, OK)"
-   VCL_return     synth
-   VCL_call       HASH
-   VCL_return     lookup
-   Timestamp      Process: 1410309978.983313 0.000075 0.000075
-   RespHeader     Date: Wed, 10 Sep 2014 00:46:18 GMT
-   RespHeader     Server: Varnish
-   RespHeader     X-Varnish: 32797
-   RespProtocol   HTTP/1.1
-   RespStatus     503
-   RespReason     Service Unavailable
-   RespReason     OK
-   VCL_call       SYNTH
-   VCL_return     deliver
-   RespHeader     Content-Length: 0


Not sure why the thread would call HASH. I would expect varnish to deliver the response after the vcl_synth call ?

Is this the expected behavior ? How can I fix this to return synthetic response without regard for the health of the backend

appreciate your response !

thank you,

Madhu

ps: Also looking forward to 4.x version of Varnish book 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140909/3afb3804/attachment-0001.html>


More information about the varnish-misc mailing list