Understanding timeouts in haproxy ingress controller

1.7k views Asked by At

I am using HAProxy as an ingress controller in my GKE cluster.
This is what my configurations look like, for a service which I want to timeout in X milliseconds:

---
apiVersion: v1
kind: Service
metadata:
  name: dummy-app-service
  annotations:
    haproxy.org/backend-config-snippet: |
      option http-keep-alive
      timeout server 40ms
      timeout client 20ms
      timeout http-keep-alive 20ms
      timeout http-request 40ms  
spec:
  ports:
  - name: app
    targetPort: 8080
    port: 8080
  selector:
    app: dummy-app

I want to understand what is the difference between client and http-request timeout, and which one takes precedence over the other.
If I receive a request, will it timeout in 20ms(client timeout) or 40ms(http-request timeout) ??

1

There are 1 answers

0
Aleksandar On

The best answer is written in the documentation timeout http-request

With the HTTP request timeout, no matter what speed the client types, the request will be aborted if it does not complete in time. When the timeout expires, an HTTP 408 response is sent to the client to inform it about the problem, and the connection is closed.

If this parameter (timeout http-request ... ) is not set, the client timeout still applies between each chunk of the incoming request. It should be set in the frontend to take effect, unless the frontend is in TCP mode, in which case the HTTP backend's timeout will be used.