emqtt_bench 压测 Haproxy 连接数超过5000 压测程序就报错

环境信息

  • EMQX 版本:5.0
  • 操作系统及版本:centos7.6
  • 其他

问题描述

emqtt_bench 压测 Haproxy 连接数超过5千 压测程序就报错。
1.不经过haproxy,直连emqx连接数能达到5万。排除emqx问题。
2.用lvs替换haproxy,连接数也能上5万。排除负载均衡服务器问题。
3.问题就处在haproxy。

配置文件及日志

#---------------------------------------------------------------------

Example configuration for a possible web application. See the

full configuration options online.

http://haproxy.1wt.eu/download/1.4/doc/configuration.txt

#---------------------------------------------------------------------

#---------------------------------------------------------------------

Global settings

#---------------------------------------------------------------------

global

# to have these messages end up in /var/log/haproxy.log you will

# need to:

#

# 1) configure syslog to accept network log events.  This is done

#    by adding the '-r' option to the SYSLOGD_OPTIONS in

#    /etc/sysconfig/syslog

#

# 2) configure local2 events to go to the /var/log/haproxy.log

#   file. A line like the following can be added to

#   /etc/sysconfig/syslog

#

#    local2.*                       /var/log/haproxy.log

#

log         127.0.0.1 local2

chroot      /var/lib/haproxy

pidfile     /var/run/haproxy.pid

maxconn     50000

user        gcapp

group       gcapp

daemon

# turn on stats unix socket

stats socket /var/lib/haproxy/stats

#---------------------------------------------------------------------

common defaults that all the ‘listen’ and ‘backend’ sections will

use if not designated in their block

#---------------------------------------------------------------------

defaults

log global

mode tcp

option tcplog

# Replace 1024000 with deployment connections

maxconn 50000

timeout connect 30000

timeout client 600s

timeout server 600s

#---------------------------------------------------------------------

main frontend which proxys to the backends

#---------------------------------------------------------------------

listen emqx_tcp

bind *:1883

mode tcp

option tcplog

maxconn 50000

timeout client 600s

default_backend emqx_tcp_back

#---------------------------------------------------------------------

round robin balancing between the various backends

#---------------------------------------------------------------------

backend emqx_tcp_back

mode tcp

balance source

timeout server 50s

timeout check 5000

server emqx1 192.168.0.228:1883 check inter 10000 fall 2 rise 5 weight 1

server emqx2 192.168.0.228:1883 check inter 10000 fall 2 rise 5 weight 1

#配置haproxy web监控,查看统计信息

listen stats

bind 192.168.0.226:8100 #前端浏览器中查看统计的WEB界面地址 !!!!!!!需要修改!!!!!!!

mode http

option httplog #日志类别,采用httplog

stats enable

stats auth admin:123456  #设置查看统计的账号密码

#设置haproxy监控地址为http://localhost:8100/emqx-stats

stats uri /emqx-stats

stats refresh 5s  #5s刷新一次

image