【haproxy】TCP长连接和短连接的haproxy 4层代理

2023-03-02  本文已影响0人  Bogon

# yum -y install epel-release

# yum -y install haproxy

# rpm -ql haproxy

# yum info haproxy

# cat /usr/lib/systemd/system/haproxy.service

# cat /etc/sysconfig/haproxy

# cat /etc/haproxy/haproxy.cfg

##############################################################################

global

  log        127.0.0.1 local2

  maxconn    50000

  daemon

  stats socket /var/run/haproxy.sock mode 600 level admin

  stats timeout  2m

defaults

  mode                    tcp

  log                    global

  option                  dontlognull

  timeout connect 5000ms

  timeout client  360000ms

  timeout server  360000ms

  maxconn        50000

listen statistics

  mode http

  bind *:8888

  stats enable

  stats hide-version

  stats uri    /admin?stats

  stats realm  Haproxy\ Statistics

  stats auth    admin:Admin@123

  stats admin if TRUE

# 长连接

frontend  persistent_connection_12345

  bind *:12345

  mode tcp

  default_backend  persistent_connection_servers

backend  persistent_connection_servers

  balance leastconn

  server  persistent_connection_192.168.1.101 192.168.1.101:12345 check port 12345  rise 1 fall 2 maxconn 50000

  server  persistent_connection_192.168.1.102 192.168.1.102:12345 check port 12345  rise 1 fall 2 maxconn 50000

# 短连接

frontend non-persistent_connection_23456

  bind *:23456

  mode tcp

  default_backend non-persistent_connection_servers

backend non-persistent_connection_servers

  balance leastconn

  server non-persistent_connection_192.168.1.101 192.168.1.101:23456 check port 23456 rise 1 fall 2 maxconn 50000

  server non-persistent_connection_192.168.1.102 192.168.1.102:23456 check port 23456 rise 1 fall 2 maxconn 50000

##############################################################################

参考

HTTP长连接和短连接

https://www.cnblogs.com/0201zcr/p/4694945.html

我们是如何优化HAProxy以让其支持200万个并发SSL连接的?

https://cloud.tencent.com/developer/article/1031614

HAProxy高并发

https://www.cnblogs.com/zjz20/p/12809856.html

上一篇下一篇

猜你喜欢

热点阅读