当前位置:网站首页>Haproxy high availability solution
Haproxy high availability solution
2022-07-04 13:46:00 【51CTO】
Add --line-numbers Options
Factors that measure load balancer performance
Session rate Conversation rate : Number of sessions per minute
Session concurrency Number of concurrent sessions : The longer the server takes to process the session , The more concurrent sessions ;
Date rate Data rate : With MB/s、Mbps To measure
HaProxy brief introduction
Official website : https://www.haproxy.org/
HAProxy Is a free load balancing software , Can run on most mainstream Linux On the operating system .
Suitable for heavy load Web Site , These sites usually need session persistence or seven layer proxy .
HAProxy Core functions
- Load balancing :L4 and L7 Two modes , Support RR/ static state RR/LC/IP Hash/URI Hash/URL_PARAM Hash/HTTP_HEADER Hash And so on
- health examination : Support TCP and HTTP Two modes of health examination
- Conversation retention : For application clusters without session sharing , It can be done by Insert Cookie/Rewrite Cookie/Prefix Cookie, And many of the above Hash Method to achieve session retention
- SSL:HAProxy Can be parsed HTTPS agreement , And can decrypt the request as HTTP Back to back end transmission
- HTTP Request rewriting and redirection
- Monitoring and statistics :HAProxy Provides the basis for Web The statistics page of , Show health status and traffic data . Based on this function , Users can develop monitoring programs to monitor HAProxy The state of
HAProxy Working mode
- http: The client request is deeply analyzed and then sent to the server ;
- tcp:4 Layer scheduling , Do not check the information on the seventh floor ;
- Health: Just a health check ( Not recommended );
HAProxy Advantages and disadvantages
advantage
- Support sessio、cookie function ;
- Can pass Url Take a health check ;
- efficiency 、 Load balancing speed is higher than Nginx And below LVS;
- HAProxy Support TCP, It can be done to MySQL Load balancing ;
- Rich scheduling algorithms ;
shortcoming
- Regular expressions are weaker than Nginx;
- Logs depend on Syslogd;
HAProxy install
1) install haproxy
CentOS The system can use yum Install directly
see HAProxy edition
2022 The latest version in is 2.6
2) Modify the configuration file
$ v i m / e t c / h a p r o x y / h a p r o x y . c f g
g l o b a l
l o g 1 2 7 . 0 . 0 . 1 l o c a l 2
c h r o o t / v a r / l i b / h a p r o x y
p i d f i l e / v a r / r u n / h a p r o x y . p i d # p i d writing Pieces of
m a x c o n n 4 0 0 0 # most Big even Pick up Count ( Silent recognize 4 0 0 0 )
u s e r h a p r o x y
g r o u p h a p r o x y
d a e m o n # take Into the cheng discharge Enter into d e a m o n model type shipment That's ok ;
d e f a u l t s
m o d e h t t p # work do model type ( Silent recognize h t t p )
l o g g l o b a l # Mining use whole game set The righteous Of Japan Records
o p t i o n h t t p l o g # Japan Records class other ( h t t p Japan Records grid type )
o p t i o n d o n t l o g n u l l # No remember record healthy kang check check Of Japan Records Letter Rest
o p t i o n h t t p - s e r v e r - c l o s e
o p t i o n f o r w a r d f o r e x c e p t 1 2 7 . 0 . 0 . 0 / 8
o p t i o n r e d i s p a t c h # S e r v e r i d clothing service device hang fall after strong system set towards To Its it healthy kang Of clothing service device On
r e t r i e s 3 # even Pick up loss Defeat To 3 Time after Just ren service clothing service No can use
t i m e o u t h t t p - r e q u e s t 1 0 s
t i m e o u t q u e u e 1 m
t i m e o u t c o n n e c t 1 0 s
t i m e o u t c l i e n t 1 m # customer Household End even Pick up super when
f r o n t e n d m a i n *: 5 0 0 0 # prison listen Of End mouth
d e f a u l t _ b a c k e n d a p p # take please seek turn Hair To name by “ a p p ” Of after End clothing service
b a c k e n d s t a t i c # set The righteous after End clothing service
b a l a n c e r o u n d r o b i n
s e r v e r s t a t i c 1 2 7 . 0 . 0 . 1: 4 3 3 1 c h e c k
b a c k e n d a p p
b a l a n c e r o u n d r o b i n
s e r v e r a p p 1 1 2 7 . 0 . 0 . 1: 5 0 0 1 c h e c k
l i s t e n s t a t u s b i n d *: 1 0 2 5 0 # set The righteous prison control page Noodles
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
{ The configuration file consists of }
global: Global configuration block , Configuration parameters take effect globally ;
default: Set the default parameters for other parts that follow , The default parameters can be reset by subsequent parts ( That is, the subsequent configuration shall prevail );
frontend: Define front-end Services ;
backend: Define back end services
3) Service start stop
$ s y s t e m c t l e n a b l e - - n o w h a p r o x y . s e r v i c e # Qi dynamic h a p r o x y and set up Set up by open machine since Qi
$ s y s t e m c t l s t a t u s h a p r o x y . s e r v i c e # check see clothing service shape state
$ s y s t e m c t l s t o p h a p r o x y . s e r v i c e # stop stop h a p r o x y . s e r v i c e
- 1.
- 2.
- 3.
monitor HAProxy state
see HAProxy Service port , Then through the host IP: The port is accessed in the browser HAProxy Monitoring page of .
$ ss -ntulp | grep haproxy
remarks
- Queue Information about queue data ( The current number of queues , Maximum , Queue limit number );
- Session rate Session rate per second ( Current value , Maximum , Limited quantity );
- Sessions There will always be a lot of talk ( Current value , Maximum , Total amount ,Lbtot: total number of times a server was selected Total time taken to select a server );
- Bytes( Inbound 、 Outbound flow );
- Denied( Refuse request 、 Reject response );
- Errors( Wrong request 、 Wrong connection 、 Wrong response );
- Warnings( Try warning again retry、 Reconnect the redispatches);
- Server( state 、 The last time to check ( How long ago was the last inspection performed )、 The weight 、 Number of backup servers 、down Number of servers 、down Machine time ).
边栏推荐
- 模块化笔记软件综合评测:Craft、Notion、FlowUs
- 实战:fabric 用户证书吊销操作流程
- 提高MySQL深分页查询效率的三种方案
- Node の MongoDB 安装
- Rsyslog configuration and use tutorial
- Interviewer: what is the difference between redis expiration deletion strategy and memory obsolescence strategy?
- 8 expansion sub packages! Recbole launches 2.0!
- Rsyslog配置及使用教程
- 7 月数据库排行榜:MongoDB 和 Oracle 分数下降最多
- "Pre training weekly" issue 52: shielding visual pre training and goal-oriented dialogue
猜你喜欢
随机推荐
[AI system frontier dynamics, issue 40] Hinton: my deep learning career and research mind method; Google refutes rumors and gives up tensorflow; The apotheosis framework is officially open source
Database lock table? Don't panic, this article teaches you how to solve it
XML入门一
The only core indicator of high-quality software architecture
8 expansion sub packages! Recbole launches 2.0!
C#/VB. Net to add text / image watermarks to PDF documents
"Pre training weekly" issue 52: shielding visual pre training and goal-oriented dialogue
Xilinx/system-controller-c/boardui/ unable to connect to the development board, the solution of jamming after arbitrary operation
比量子化学方法快六个数量级,一种基于绝热状态的绝热人工神经网络方法,可加速对偶氮苯衍生物及此类分子的模拟
2022KDD预讲 | 11位一作学者带你提前解锁优秀论文
高效!用虚拟用户搭建FTP工作环境
Is the outdoor LED screen waterproof?
CTF competition problem solution STM32 reverse introduction
Meituan Ali's Application Practice on multimodal recall
"Tips" to slim down Seurat objects
A data person understands and deepens the domain model
爬虫练习题(一)
Alibaba cloud award winning experience: build a highly available system with polardb-x
Reptile exercises (I)
MySQL three-level distribution agent relationship storage