SlideShare une entreprise Scribd logo
1  sur  9
Haproxy
Haproxy
HAProxy is a free, very fast and reliable solution offering
high availability, load balancing, and proxying for TCP and
HTTP-based applications
● high availability
● load balancing
● proxying
Installation
1. download from this
2. tar zxvf haproxy-1.x.x.tar.gz
3. cd haproxy-1.x.x
4. make TARGET=xxx (xxx需要指定OS, linux26)
5. sudo make install
6. copy script to /etc/init.d/haproxy
Configuration
1. /etc/init.d/haproxy
a. CONFIG, HAPROXY
2. /etc/haproxy/haproxy.cfg
a. global 全局配置
b. defaults 默认配置
c. listen admin_stats 统计页面配置
d. listen node_server_in 配置frontend -- 接收请求
e. backend 配置backend -- 处理请求
Configuration
frontend
1. bind # 监听端口
a. bind 0.0.0.0:80
2. acl # access control lists
a. acl dom_example hdr_dom(host) -i example.com
b. acl dom_buy_example hdr_dom(host) -i buy.example.com
c. acl dom_img_example hdr_dom(host) -i img.example.com
d. acl url_course path_beg /course
e. acl ua_mobile hdr_sub(user-agent) -i mobile android iphone ipad ucweb
3. reqirep (rewrite, 不建议使用, 太复杂- -)
a. reqirep
4. use_backend
a. use_backend buy_servers if dom_buy_example ua_mobile
b. use_backend img_servers if dom_img_example
c. use_backend course_servers if dom_example url_course
Configuration
backend
backend buy_servers
balance roundrobin
option httpchk HEAD /heartbeat HTTP/1.1rnHost:www.example.com
errorfile 500 /etc/haproxy/errors/error.http
errorfile 502 /etc/haproxy/errors/error.http
server server1_8080 server1:8080 weight 20 check inter 2000 rise 2 fall 3
server server2_8080 server2:8080 weight 10 check inter 2000 rise 2 fall 3
server server3_8060 server3:8060 weight 5 check backup inter 2000 rise 2 fall 3
P.S: 修改完配置需要reload: /etc/init.d/haproxy reload
Log
1. /var/log/haproxy.log # file path
a. /var/log/haproxy.log.2.gz # cp && gzip -d
2. /etc/logrotate.d/haproxy # logrotate
3. /etc/rsyslog.d/49-haproxy.conf # keep haproxy log out of syslog
4. HTTP log format # doc
Jul 16 11:38:54 localhost haproxy[61457]: 115.54.xxx.8x:39954 [16/Jul/2014:11:38:54.325] node_server_in buy_servers/server1_8080
0/0/1/1/275 200 590 - - ---- 9/9/0/0/0 0/0 "GET /course HTTP/1.1"
[ log time ] [ haproxy pid ] [ user ip ] [ request time ] [ frontend ]
Jul 16 11:28:48 localhost haproxy[61454]: 119.39.3.85:18658 [16/Jul/2014:11:28:48.224] node_server_in
[ backend/server ] [ timer (ms) ] [status code] [ response length] [state]
buy_servers/server1_8080 1/0/0/227/281 200 4896 - - ----
[ connections ] [ queue ] [ method url ]
8/8/1/0/0 0/0 "GET /course HTTP/1.1"
Log
1. Timer Tq / Tw / Tc / Tr / Tt ---- 1/0/0/227/281 5776/0/0/28/6477
a. "Tq" is the total time in milliseconds spent waiting for the client to send a full HTTP request, not
counting data. Large times here generally indicate network trouble between the client and haproxy.
b. "Tw" is the total time in milliseconds spent waiting in the various queues.
c. "Tc" is the total time in milliseconds spent waiting for the connection to establish to the final server,
including retries.
d. "Tr" is the total time in milliseconds spent waiting for the server to send a full HTTP response, not
counting data.
e. "Tt" is the total time in milliseconds elapsed between the accept and the last close.
2. Session state ---- ---- CD-- SH--
a. 1st character: the first event which caused the session to terminate
i. C : the TCP session was unexpectedly aborted by the client.
ii. S : the TCP session was unexpectedly aborted by the server, or the server explicitly refused it.
iii. c : the client-side timeout expired while waiting for the client to send or receive data.
iv. s : the server-side timeout expired while waiting for the server to send or receive data.
v. - : normal session completion, both the client and the server closed with nothing left in the buffers.
b. 2nd character: the TCP or HTTP session state when it was closed
i. D : the session was in the DATA phase.
ii. - : normal session completion after end of data transfer.
Thanks

Contenu connexe

