Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4849

Backend server timeout config for slow reponse server

$
0
0

I am using HAProxy 2.9.1 and I am trying to setup 2 backends as follows:

  1. Backend named svelte

This backend is fast to reponse i.e. it could take 0.1s to reponse.

Example: time to make http request

❯ time curl -I http://localhost:5173/
HTTP/1.1 404 Not Found
Access-Control-Allow-Origin: *
content-length: 928
content-type: text/html
etag: "qrysmh"
x-sveltekit-page: true
Date: Wed, 10 Jan 2024 07:20:20 GMT
Connection: keep-alive
Keep-Alive: timeout=5

curl -I http://localhost:5173/  0.00s user 0.00s system 38% cpu 0.022 total
  1. Backend named magento

This backends is slow to reponse, i.e it could take 5s or more to reponse.

Example time to make http request:

❯ time curl -I http://localhost:8090
HTTP/1.1 200 OK
Server: nginx/1.25.3
Date: Wed, 10 Jan 2024 07:20:35 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/7.0.33
Set-Cookie: created_timestamp=1704871230; expires=Thu, 09-Jan-2025 07:20:30 GMT; Max-Age=31536000; path=/
Set-Cookie: frontend=2c9ccb6743227aed1ddaf2955986a516; expires=Wed, 17-Jan-2024 07:20:31 GMT; Max-Age=604800; path=/; domain=localhost; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
X-Frame-Options: SAMEORIGIN

curl -I http://localhost:8090  0.00s user 0.01s system 0% cpu 4.861 total

And, the haproxy.cfg config file looks as follows:

global
    log 127.0.0.1   local0
    log 127.0.0.1   local1 debug
    maxconn 4096

  defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    option redispatch
    maxconn 2000
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 500000ms

  frontend localnodes
    bind *:8000
    mode http
    default_backend magento
    stats enable
    stats uri /stats
    stats refresh 10s
    stats admin if LOCALHOST 

    use_backend svelte if { path /a }
    use_backend magento if { path /b } || { path_beg /b/ }

  backend svelte
    mode http
    balance roundrobin
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    server server1 localhost:5173 check    

  backend magento
    mode http
    balance roundrobin
    server server1 localhost:8090 check

When I check in http://localhost:8000/stats as shown in this picture:

The backend named magento is always down, no matter how I change timeout connect, timeout client, timeout server.

So, I’m wondering if there is any way to setup haproxy to make it work with slow response backend ?
or in the other word, it’s kind of known server that slow reponse but we want HAProxy to mark as UP (not DOWN)? What specific config to adjust to work with particular server or backend.

Any idea or suggestion would be really appreciated.

Thanks,

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4849

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>