TCP 上的 CPU 使用率过高

TCP 上的 CPU 使用率过高

我正在运行 haproxy 2.4,当 haproxy 配置为 tcp 模式时,我的 CPU 使用率很高。

例子:

运行压力工具生成大约 30k 个连接:

./pst -c 100000 -r 100000 -u urlist.txt -phttp://192.168.58.13:3128

所有 haproxy 进程的 CPU 使用率飙升至接近 100%,负载为 4+。在 http 模式下运行相同的测试。

每个进程的 CPU 使用率约为 10%,负载为 1.20。

我也尝试使用 nbthread 代替 nbproc,但得到相同的结果。

此外,这个问题在 haproxy 2.5 上仍然存在

HTTP模式配置文件:

#  1,5
# CPU(s) 11
global
    log 127.0.0.1 local0
    maxconn 200000
    nbproc           11
    cpu-map           1 0
    cpu-map           2 1
    cpu-map           3 2
    cpu-map           4 3
    cpu-map           5 4
    cpu-map           6 5
    cpu-map           7 6
    cpu-map           8 7
    cpu-map           9 8
    cpu-map           10 9
    cpu-map           11 10
    uid 0
    gid 0
    chroot  /tmp
    pidfile /var/run/haproxy.pid
    stats socket /var/run/haproxy.stat mode 600 level admin
    stats bind-process 1
    daemon
#   debug
#   quiet

defaults
    log global
    log-format  HASTATS:::%{+Q}o:::client_ip=%ci:::client_port=%cp:::datetime_of_request=[%tr]:::frontend_name_transport=%ft:::backend_name=%b:::server_name=%s:::time_to_receive_full_request=%TR:::Tw=%Tw:::Tc=%Tc:::response_time=%Tr:::active_time_of_request=%Ta:::status_code=%ST:::bytes_read=%B:::captured_request_cookie=%CC:::captured_response_cookie=%CS:::termination_state_with_cookie_status=%tsc:::actconn=%ac:::feconn=%fc:::beconn=%bc:::srv_conn=%sc:::retries=%rc:::srv_queue=%sq:::backend_queue=%bq:::captured_request_headers_default_style=%hr:::captured_response_headers_default_style=%hs:::server_ip=%si:::server_port=%sp:::frontend_name=%f:::http_method=%HM:::http_request_uri_without_query=%HP:::http_request_query_string=%HQ:::http_request_uri=%HU:::bytes_uploaded=%U:::ssl_ciphers=%sslc:::ssl_version=%sslv:::%[capture.res.hdr(0)]
    mode    http
    option  dontlognull
    retries 3
    option  redispatch
    maxconn 200000
    timeout connect 5000
    timeout client  50000
    timeout server  50000

frontend ddsds
    bind    :3128 name ddsds
    capture request header Host len 1024
    capture request header Content-Type len 1024
    capture request header User-Agent len 1024
    capture request header Referer len 1024
    capture request header X-Forwarded-For len 1024
    capture response header Content-Type len 1024
    capture cookie Cookie_2 len 100
    http-request set-header mode mode:tcp
    http-request capture hdr(mode)  len 10
    mode http
    option  httplog
#   http-keep-alive: * 1 *
    option http-keep-alive
    timeout http-keep-alive 15000
    option prefer-last-server
    option redispatch
    no option httpclose
    option http-tunnel
    timeout client  15000
    timeout http-request    50000
    timeout queue   50000

    default_backend default_ddsds

backend default_ddsds
    mode http
    balance leastconn
#   http-keep-alive: * 1 *
    option http-keep-alive
    timeout http-keep-alive 15000
    option prefer-last-server
    option redispatch
    no option httpclose
    option http-tunnel
    timeout connect 4000
    timeout server  50000
    timeout http-request    50000
    timeout queue   50000
    retries 3

    server normal_port 192.168.58.12:50877 weight 1 maxconn 10000 check inter 60000 rise 2 fall 3 source 192.168.58.13

# ddsds no result
frontend admin_page
    bind    127.0.0.1:64741
    mode http
    stats enable
    stats refresh 10s
    stats uri /stats

TCP模式下的配置文件:

#  1,5
# CPU(s) 11
global
    log 127.0.0.1 local0
    maxconn 200000
    nbproc           11
    cpu-map           1 0
    cpu-map           2 1
    cpu-map           3 2
    cpu-map           4 3
    cpu-map           5 4
    cpu-map           6 5
    cpu-map           7 6
    cpu-map           8 7
    cpu-map           9 8
    cpu-map           10 9
    cpu-map           11 10
    uid 0
    gid 0
    chroot  /tmp
    pidfile /var/run/haproxy.pid
    stats socket /var/run/haproxy.stat mode 600 level admin
    stats bind-process 1
    daemon
#   debug
#   quiet

defaults
    log global
    log-format  HASTATS:::%{+Q}o:::client_ip=%ci:::client_port=%cp:::datetime_of_request=[%tr]:::frontend_name_transport=%ft:::backend_name=%b:::server_name=%s:::time_to_receive_full_request=%TR:::Tw=%Tw:::Tc=%Tc:::response_time=%Tr:::active_time_of_request=%Ta:::status_code=%ST:::bytes_read=%B:::captured_request_cookie=%CC:::captured_response_cookie=%CS:::termination_state_with_cookie_status=%tsc:::actconn=%ac:::feconn=%fc:::beconn=%bc:::srv_conn=%sc:::retries=%rc:::srv_queue=%sq:::backend_queue=%bq:::captured_request_headers_default_style=%hr:::captured_response_headers_default_style=%hs:::server_ip=%si:::server_port=%sp:::frontend_name=%f:::http_method=%HM:::http_request_uri_without_query=%HP:::http_request_query_string=%HQ:::http_request_uri=%HU:::bytes_uploaded=%U:::ssl_ciphers=%sslc:::ssl_version=%sslv:::%[capture.res.hdr(0)]
    mode    http
    option  dontlognull
    retries 3
    option  redispatch
    maxconn 200000
    timeout connect 5000
    timeout client  50000
    timeout server  50000

frontend ddsds
    bind    :3128 name ddsds
    capture request header Host len 1024
    capture request header Content-Type len 1024
    capture request header User-Agent len 1024
    capture request header Referer len 1024
    capture request header X-Forwarded-For len 1024
    capture response header Content-Type len 1024
    capture cookie Cookie_2 len 100
    http-request set-header mode mode:tcp
    http-request capture hdr(mode)  len 10
    mode tcp
    option  httplog
    option  dontlognull
    option http-tunnel
    timeout client  15000
    timeout http-request    50000
    timeout queue   50000

    default_backend default_ddsds

backend default_ddsds
    mode tcp
    balance leastconn
    option http-tunnel
    timeout connect 4000
    timeout server  50000
    timeout http-request    50000
    timeout queue   50000
    retries 3

    server normal_port 192.168.58.12:50877 weight 1 maxconn 10000 check inter 60000 rise 2 fall 3 source 192.168.58.13

# ddsds no result
frontend admin_page
    bind    127.0.0.1:64741
    mode http
    stats enable
    stats refresh 10s
    stats uri /stats

任何人都可以帮我解决这个问题。

提前致谢。

相关内容