40000-50000个并发
处理能力10GB
LVS HAproxy四层负载
NGINX HAProxy 七层负载
1、安装
2、配置
global
defaults
frontend
backend
listen
--
global:
maxconn 10000
daemon
nbproc 进程数
defaults:
mode tcp/httpd
retries 3
timeout connect 10s
timeout client 20s
timeout server 30s
timeout check 5s
frontend www:
bind *.80
mode http
option httplog #记录http日志
option forwardfor #记录访问IP
option httpclose #关闭TCP连接
log global
default_backend htmpool
backend htmpool:
mode http
option redispatch #是否设置cookie
option abortonclose #如果服务器负载很高,自动结束处理时间长的连接
balance roundrobin/static-rr/source/leastconn/uri/uri_param/hdr #轮询算法
option httpchk GET /index.php #健康状态检查
server web1 ip:8080 cookie server1 weight 6 check inter 2000 rise 2 fall 3
//定义监控页面
listen admin_stats
bind *:9188
mode http
log 127.0.0.1 local0 err
stats refresh 30s
stats uri /status
stats realm welcome login\ Haproxy
stats auth admin:admin
stats hide-version
stats admin if TRUE
frontend基于ACL做负载均衡
acl www hdr_beg(host) -i ^(www.z.cn|z.cn)
acl bbs hdr_dom(host) -i bbs.z.cn
acl url url_sub -i buy_sid=
use_backend server_www if www
use_backend server_app if url
use_backend server_bbs if bbs
default_backend server_cache
实例
启动
haproxy -f xx.cfg
haproxy -c #语法检查
平滑重启
haproxy -f xx.cfg -st cat haproxy.pid
HAProxy+keepalived 高可用