title: haproxy - layer 7 health check failure
body: <p>I am getting occasional layer 7 health check failures. This happens on production machine seemingly at random, maybe once a minute or every few minutes on average. Here is the configuration:</p>
  
  <pre><code>backend api
      mode http
      option httpchk GET /api/v1/status HTTP/1.0
      http-check expect status 200
      balance roundrobin
      server api1 127.0.0.1:8001 check fall 3 rise 2
      server api2 127.0.0.1:8002 check fall 3 rise 2
  </code></pre>
  
  <p>The HAproxy log tells me the following:</p>
  
  <pre><code>Health check for server api/api2 failed, reason: Layer7 timeout, check duration: 10001ms, status: 2/3 UP.
  </code></pre>
  
  <p>Strange thing is when I run a script to fetch the same URL at a much faster pace than HAproxy, it never fails to return 200 response. It never hangs like it seems to do for HAproxy.</p>
  
  <p>In addition, I'm getting occasional HAProxy error for various API calls, not just health checks, all looking quite similar:</p>
  
  <pre><code>https-in~ api/api1 45/0/0/-1/30045 504 194 - - sHVN 50/49/13/10/0 0/0 "POST /api/v1/accounts HTTP/1.1"
  </code></pre>
  
  <p>What could be the issue here? This one really got me stumped.</p>