Tendances

HA Deployment Architecture with HAProxy and Keepalived
HA Deployment Architecture with HAProxy and KeepalivedHA Deployment Architecture with HAProxy and Keepalived
HA Deployment Architecture with HAProxy and KeepalivedGanapathi Kandaswamy
 
Prometheus design and philosophy
Prometheus design and philosophy   Prometheus design and philosophy
Prometheus design and philosophy Docker, Inc.
 
Monitoring With Prometheus
Monitoring With PrometheusMonitoring With Prometheus
Monitoring With PrometheusKnoldus Inc.
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX, Inc.
 
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation BuffersHBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation BuffersCloudera, Inc.
 
Nginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptxNginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptxwonyong hwang
 
톰캣 운영 노하우
톰캣 운영 노하우톰캣 운영 노하우
톰캣 운영 노하우jieunsys
 
Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드Ji-Woong Choi
 
NGINX Installation and Tuning
NGINX Installation and TuningNGINX Installation and Tuning
NGINX Installation and TuningNGINX, Inc.
 
Monitoring_with_Prometheus_Grafana_Tutorial
Monitoring_with_Prometheus_Grafana_TutorialMonitoring_with_Prometheus_Grafana_Tutorial
Monitoring_with_Prometheus_Grafana_TutorialTim Vaillancourt
 
Introduction to Prometheus
Introduction to PrometheusIntroduction to Prometheus
Introduction to PrometheusJulien Pivotto
 
Fundamentals of Apache Kafka
Fundamentals of Apache KafkaFundamentals of Apache Kafka
Fundamentals of Apache KafkaChhavi Parasher
 
Exactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache KafkaExactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache Kafkaconfluent
 
APACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsAPACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsKetan Gote
 
Monitoring microservices with Prometheus
Monitoring microservices with PrometheusMonitoring microservices with Prometheus
Monitoring microservices with PrometheusTobias Schmidt
 
Apache Kafka - Martin Podval
Apache Kafka - Martin PodvalApache Kafka - Martin Podval
Apache Kafka - Martin PodvalMartin Podval
 
How Dashtable Helps Dragonfly Maintain Low Latency
How Dashtable Helps Dragonfly Maintain Low LatencyHow Dashtable Helps Dragonfly Maintain Low Latency
How Dashtable Helps Dragonfly Maintain Low LatencyScyllaDB
 

Tendances (20)

HA Deployment Architecture with HAProxy and Keepalived
HA Deployment Architecture with HAProxy and KeepalivedHA Deployment Architecture with HAProxy and Keepalived
HA Deployment Architecture with HAProxy and Keepalived
 
Prometheus design and philosophy
Prometheus design and philosophy   Prometheus design and philosophy
Prometheus design and philosophy
 
Monitoring With Prometheus
Monitoring With PrometheusMonitoring With Prometheus
Monitoring With Prometheus
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best Practices
 
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation BuffersHBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
 
Prometheus monitoring
Prometheus monitoringPrometheus monitoring
Prometheus monitoring
 
Nginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptxNginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptx
 
Monitoring With Prometheus
Monitoring With PrometheusMonitoring With Prometheus
Monitoring With Prometheus
 
톰캣 운영 노하우
톰캣 운영 노하우톰캣 운영 노하우
톰캣 운영 노하우
 
Hashicorp Nomad
Hashicorp NomadHashicorp Nomad
Hashicorp Nomad
 
Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드Scouter와 influx db – grafana 연동 가이드
Scouter와 influx db – grafana 연동 가이드
 
NGINX Installation and Tuning
NGINX Installation and TuningNGINX Installation and Tuning
NGINX Installation and Tuning
 
Monitoring_with_Prometheus_Grafana_Tutorial
Monitoring_with_Prometheus_Grafana_TutorialMonitoring_with_Prometheus_Grafana_Tutorial
Monitoring_with_Prometheus_Grafana_Tutorial
 
Introduction to Prometheus
Introduction to PrometheusIntroduction to Prometheus
Introduction to Prometheus
 
Fundamentals of Apache Kafka
Fundamentals of Apache KafkaFundamentals of Apache Kafka
Fundamentals of Apache Kafka
 
Exactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache KafkaExactly-once Semantics in Apache Kafka
Exactly-once Semantics in Apache Kafka
 
APACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka StreamsAPACHE KAFKA / Kafka Connect / Kafka Streams
APACHE KAFKA / Kafka Connect / Kafka Streams
 
Monitoring microservices with Prometheus
Monitoring microservices with PrometheusMonitoring microservices with Prometheus
Monitoring microservices with Prometheus
 
