5

My varnish version is 3.0.

My server works well while I curl the URLs, but when use varnish cache it return 503 service unavailable occasionally.

The log info likes is:

0 Debug        - "VCL_error(200, OK)"
24 VCL_call     c recv error
24 VCL_call     c error deliver
24 SessionClose c error
0 Debug        - "VCL_error(200, OK)"
27 VCL_call     c recv error
27 VCL_call     c error deliver
27 SessionClose c error
0 Debug        - "VCL_error(200, OK)"
16 VCL_call     c recv error
16 VCL_call     c error deliver
16 SessionClose c error
14 Debug        - "Write error, retval = 2998272, len = 8465870, errno = Success"
0 Debug        - "VCL_error(200, OK)"
14 VCL_call     c recv error
14 VCL_call     c error deliver
14 SessionClose c error
0 Debug        - "VCL_error(200, OK)"
21 VCL_call     c recv error
21 VCL_call     c error deliver
21 SessionClose c error

PS:The server response 200 when I curl or type the urls on browsers.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
lichengwu
  • 4,277
  • 6
  • 29
  • 42

1 Answers1

11

varnish 503 can be fixed by steps below:

  1. Increase the connect_timeout,.first_byte_timeout and .between_bytes_timeout in you backend setting:

    backend default {
      .host = "www.example.com";
      .connect_timeout = 5s;
      .first_byte_timeout = 10s;
      .between_bytes_timeout = 10s;
    }
    
  2. Increase the parameter to 8192 when start varnish.

    varnishd [options] http_resp_hdr_len=8192
    
  3. Checkout you network or backend server.

    If Step 1 and Step 2 can not help you, please check you network connection and banckend server's availability.

Kenster
  • 23,465
  • 21
  • 80
  • 106
lichengwu
  • 4,277
  • 6
  • 29
  • 42
  • 1
    Maybe this will help others too: i had a similar problem with curl and varnish. Also got the annoying 503 with curl requests while the rest responded normally. My fix: removed the "Content-Length" header (as i had it just to be complete) – klapvee Jan 11 '15 at 12:38
  • From my reading https://www.varnish-cache.org/docs/3.0/reference/varnishd.html 32bit systems should be accounted for with regard to #2 option above. Also, the default value seems to be 8192 ? – Mike Q Dec 28 '16 at 17:03
  • @barthoda most likely the first_byte_timeout if I were to guess. – Mike Q Dec 28 '16 at 17:04