HAProxy community

HAProxy CPU Usage when all backend servers are in MAINT state with check directive

Hi folks!

I’ve noticed the weird HAProxy 2.0 (2.0.12) behavour when it is started with all backend servers disabled (MAINT state). Weirdness is that when the servers are configured with check directive HAProxy starts to consume additional CPU cycles (when compared to the same configuration with no-check directive). It becomes more visible when HAProxy is started with high number of threads.

For example, on a 2CPU VM and 100 backend servers in a MAINT state HAProxy started with 62 threads consumes around 20% of CPU (that’s with no load). With the same config but no-check in it CPU usage is around 1%.

Can this be fixed?

Example config:

global
   nbthread 62
   log stdout local0 warning
   stats socket /var/run/haproxy.sock mode 666 level admin
   stats timeout 2m

defaults
    log global
    mode http
    option http-use-htx
    timeout connect 5s
    timeout client 1h
    timeout server 1h

listen grpc
    bind 127.0.0.1:50051 proto h2
    option httplog
    balance roundrobin
    default-server proto h2 check inter 1s fall 1 rise 1 disabled
    #default-server proto h2 no-check inter 1s fall 1 rise 1 disabled
    server-template srv 1-100 10.0.0.1:50051