Apache Kafka - Martin Podval
Apache Kafka - Martin PodvalApache Kafka - Martin Podval
Apache Kafka - Martin Podval
 
How Dashtable Helps Dragonfly Maintain Low Latency
How Dashtable Helps Dragonfly Maintain Low LatencyHow Dashtable Helps Dragonfly Maintain Low Latency
How Dashtable Helps Dragonfly Maintain Low Latency
 

En vedette

HAProxy tech talk
HAProxy tech talkHAProxy tech talk
HAProxy tech talkicebourg
 
How To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - SlidesHow To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - SlidesSeveralnines
 
HA Proxy logs - The Art of Logging
HA Proxy logs - The Art of LoggingHA Proxy logs - The Art of Logging
HA Proxy logs - The Art of Logginglogmatic.io
 
Web Server Load Balancer
Web Server Load BalancerWeb Server Load Balancer
Web Server Load BalancerMobME Technical
 
ChinaNetCloud Training - HAProxy Intro
ChinaNetCloud Training - HAProxy IntroChinaNetCloud Training - HAProxy Intro
ChinaNetCloud Training - HAProxy IntroChinaNetCloud
 
Aniki - The ORM as our great brother.
Aniki - The ORM as our great brother.Aniki - The ORM as our great brother.
Aniki - The ORM as our great brother.karupanerura
 
Load Balancing with Apache
Load Balancing with ApacheLoad Balancing with Apache
Load Balancing with ApacheBradley Holt
 
A travellers guide to leh ladhak
A travellers guide to leh ladhakA travellers guide to leh ladhak
A travellers guide to leh ladhakPriyanka9989
 
Healingherbsandspices 140617021154-phpapp01
Healingherbsandspices 140617021154-phpapp01Healingherbsandspices 140617021154-phpapp01
Healingherbsandspices 140617021154-phpapp01Suzanne Long VonSeggern
 
Sujet Brevet Pondichery 2014
Sujet Brevet Pondichery 2014Sujet Brevet Pondichery 2014
Sujet Brevet Pondichery 2014mlaugel
 
Optimization Direct Inc. at INFORMS Analytics 2015 #analytics2015 #orms #cplex
Optimization Direct Inc. at INFORMS Analytics 2015 #analytics2015 #orms #cplexOptimization Direct Inc. at INFORMS Analytics 2015 #analytics2015 #orms #cplex
Optimization Direct Inc. at INFORMS Analytics 2015 #analytics2015 #orms #cplexoptimizatiodirectdirect
 

En vedette (16)

HAProxy tech talk
HAProxy tech talkHAProxy tech talk
HAProxy tech talk
 
How To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - SlidesHow To Set Up SQL Load Balancing with HAProxy - Slides
How To Set Up SQL Load Balancing with HAProxy - Slides
 
HA Proxy logs - The Art of Logging
HA Proxy logs - The Art of LoggingHA Proxy logs - The Art of Logging
HA Proxy logs - The Art of Logging
 
Web Server Load Balancer
Web Server Load BalancerWeb Server Load Balancer
Web Server Load Balancer
 
ChinaNetCloud Training - HAProxy Intro
ChinaNetCloud Training - HAProxy IntroChinaNetCloud Training - HAProxy Intro
ChinaNetCloud Training - HAProxy Intro
 
Varnish
VarnishVarnish
Varnish
 
Tuning 17 march
Tuning 17 marchTuning 17 march
Tuning 17 march
 
Aniki - The ORM as our great brother.
Aniki - The ORM as our great brother.Aniki - The ORM as our great brother.
Aniki - The ORM as our great brother.
 
Load Balancing with Apache
Load Balancing with ApacheLoad Balancing with Apache
Load Balancing with Apache
 
What's New in HAProxy
What's New in HAProxyWhat's New in HAProxy
What's New in HAProxy
 
A travellers guide to leh ladhak
A travellers guide to leh ladhakA travellers guide to leh ladhak
A travellers guide to leh ladhak
 
Logotipoppt
LogotipopptLogotipoppt
Logotipoppt
 
Healingherbsandspices 140617021154-phpapp01
Healingherbsandspices 140617021154-phpapp01Healingherbsandspices 140617021154-phpapp01
Healingherbsandspices 140617021154-phpapp01
 
Controlling hazards
Controlling hazardsControlling hazards
Controlling hazards
 
Sujet Brevet Pondichery 2014
Sujet Brevet Pondichery 2014Sujet Brevet Pondichery 2014
Sujet Brevet Pondichery 2014
 
