I had a 95% CPU usage with a single haproxy process, so I switched to nbproc 2.

I have a two frontends and two backends; I pinned 1 frontend and 1 backend to process 1, and pinned the remaining two to process 2. I expected the load on the CPU cores to be distributed based on the load of the frontend/backend groups, however, now I have two haproxy processes, one using 20% CPU, the other still using 95% CPU. Why is that the case?

I am not yet dropping connections, but I will be as I start using even more CPU on that one thread.

Configuration is as follows:

    nbproc 2
    maxconn 150000
    user root # haproxy
    group root # haproxy
    stats socket /var/run/haproxy.sock group haproxy mode 775

    mode tcp
    timeout connect 5000ms
    timeout client 130s
    timeout server 130s

frontend http-in
    bind-process 2
    bind *:80
    mode http
    maxconn 40000

    acl host_typea hdr(host) -i typea.example.com
    acl host_typeb hdr(host) -i www.example.com

    use_backend typea-backend if host_typea
    use_backend typeb-backend if host_typeb

    default_backend typeb-backend

frontend proxy-customers-frontend
    bind-process 1
    bind *:20000
    maxconn 10000
    option httpclose
    mode http
    log global
    acl host_typec hdr(proxy-authorization) -m len gt 80
    use_backend typec-backend if host_typec

    default_backend typed-backend

backend typea-backend
    bind-process 2
    mode http
    balance url_param ip check_post

    server localhost-30000 check
    server localhost-30001 check
    server localhost-30002 check
    server localhost-30003 check
    server localhost-30004 check
    server localhost-30005 check
    server localhost-30006 check
    server localhost-30007 check

backend typeb-backend
    bind-process 2
    mode http
    option forwardfor
    server localhost-81 check

backend typec-backend
    bind-process 1
    mode http
    server localhost-19999 check

backend typed-backend
    bind-process 1
    mode http

    server localhost-20001 check
    server localhost-20002 check
    server localhost-20003 check
    server localhost-20004 check
    server localhost-20005 check
    server localhost-20006 check
    server localhost-20007 check
    server localhost-20008 check
  • Seeing your config might help... – GregL May 13 '16 at 12:31
  • @GregL Added my current configuration. – Rytis May 15 '16 at 7:12

I've just started down a similar road with enabling multiple processes for haproxy. Based on the information here, it appears that the default behavior of the Linux kernel is for the processes to inherit CPU affinity from the parent, which would default to the same CPU. I believe you will see a difference if you map each process to a specific CPU with cpu-map:

nbproc 2
cpu-map 1 0
cpu-map 2 1
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.