当前位置:网站首页>Yiwen takes you to know about haproxy
Yiwen takes you to know about haproxy
2022-07-19 04:55:00 【Xiaoxinai programming】
Load balancing -HAProxy
HAProxy Provide high availability 、 Load balancing and based on TCP and HTTP Agent for application , Support virtual host , It's free 、 A fast and reliable solution , Include Twitter,Reddit,StackOverflow,GitHub A number of well-known Internet companies, including .HAProxy Implemented an event driven 、 Single process model , This model supports a very large number of concurrent connections .
install HAProx
haproxy— Mainly for load balancing 7 layer , You can also do 4 Layer load balancing
apache You can also do 7 Layer load balancing , But it's troublesome . No one uses it in actual work ;
Load balancing is done through OSI The agreement corresponds to ;
7 Layer load balancing : With 7 layer http agreement ;
4 Layer load balancing : It's using tcp Load balancing by protocol plus end slogan ;
// Download dependency package
yum install gcc vim wget
// Upload haproxy Source package
// decompression
tar -zxvf haproxy-1.6.5.tar.gz -C /usr/local
// Entry directory 、 Compile 、 install
cd /usr/local/haproxy-1.6.5
make TARGET=linux31 PREFIX=/usr/local/haproxy
make install PREFIX=/usr/local/haproxy
mkdir /etc/haproxy
// Empowerment
groupadd -r -g 149 haproxy
useradd -g haproxy -r -s /sbin/nologin -u 149
haproxy
// establish haproxy The configuration file
mkdir /etc/haproxy
vim /etc/haproxy/haproxy.cfg```
## To configure HAProxy
Profile path :/etc/haproxy/haproxy.cfg
```java
#logging options
global
log 127.0.0.1 local0 info
maxconn 5120
chroot /usr/local/haproxy
uid 99
gid 99
daemon
quiet
nbproc 20
pidfile /var/run/haproxy.pid
defaults
log global
mode tcp
option tcplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5s
clitimeout 60s
srvtimeout 15s
#front-end IP for consumers and producters
listen rabbitmq_cluster
bind 0.0.0.0:5672
mode tcp
#balance url_param userid
#balance url_param session_id check_post 64
#balance hdr(User-Agent)
#balance hdr(host)
#balance hdr(Host) use_domain_only
#balance rdp-cookie
#balance leastconn
#balance source //ip
balance roundrobin
server node1 127.0.0.1:5673 check inter
5000 rise 2 fall 2
server node2 127.0.0.1:5674 check inter
5000 rise 2 fall 2
listen stats
bind 172.16.98.133:8100
mode http
option httplog
stats enable
stats uri /rabbitmq-stats
stats refresh 5s
start-up HAproxy load
ha-proxy Is a high-performance load balancing software . Because it focuses on Load Balancing , Therefore, nginx Better than load balancing , More professional .
/usr/local/haproxy/sbin/haproxy -f
/etc/haproxy/haproxy.cfg
// see haproxy Process status
ps -ef | grep haproxy
Visit the following address pair mq Node monitoring
http://172.16.98.133:8100/rabbitmq-stats
Access... In code mq The cluster address , It becomes access haproxy Address :5672
summary :
HAProxy Implemented an event driven , Single process model , This model supports a very large number of concurrent connections . The multiprocess or multithreaded model is limited by memory 、 System scheduler restrictions and ubiquitous lock restrictions , Rarely handle thousands of concurrent connections . Event driven model because of better resource and time management of user space (User-Space) Achieve all of these tasks , So there are no such problems . The disadvantage of this model is , On a multicore system , These programs usually have poor scalability . That's why they have to optimize to Make each CPU Time slice (Cycle) Do more work .
边栏推荐
猜你喜欢

免签名模板审核的短信验证测试

Reproduction of XOR and encryption decryption

项目组暑假总结02

Tidb performance optimization overview

新生任务-5

Some concepts of ES

畢設:基於Vue+Socket+Redis的分布式高並發防疫健康管理系統

Database and the future of open source
![[fuel cell] simulation of fuel cell system control strategy based on Simulink](/img/c8/a8715dd5d57533208cfb4dd918b9e7.png)
[fuel cell] simulation of fuel cell system control strategy based on Simulink

Mysql database table a data synchronization to table b
随机推荐
Hightec new aurix tc37x demo project
Some concepts of ES
网址在线封装APK系统源码
[vuforia] simple logic of image recognition
NoSQL概述
知识图谱de构建与应用(六):知识图谱的存储、服务与质量
And predicts that nerf will eventually replace deepfake
.sh脚本编写
NPM installation tutorial
摄像头切换
Restclient operation document
一文了解配置中心
知识图谱de构建与应用(七):大规模知识图谱预训练
MYSQL模糊匹配1,11,111这种相似字符串问题
Es document operation
Tidb learning
DSL query document
Using circular statements to make login programs
Monitoring and alarm of kubernetes
Overview of CKS core knowledge points