Optimization Direct Inc. at INFORMS Analytics 2015 #analytics2015 #orms #cplex
Optimization Direct Inc. at INFORMS Analytics 2015 #analytics2015 #orms #cplexOptimization Direct Inc. at INFORMS Analytics 2015 #analytics2015 #orms #cplex
Optimization Direct Inc. at INFORMS Analytics 2015 #analytics2015 #orms #cplex
 

Similaire à Introduction to Haproxy

Ch 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet ServersCh 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet Serverswebhostingguy
 
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...Ontico
 
Apache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual HostingApache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual Hostingwebhostingguy
 
Time Series Database and Tick Stack
Time Series Database and Tick StackTime Series Database and Tick Stack
Time Series Database and Tick StackGianluca Arbezzano
 
Go 1.8 'new' networking features
Go 1.8 'new' networking featuresGo 1.8 'new' networking features
Go 1.8 'new' networking featuresstrikr .
 
Linux sever building
Linux sever buildingLinux sever building
Linux sever buildingEdmond Yu
 
Curso: Redes y telecomunicaciones: 07 Protoclos TCP/IP
Curso: Redes y telecomunicaciones: 07 Protoclos TCP/IPCurso: Redes y telecomunicaciones: 07 Protoclos TCP/IP
Curso: Redes y telecomunicaciones: 07 Protoclos TCP/IPJack Daniel Cáceres Meza
 
Ngrep commands
Ngrep commandsNgrep commands
Ngrep commandsRishu Seth
 
Juglouvain http revisited
Juglouvain http revisitedJuglouvain http revisited
Juglouvain http revisitedmarctritschler
 
Linux HTTPS/TCP/IP Stack for the Fast and Secure Web
Linux HTTPS/TCP/IP Stack for the Fast and Secure WebLinux HTTPS/TCP/IP Stack for the Fast and Secure Web
Linux HTTPS/TCP/IP Stack for the Fast and Secure WebAll Things Open
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)Ericom Software
 
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA BroadcastNGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA BroadcastNGINX, Inc.
 
Clocking and sync
Clocking and syncClocking and sync
Clocking and syncOded Rotter
 

Similaire à Introduction to Haproxy (20)

