5

I'm running Varnish over Apache on a Drupal site. I have a PHP script that executes on a certain path of my site, and takes a really long time... like 60 - 120 seconds. When trying to access that page, Varnish always gives me 503 guru meditation timeout after exactly 60 seconds.

I have tried setting Varnish connect_timeout to a really high value... I have tried setting all of the timeouts in Apache's php.ini to really high values... but no luck: Varnish just keeps giving me the 503 error after exactly 60 seconds.

So here's my question: where is this 60 second timeout value coming from? I'm pulling my hair out here...

(FYI: if I take Varnish out of the picture, Apache serves the page as expected after 60 - 120 seconds, which makes me think the timeout must be somewhere on the Varnish side...).

Jordan Magnuson
  • 187
  • 1
  • 2
  • 9

2 Answers2

10

I've encounter 503 errors the time that my server is not much of load. I tried to avoid that problem by increasing the timeout in vcl conf

first_byte_timeout = 300s; (by default this is set to 60s) <- probably this one can answer your question (or not) :)

Kindly check this out

http://vincentfretin.ecreall.com/articles/varnish-guru-meditation-on-timeout

hope this one helps

chojayr
  • 151
  • 1
  • 5
  • Thank you luilav! first_byte_timeout was indeed the problem. I suppose it is not possible to set this value higher only for a particular path? – Jordan Magnuson Feb 05 '14 at 18:09
  • 1
    You can define another backend with a higher timeout and switch the backend for a particular path. – NITEMAN Feb 11 '14 at 08:21
  • `bereq.first_byte_timeout` exists, but I'm not sure it's writable. If it is, you could also modify that inside of `vcl_pass` as opposed to defining a second backend just to change `first_byte_timeout`. – BMDan Mar 04 '14 at 19:54
0
Error 503 Backend fetch failed
Backend fetch failed

To resolve this issue, increase the default value of the http_resp_hdr_len parameter in your Varnish configuration file. The http_resp_hdr_len parameter specifies the max header length within the total default response size of 32768 bytes.

If the http_resp_hdr_len value exceeds 32768 bytes, you must also increase the default response size using the http_resp_size parameter. As a user with root privileges, open your Vanish configuration file in a text editor:

CentOS 6: /etc/sysconfig/varnish
CentOS 7: /etc/varnish/varnish.params
Ubuntu: /etc/default/varnish

Search for the http_resp_hdr_len parameter. If the parameter doesn’t exist, add it after thread_pool_max. Set http_resp_hdr_len to a value equal to the product count of your largest category multiplied by 21. (Each product tag is about 21 characters in length.)

For example, setting the value to 65536 bytes should work if your largest category has 3,000 products:

-p http_resp_hdr_len=65536 \

Set the http_resp_size to a value that accommodates the increased response header length.

For example, using the sum of the increased header length and default response size is a good starting point (e.g., 65536 + 32768 = 98304):

-p http_resp_size=98304 \

A snippet follows:

# DAEMON_OPTS is used by the init script.
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
     -f ${VARNISH_VCL_CONF} \
     -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
     -p thread_pool_min=${VARNISH_MIN_THREADS} \
     -p thread_pool_max=${VARNISH_MAX_THREADS} \
     -p http_resp_hdr_len=65536 \
     -p http_resp_size=98304 \
     -S ${VARNISH_SECRET_FILE} \
     -s ${VARNISH_STORAGE}"
James M
  • 200
  • 1
  • 2
  • 12