Ch 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet ServersCh 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet Servers
 
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
Проксирование HTTP-запросов web-акселератором / Александр Крижановский (Tempe...
 
Apache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual HostingApache web server installation/configuration, Virtual Hosting
Apache web server installation/configuration, Virtual Hosting
 
Time Series Database and Tick Stack
Time Series Database and Tick StackTime Series Database and Tick Stack
Time Series Database and Tick Stack
 
Go 1.8 'new' networking features
Go 1.8 'new' networking featuresGo 1.8 'new' networking features
Go 1.8 'new' networking features
 
Http2
Http2Http2
Http2
 
Linux sever building
Linux sever buildingLinux sever building
Linux sever building
 
Http2 kotlin
Http2   kotlinHttp2   kotlin
Http2 kotlin
 
Curso: Redes y telecomunicaciones: 07 Protoclos TCP/IP
Curso: Redes y telecomunicaciones: 07 Protoclos TCP/IPCurso: Redes y telecomunicaciones: 07 Protoclos TCP/IP
Curso: Redes y telecomunicaciones: 07 Protoclos TCP/IP
 
Ngrep commands
Ngrep commandsNgrep commands
Ngrep commands
 
Juglouvain http revisited
Juglouvain http revisitedJuglouvain http revisited
Juglouvain http revisited
 
Linux HTTPS/TCP/IP Stack for the Fast and Secure Web
Linux HTTPS/TCP/IP Stack for the Fast and Secure WebLinux HTTPS/TCP/IP Stack for the Fast and Secure Web
Linux HTTPS/TCP/IP Stack for the Fast and Secure Web
 
Running php on nginx
Running php on nginxRunning php on nginx
Running php on nginx
 
Cloud Monitoring tool Grafana
Cloud Monitoring  tool Grafana Cloud Monitoring  tool Grafana
Cloud Monitoring tool Grafana
 
Monit
MonitMonit
Monit
 
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
WebSockets Everywhere: the Future Transport Protocol for Everything (Almost)
 
Unit 6 : Application Layer
Unit 6 : Application LayerUnit 6 : Application Layer
Unit 6 : Application Layer
 
NGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA BroadcastNGINX: Basics & Best Practices - EMEA Broadcast
NGINX: Basics & Best Practices - EMEA Broadcast
 
Clocking and sync
Clocking and syncClocking and sync
Clocking and sync
 
Dhcp
DhcpDhcp
Dhcp
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Introduction to Haproxy

  • 2. Haproxy HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications ● high availability ● load balancing ● proxying
  • 3. Installation 1. download from this 2. tar zxvf haproxy-1.x.x.tar.gz 3. cd haproxy-1.x.x 4. make TARGET=xxx (xxx需要指定OS, linux26) 5. sudo make install 6. copy script to /etc/init.d/haproxy
  • 4. Configuration 1. /etc/init.d/haproxy a. CONFIG, HAPROXY 2. /etc/haproxy/haproxy.cfg a. global 全局配置 b. defaults 默认配置 c. listen admin_stats 统计页面配置 d. listen node_server_in 配置frontend -- 接收请求 e. backend 配置backend -- 处理请求
  • 5. Configuration frontend 1. bind # 监听端口 a. bind 0.0.0.0:80 2. acl # access control lists a. acl dom_example hdr_dom(host) -i example.com b. acl dom_buy_example hdr_dom(host) -i buy.example.com c. acl dom_img_example hdr_dom(host) -i img.example.com d. acl url_course path_beg /course e. acl ua_mobile hdr_sub(user-agent) -i mobile android iphone ipad ucweb 3. reqirep (rewrite, 不建议使用, 太复杂- -) a. reqirep 4. use_backend a. use_backend buy_servers if dom_buy_example ua_mobile b. use_backend img_servers if dom_img_example c. use_backend course_servers if dom_example url_course
  • 6. Configuration backend backend buy_servers balance roundrobin option httpchk HEAD /heartbeat HTTP/1.1rnHost:www.example.com errorfile 500 /etc/haproxy/errors/error.http errorfile 502 /etc/haproxy/errors/error.http server server1_8080 server1:8080 weight 20 check inter 2000 rise 2 fall 3 server server2_8080 server2:8080 weight 10 check inter 2000 rise 2 fall 3 server server3_8060 server3:8060 weight 5 check backup inter 2000 rise 2 fall 3 P.S: 修改完配置需要reload: /etc/init.d/haproxy reload
  • 7. Log 1. /var/log/haproxy.log # file path a. /var/log/haproxy.log.2.gz # cp && gzip -d 2. /etc/logrotate.d/haproxy # logrotate 3. /etc/rsyslog.d/49-haproxy.conf # keep haproxy log out of syslog 4. HTTP log format # doc Jul 16 11:38:54 localhost haproxy[61457]: 115.54.xxx.8x:39954 [16/Jul/2014:11:38:54.325] node_server_in buy_servers/server1_8080 0/0/1/1/275 200 590 - - ---- 9/9/0/0/0 0/0 "GET /course HTTP/1.1" [ log time ] [ haproxy pid ] [ user ip ] [ request time ] [ frontend ] Jul 16 11:28:48 localhost haproxy[61454]: 119.39.3.85:18658 [16/Jul/2014:11:28:48.224] node_server_in [ backend/server ] [ timer (ms) ] [status code] [ response length] [state] buy_servers/server1_8080 1/0/0/227/281 200 4896 - - ---- [ connections ] [ queue ] [ method url ] 8/8/1/0/0 0/0 "GET /course HTTP/1.1"
  • 8. Log 1. Timer Tq / Tw / Tc / Tr / Tt ---- 1/0/0/227/281 5776/0/0/28/6477 a. "Tq" is the total time in milliseconds spent waiting for the client to send a full HTTP request, not counting data. Large times here generally indicate network trouble between the client and haproxy. b. "Tw" is the total time in milliseconds spent waiting in the various queues. c. "Tc" is the total time in milliseconds spent waiting for the connection to establish to the final server, including retries. d. "Tr" is the total time in milliseconds spent waiting for the server to send a full HTTP response, not counting data. e. "Tt" is the total time in milliseconds elapsed between the accept and the last close. 2. Session state ---- ---- CD-- SH-- a. 1st character: the first event which caused the session to terminate i. C : the TCP session was unexpectedly aborted by the client. ii. S : the TCP session was unexpectedly aborted by the server, or the server explicitly refused it. iii. c : the client-side timeout expired while waiting for the client to send or receive data. iv. s : the server-side timeout expired while waiting for the server to send or receive data. v. - : normal session completion, both the client and the server closed with nothing left in the buffers. b. 2nd character: the TCP or HTTP session state when it was closed i. D : the session was in the DATA phase. ii. - : normal session completion after end of data transfer.

Notes de l'éditeur

  1. option 如何检查 dolphin.local:9600/onepiece/heartbeat 如果不行,检查dolphin.local 9600对应的进程在不在 ?how ? telnet?
  2. sH server timeout for header