SlideShare a Scribd company logo
1 of 41
Download to read offline
HA Deployment Architecture with HAProxy
By
K Ganapathi, Technical Director, eProcurement Project(GePNIC)
National Informatics Centre
Chennai, India
Agenda
• What is HAProxy?
• Any Alternative to HAProxy?
• Why HAProxy?
• Implementation – HAProxy & Keepalived.
The content of his presentation has been created in
such a way that even the participants who are part of
development team with no or less server
administration work can understand the concept of
High Availability, learn and implement two packages
HAProxy and Keepalived in their production
environment.
What is HAProxy?
• It is a open source, free, fast and easy to configure
solution for implementing
- High Availability
- High Performance-Scale out
- Load Balancing
- DDoS Prevention
Alternate to HAProxy?
• Nginx
• Linux Virtual Server – (LVS)
• AWS Elastic LB
• Varnish
• F5 ….
Alternate to HAProxy?
• Nginx - Can be used as both web server & load balancer (reverse proxy).
• Linux Virtual Server – (LVS) – Very fast, works as layer-4 LB, configuration is
not user friendly.
• AWS Elastic LB - for Amazon Cloud infrastructure users.
• Varnish - Not in much use and activities
• F5 - Hardware LB, costly solution compared to SW LB. Can be installed as
common data centre infrastructure and used by all the co-located
users.
....a long list
Why HAProxy?
• Used by Lot of Industry Majors like Twitter, AO Labs, Airbnb, Adobe
Advt. Cloud, Alibaba, Fedora, GitHub, Kernel.org ...
• Redhat-OpenShift & other Cloud Operators – RedHat openly declares
that it is using HAProxy in their Container and Cloud suits. Other
cloud players are also using HAProxy but don’t declare it in open.
• Any of our neighbours using it ? Yes! – Many of our internal project
teams are using HAProxy over years. Only thing is that there is no
knowledge sharing among the peer groups. In our eProcurement
project we are using it for more than a year now for three of our
portals with high concurrent connections.
Why HAProxy? Contd ..
• Open Source
• Low cost - compared to Costly HW LB
• Easy to configure - when compared to HW LB
• Very Fast
• More Algorithm Option
• Hot reconfiguration
• Can block IPs manually
• Can block IPs automatically based on the hit rate
Implementation – Building a HA Web Server
10.248.2.1
Web Server
(Apache)
User
NAT
164.100.78.1
1. Deployment without High Availability
Implementation – Building a HA Web Server
10.248.2.1
Web Server
(Apache)
User
NAT
164.100.78.1
Stand By
Server
2. Manual Failover Arrangement
Same
Content
Implementation – Building a HA Web Server
Web Server
(Apache)
User
NAT
164.100.78.1
10.248.2.1
Stand By
Server
2. Manual Failover Arrangement
Down
Mannually
Assign IP
10.248.2.1
Can we automate the Failover arrangement?
Implementation – Building a HA Web Server
Implementation – Building a HA Web Server
10.248.2.2
Web Server
Master Node
User
NAT
164.100.78.1
s
3. Automate Failover Arrangement with Keepalived
Up
Keepalived
10.248.2.3
Web Server
Backup Node
Up
Floating IP
10.248.2.1
Keepalived is the router programme written in C.
It uses the Linux Kernel Virtual Server Module.
It has many uses. Here we use it for floating a IP
between two servers automatically based on
their health
Implementation – Building a HA Web Server
10.248.2.2
Web Server
Master Node
User
NAT
164.100.78.1
3. Automate Failover Arrangement with Keepalived
Down
10.248.2.3
Web Server
Backup Node
UpFloating IP
10.248.2.1
Keepalived
Floated the
IP to Backup
Node
Implementation – Building a HA Web Server
Web Server
Master Node
User
NAT
164.100.78.1
Down
Keepalived –
Floated the
IP to Backup
Node
10.248.2.1
Web Server
Backup Node
Up
3. Automate Failover Arrangement with Keepalived
HA – Scaling - Resource Utilisation-
This is a HA deployment architecture
sufficient for portals with low concurrent
connections .
Implementation – Building a HA Web Server
10.248.2.2
Web Server
Node-1
User
NAT
164.100.78.1
4. High availability , High performance , Scale out Architecture with HA Proxy
Up
10.248.2.3
Web Server
Node-2
UpHAProxy Server
LB
10.248.2.1
Round Robin, Static Round Robin,
Least Connection, Source, URI,
URL Parameter
10.248.2.2
Web Server
Node-1
User
NAT
164.100.78.1 Down
10.248.2.3
Web Server
Node-2
UpHAProxy Server
LB
10.248.2.1 X
Is this a True HA
Architecture?
Implementation – Building a HA Web Server
Implementation – Building a HA Web Server
10.248.2.2
Web Server
Node-1
User
NAT
164.100.78.1
UP
10.248.2.3
Web Server
Node-2
UpHAProxy Server
LB
10.248.2.1
DownX
It is not a True HA Architecture. If the HAProxy server is
down then your portal is down on this single failure.
So, How to ensure HA for HAProxy itself?
10.248.2.4
Node-1
User
NAT
164.100.78.1
10.248.2.5
Node-2
HAProxy Server
Master Node LB
Implementation – Building a HA Web Server
HAProxy Server
Backup Node
Keepalived
Keepalived
5. High availability , High performance , Scale out Architecture with HA Proxy
10.248.2.6
Node-3
Rsync,
lsyncd,
or
NFS,
GFS,
GlusterFS,
Object
Storage
10.248.2.3
10.248.2.2
How to ensure HA for HAProxy itself? – Use Keepalived.
10.248.2.4
Node-1
User
164.100.78.1
10.248.2.5
Node-2
HAProxy Server
Master Node LB
Implementation – Building a HA Web Server
HAProxy Server
Backup Node
Keepalived floated
the IP to backup
node
Keepalived
5. High availability , High performance , Scale out Architecture with HA Proxy
10.248.2.6
Node-3
Rsync,
lsyncd,
or
NFS,
GFS,
GlusterFS,
Object
Storage
10.248.2.3
10.248.2.2 - DOWN
How to ensure HA for HAProxy itself? – Use Keepalived.
X
10.248.2.4
Node-1
10.248.2.5
Node-2
HAProxy Server
Master Node
HAProxy-Keepalived– Installation
HAProxy Server
Backup Node
6. System Prerequisite (our environment)
10.248.2.6
Node-3
Rsync,
lsyncd,
or
NFS,
GFS,
GlusterFS,
Object
Storage
10.248.2.3
1. OS – RHEL 7.3
2. Install keepalived (rpm)
3. Install HAProxy (Compile)
10.248.2.2
HAProxy-Keepalived– Installation
7. Installation Steps
1. Install and enable keepalived daemon in 2 HAProxy Nodes
2. To create Virtual IP (Floating IP) 10.248.2.1 between the HAproxy Nodes – Using
keepalived.
3. Compile haproxy from source with TPROXY enabled.
4. Configure haproxy in both the nodes. Also do the dependent FW and IP routing
in both the nodes.
5. Change the gateway of Web-Sever1/2/3/ to Virtual IP (10.248.2.1)
6. Change the access log configuration on the web-server1 & web-server2 to
capture client IP through X-Forwarded-For parameter.
7. Start haproxy & Keepalived.
HAProxy-Keepalived– Installation
7. Keepalived
#rpm –ivh keepalived-1.2.13-8.el7.x86_64 <- in Both HAProxy Servers
#vi /etc/keepalived/keepalived.conf <-in HAProxy Node1
vrrp_script chk_haproxy {
script "killall -0 haproxy" # check the haproxy process
interval 2 # every 2 seconds
weight 2 # add 2 points if OK
}
vrrp_instance VI_1 {
interface eno49
state MASTER
virtual_router_id 51
priority 101
authentication {
auth_type PASS
auth_pass PassWord123$
}
virtual_ipaddress {
10.248.2.1 # virtual ip address
}
track_script {
chk_haproxy
}
}
HAProxy Server
Master Node
10.248.2.2
HAProxy-Keepalived– Installation Contd..
7. Keepalived
#vi /etc/keepalived/keepalived.conf <-in HAProxy Node2
vrrp_script chk_haproxy {
script "killall -0 haproxy" # check the haproxy process
interval 2 # every 2 seconds
weight 2 # add 2 points if OK
}
vrrp_instance VI_1 {
interface eno49
state BACKUP
virtual_router_id 51
priority 100
authentication {
auth_type PASS
auth_pass PassWord123$
}
virtual_ipaddress {
10.248.2.1 # virtual ip address
}
track_script {
chk_haproxy
}
}
HAProxy Server
Backup Node
10.248.2.3
HAProxy-Keepalived– Installation Contd..
7. Keepalived
Start the keepalived services in both the HAProxy nodes.
#systemctl enable keepalived.service
#systemctl start keepalived.service
Now #ssh root@10.248.2.1 <- It will connect to Master
node
HAProxy-Keepalived– Installation Contd..
7. Keepalived
How to confirm that the IP 10.248.2.1 is floating between the nodes?
Now both the HAProxy nodes 10.248.2.2 & 10.248.2.3 are up and running.
Now #ssh root@10.248.2.1 <- It will connect to Master
node (10.248.2.2).
Now down the server with IP 10.248.2.2.
again #ssh root@10.248.2.1 <- Now it will connect to backup node
(10.248.2.3).
If the master node 10.248.2.2 is up, then the IP 10.248.2.1 will be floated to
this master node.
HAProxy-Keepalived– Installation Contd..
7. HAProxy Installation
Download haproxy latest stable version 1.7.8 from ;
http://www.haproxy.org/download/1.7/src/haproxy-
1.7.8.tar.gz
Copy haproxy-1.7.8.tar.gz to haproxy-node1 & haproxy-node2
/usr/local/ directory.
At haproxy-node1 ;
# cd /usr/local/
# tar xvfz haproxy-1.7.8.tar.gz
# cd haproxy-1.7.8
HAProxy-Keepalived– Installation Contd..
7. HAProxy Installation
# make TARGET=linux2628 CPU=native USE_PCRE=1 USE_LIBCRYPT=1
USE_LINUX_SPLICE=1 USE_LINUX_TPROXY=1
# make install target=linux2628
Now haproxy binary was installed in /usr/local/sbin/
Give a soft link to /usr/sbin also;
# ln -s /usr/local/sbin/haproxy /usr/sbin
Now copy the haproxy startup script to /etc/init.d
# scp examples/haproxy.init /etc/init.d/haproxy
HAProxy-Keepalived– Installation Contd..
7. HAProxy Configuration
# vi /etc/haproxy/haproxy.cfg and replace it with the following content.
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 40000
user root
group root
daemon
stats socket /var/lib/haproxy/stats
HAProxy-Keepalived– Installation Contd..
7. HAProxy Configuration
defaults
mode http
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
HAProxy-Keepalived– Installation Contd..
7. HAProxy Configuration
frontend myweb-http-frend
bind 10.248.2.1:80 transparent
mode http
option httplog
default_backend myweb-http-bkend
backend myweb-http-bkend
mode http
balance source
cookie SERVERID insert indirect nocache
server webserv1 10.248.2.4:80 check
server webserv2 10.248.2.5:80 check
server webserv3 10.248.2.6:80 check
HAProxy-Keepalived– Installation Contd..
7. HAProxy Configuration
#vi /etc/sysctl.conf
net.ipv4.conf.all.rp_filter=0
net.ipv4.ip_forward=1
net.ipv4.conf.all.forwarding=1
net.ipv4.conf.all.send_redirects=1
net.ipv4.conf.eno49.send_redirects=1
net.ipv4.conf.eno49.rp_filter=0
net.ipv4.conf.eno50.rp_filter=0
load the above entries without reboot ;
# sysctl -p
HAProxy-Keepalived– Installation Contd..
7. HAProxy Configuration
Change the gateway of web servers to VIP:
10.248.2.1
#vi /etc/sysconfig/network-scripts/ifcfg-eno49
GATEWAY=10.248.2.1
HAProxy-Keepalived– Installation Contd..
Change the access log configuration on the web-server1 , web-server2 and web-
server3 to capture client IP through X-Forwarded-For parameter.
On all the web servers ie. 10.248.2.4 , 10.248.2.5 & 10.248.2.6 change access log
configuration as follow;
# vi /usr/local/apache/httpd.conf
HAProxy-Keepalived– Installation Contd..
SetEnvIf X-Forwarded-For "^.*..*..*..*" forwarded
LogFormat "%{X-Forwarded-For}i %l %u %t "%r" %>s %b "%{Referer}i" "%{User-
Agent}i"" proxy
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i""
combined
CustomLog "|/bin/sh -c '/usr/bin/tee -a /var/log/apache/access_log |
/usr/bin/logger -thttpd -plocal6.notice'" combined env=!forwarded
CustomLog "|/bin/sh -c '/usr/bin/tee -a /var/log/apache/access_log |
/usr/bin/logger -thttpd -plocal6.notice'" proxy env=forwarded
#/etc/init.d/apachectl restart
10.248.2.4
Node-1
User
NAT
164.100.78.1
10.248.2.5
Node-2
HAProxy Server
Master Node LB
Testing the Configuration
HAProxy Server
Backup Node
Keepalived
Keepalived
8. Testing
10.248.2.6
Node-3
Rsync,
lsyncd,
or
NFS,
GFS,
GlusterFS,
Object
Storage
10.248.2.3
10.248.2.2
Extra Bytes
• Load balancers works on reverse proxy concept.
• There are two type of Load balancers – layer-4 and layer-7 Load
balancers.
• If a LB does the load balancing by acting on the data available at
Layer-4 of OSI – Network Model(Network/Transport Layer), then it
is layer-4 LB. Here LB will be done based on IP, Ports, etc.
• If a LB does the load balancing by acting on the data available at
Layer-7 (Application Layer) then it is layer-7 LB. The LB will be done
based on content in the URL. Ex: ‘http://...../reports’ can be
directed to particular servers.
• Keepalived works on VRRP – Virtual Router Redundancy Protocol.
Extra Bytes – Contd..
• We can block IPs (causing DDoS) in HAProxy itself instead
blocking at web server ;
tcp-request connection reject if { src -f
/etc/haproxy/blacklist.txt
• Can configure HAProxy to automatically block IPs based on
hit rate;
acl conn_rate_abuse sc2_conn_rate gt 5
tcp-request content reject if conn_rate_abuse
Credits
Thanks to
• Mr. Willy Tarreau, who still maintains the HAProxy project and
a core contributor to Linux kernel.
• Team of keepalived.org, working on sponsored funds to give
keepalived to industry, which is being widely used in large
data centre infrastructure and cloud products.
• RedHat for helping me in PoC.
• Our GePNIC (eProcurement) DC Support team for helping me
in PoC and taking HAProxy to production.
HAProxy-Keepalived– References
References:
 https://www.loadbalancer.org/blog/configure-haproxy-with-tproxy-
kernel-for-full-transparent-proxy/
 https://ubuntuforums.org/archive/index.php/t-2168372.html
 /usr/local/haproxy-1.7.8/README
 http://www.keepalived.org/
 Live configuration files being used in eProcurement Project.
Thank you ….
K Ganapathi
Technical Director
eProcurement Project(GePNIC)
National Informatics Centre
Chennai, India
kganapathi@nic.in

More Related Content

What's hot

Kubernetes Helm: Why It Matters
Kubernetes Helm: Why It MattersKubernetes Helm: Why It Matters
Kubernetes Helm: Why It MattersPlatform9
 
Introduction to Haproxy
Introduction to HaproxyIntroduction to Haproxy
Introduction to HaproxyShaopeng He
 
Rancher and Kubernetes Best Practices
Rancher and  Kubernetes Best PracticesRancher and  Kubernetes Best Practices
Rancher and Kubernetes Best PracticesAvinash Patil
 
Rootless Containers & Unresolved issues
Rootless Containers & Unresolved issuesRootless Containers & Unresolved issues
Rootless Containers & Unresolved issuesAkihiro Suda
 
오픈스택 멀티노드 설치 후기
오픈스택 멀티노드 설치 후기오픈스택 멀티노드 설치 후기
오픈스택 멀티노드 설치 후기영우 김
 
OpenvSwitch Deep Dive
OpenvSwitch Deep DiveOpenvSwitch Deep Dive
OpenvSwitch Deep Diverajdeep
 
Cloud stack vs openstack vs eucalyptus
Cloud stack vs openstack vs eucalyptusCloud stack vs openstack vs eucalyptus
Cloud stack vs openstack vs eucalyptusAshok Kumar
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansibleKhizer Naeem
 
오픈스택: 구석구석 파헤쳐보기
오픈스택: 구석구석 파헤쳐보기오픈스택: 구석구석 파헤쳐보기
오픈스택: 구석구석 파헤쳐보기Jaehwa Park
 
Hashicorp Vault Open Source vs Enterprise
Hashicorp Vault Open Source vs EnterpriseHashicorp Vault Open Source vs Enterprise
Hashicorp Vault Open Source vs EnterpriseStenio Ferreira
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes NetworkingCJ Cullen
 
Kubernetes & helm 활용
Kubernetes & helm 활용Kubernetes & helm 활용
Kubernetes & helm 활용SK Telecom
 
Hadoop Security Today & Tomorrow with Apache Knox
Hadoop Security Today & Tomorrow with Apache KnoxHadoop Security Today & Tomorrow with Apache Knox
Hadoop Security Today & Tomorrow with Apache KnoxVinay Shukla
 
pfSense presentation
pfSense presentationpfSense presentation
pfSense presentationSimon Vass
 
A crash course in CRUSH
A crash course in CRUSHA crash course in CRUSH
A crash course in CRUSHSage Weil
 
Kvm and libvirt
Kvm and libvirtKvm and libvirt
Kvm and libvirtplarsen67
 

What's hot (20)

Kubernetes Helm: Why It Matters
Kubernetes Helm: Why It MattersKubernetes Helm: Why It Matters
Kubernetes Helm: Why It Matters
 
Introduction to Haproxy
Introduction to HaproxyIntroduction to Haproxy
Introduction to Haproxy
 
Rancher and Kubernetes Best Practices
Rancher and  Kubernetes Best PracticesRancher and  Kubernetes Best Practices
Rancher and Kubernetes Best Practices
 
Rootless Containers & Unresolved issues
Rootless Containers & Unresolved issuesRootless Containers & Unresolved issues
Rootless Containers & Unresolved issues
 
오픈스택 멀티노드 설치 후기
오픈스택 멀티노드 설치 후기오픈스택 멀티노드 설치 후기
오픈스택 멀티노드 설치 후기
 
OpenvSwitch Deep Dive
OpenvSwitch Deep DiveOpenvSwitch Deep Dive
OpenvSwitch Deep Dive
 
Meetup 23 - 02 - OVN - The future of networking in OpenStack
Meetup 23 - 02 - OVN - The future of networking in OpenStackMeetup 23 - 02 - OVN - The future of networking in OpenStack
Meetup 23 - 02 - OVN - The future of networking in OpenStack
 
Cloud stack vs openstack vs eucalyptus
Cloud stack vs openstack vs eucalyptusCloud stack vs openstack vs eucalyptus
Cloud stack vs openstack vs eucalyptus
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
오픈스택: 구석구석 파헤쳐보기
오픈스택: 구석구석 파헤쳐보기오픈스택: 구석구석 파헤쳐보기
오픈스택: 구석구석 파헤쳐보기
 
Hashicorp Vault Open Source vs Enterprise
Hashicorp Vault Open Source vs EnterpriseHashicorp Vault Open Source vs Enterprise
Hashicorp Vault Open Source vs Enterprise
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes Networking
 
Kubernetes & helm 활용
Kubernetes & helm 활용Kubernetes & helm 활용
Kubernetes & helm 활용
 
Terraform
TerraformTerraform
Terraform
 
Hadoop Security Today & Tomorrow with Apache Knox
Hadoop Security Today & Tomorrow with Apache KnoxHadoop Security Today & Tomorrow with Apache Knox
Hadoop Security Today & Tomorrow with Apache Knox
 
pfSense presentation
pfSense presentationpfSense presentation
pfSense presentation
 
A crash course in CRUSH
A crash course in CRUSHA crash course in CRUSH
A crash course in CRUSH
 
The kvm virtualization way
The kvm virtualization wayThe kvm virtualization way
The kvm virtualization way
 
Community Openstack 구축 사례
Community Openstack 구축 사례Community Openstack 구축 사례
Community Openstack 구축 사례
 
Kvm and libvirt
Kvm and libvirtKvm and libvirt
Kvm and libvirt
 

Similar to HA Deployment Architecture with HAProxy and Keepalived

HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...Edward Burns
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefAll Things Open
 
Micro services vs hadoop
Micro services vs hadoopMicro services vs hadoop
Micro services vs hadoopGergely Devenyi
 
The Big Cloud native FaaS Lebowski
The Big Cloud native FaaS Lebowski The Big Cloud native FaaS Lebowski
The Big Cloud native FaaS Lebowski QAware GmbH
 
What’s new in Nuxeo 5.2?
What’s new in Nuxeo 5.2?What’s new in Nuxeo 5.2?
What’s new in Nuxeo 5.2?Nuxeo
 
final proposal-Xen based Hypervisor in a Box
final proposal-Xen based Hypervisor in a Boxfinal proposal-Xen based Hypervisor in a Box
final proposal-Xen based Hypervisor in a BoxParamkusham Shruthi
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefNathen Harvey
 
Big data with hadoop Setup on Ubuntu 12.04
Big data with hadoop Setup on Ubuntu 12.04Big data with hadoop Setup on Ubuntu 12.04
Big data with hadoop Setup on Ubuntu 12.04Mandakini Kumari
 
HAProxy scale out using open source
HAProxy scale out using open sourceHAProxy scale out using open source
HAProxy scale out using open sourceIngo Walz
 
High-Performance FAAS with Nuclio
High-Performance FAAS with NuclioHigh-Performance FAAS with Nuclio
High-Performance FAAS with NuclioQAware GmbH
 
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...Kevin Minder
 
What’s New in NGINX Plus R16? – EMEA
What’s New in NGINX Plus R16? – EMEAWhat’s New in NGINX Plus R16? – EMEA
What’s New in NGINX Plus R16? – EMEANGINX, Inc.
 
FreeSWITCH on Docker
FreeSWITCH on DockerFreeSWITCH on Docker
FreeSWITCH on Docker建澄 吳
 
Bhushan m dev_ops_engr_31june
Bhushan m dev_ops_engr_31juneBhushan m dev_ops_engr_31june
Bhushan m dev_ops_engr_31juneBhushan Mahajan
 
The Big Cloud Native FaaS Lebowski
The Big Cloud Native FaaS LebowskiThe Big Cloud Native FaaS Lebowski
The Big Cloud Native FaaS LebowskiQAware GmbH
 
PHPIDOL#80: Kubernetes 101 for PHP Developer. Yusuf Hadiwinata - VP Operation...
PHPIDOL#80: Kubernetes 101 for PHP Developer. Yusuf Hadiwinata - VP Operation...PHPIDOL#80: Kubernetes 101 for PHP Developer. Yusuf Hadiwinata - VP Operation...
PHPIDOL#80: Kubernetes 101 for PHP Developer. Yusuf Hadiwinata - VP Operation...Yusuf Hadiwinata Sutandar
 
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin JonesITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin JonesOrtus Solutions, Corp
 
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, OrchestrationThe Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, OrchestrationErica Windisch
 
OpenContrail deployment experience
OpenContrail deployment experienceOpenContrail deployment experience
OpenContrail deployment experienceJakub Pavlik
 

Similar to HA Deployment Architecture with HAProxy and Keepalived (20)

HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
Micro services vs hadoop
Micro services vs hadoopMicro services vs hadoop
Micro services vs hadoop
 
The Big Cloud native FaaS Lebowski
The Big Cloud native FaaS Lebowski The Big Cloud native FaaS Lebowski
The Big Cloud native FaaS Lebowski
 
What’s new in Nuxeo 5.2?
What’s new in Nuxeo 5.2?What’s new in Nuxeo 5.2?
What’s new in Nuxeo 5.2?
 
final proposal-Xen based Hypervisor in a Box
final proposal-Xen based Hypervisor in a Boxfinal proposal-Xen based Hypervisor in a Box
final proposal-Xen based Hypervisor in a Box
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
Big data with hadoop Setup on Ubuntu 12.04
Big data with hadoop Setup on Ubuntu 12.04Big data with hadoop Setup on Ubuntu 12.04
Big data with hadoop Setup on Ubuntu 12.04
 
HAProxy scale out using open source
HAProxy scale out using open sourceHAProxy scale out using open source
HAProxy scale out using open source
 
High-Performance FAAS with Nuclio
High-Performance FAAS with NuclioHigh-Performance FAAS with Nuclio
High-Performance FAAS with Nuclio
 
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
Securing Hadoop's REST APIs with Apache Knox Gateway Hadoop Summit June 6th, ...
 
What’s New in NGINX Plus R16? – EMEA
What’s New in NGINX Plus R16? – EMEAWhat’s New in NGINX Plus R16? – EMEA
What’s New in NGINX Plus R16? – EMEA
 
FreeSWITCH on Docker
FreeSWITCH on DockerFreeSWITCH on Docker
FreeSWITCH on Docker
 
FreeSWITCH on Docker
FreeSWITCH on DockerFreeSWITCH on Docker
FreeSWITCH on Docker
 
Bhushan m dev_ops_engr_31june
Bhushan m dev_ops_engr_31juneBhushan m dev_ops_engr_31june
Bhushan m dev_ops_engr_31june
 
The Big Cloud Native FaaS Lebowski
The Big Cloud Native FaaS LebowskiThe Big Cloud Native FaaS Lebowski
The Big Cloud Native FaaS Lebowski
 
PHPIDOL#80: Kubernetes 101 for PHP Developer. Yusuf Hadiwinata - VP Operation...
PHPIDOL#80: Kubernetes 101 for PHP Developer. Yusuf Hadiwinata - VP Operation...PHPIDOL#80: Kubernetes 101 for PHP Developer. Yusuf Hadiwinata - VP Operation...
PHPIDOL#80: Kubernetes 101 for PHP Developer. Yusuf Hadiwinata - VP Operation...
 
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin JonesITB2019 NGINX Overview and Technical Aspects - Kevin Jones
ITB2019 NGINX Overview and Technical Aspects - Kevin Jones
 
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, OrchestrationThe Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
 
OpenContrail deployment experience
OpenContrail deployment experienceOpenContrail deployment experience
OpenContrail deployment experience
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 

HA Deployment Architecture with HAProxy and Keepalived

  • 1. HA Deployment Architecture with HAProxy By K Ganapathi, Technical Director, eProcurement Project(GePNIC) National Informatics Centre Chennai, India
  • 2. Agenda • What is HAProxy? • Any Alternative to HAProxy? • Why HAProxy? • Implementation – HAProxy & Keepalived.
  • 3. The content of his presentation has been created in such a way that even the participants who are part of development team with no or less server administration work can understand the concept of High Availability, learn and implement two packages HAProxy and Keepalived in their production environment.
  • 4. What is HAProxy? • It is a open source, free, fast and easy to configure solution for implementing - High Availability - High Performance-Scale out - Load Balancing - DDoS Prevention
  • 5. Alternate to HAProxy? • Nginx • Linux Virtual Server – (LVS) • AWS Elastic LB • Varnish • F5 ….
  • 6. Alternate to HAProxy? • Nginx - Can be used as both web server & load balancer (reverse proxy). • Linux Virtual Server – (LVS) – Very fast, works as layer-4 LB, configuration is not user friendly. • AWS Elastic LB - for Amazon Cloud infrastructure users. • Varnish - Not in much use and activities • F5 - Hardware LB, costly solution compared to SW LB. Can be installed as common data centre infrastructure and used by all the co-located users. ....a long list
  • 7. Why HAProxy? • Used by Lot of Industry Majors like Twitter, AO Labs, Airbnb, Adobe Advt. Cloud, Alibaba, Fedora, GitHub, Kernel.org ... • Redhat-OpenShift & other Cloud Operators – RedHat openly declares that it is using HAProxy in their Container and Cloud suits. Other cloud players are also using HAProxy but don’t declare it in open. • Any of our neighbours using it ? Yes! – Many of our internal project teams are using HAProxy over years. Only thing is that there is no knowledge sharing among the peer groups. In our eProcurement project we are using it for more than a year now for three of our portals with high concurrent connections.
  • 8. Why HAProxy? Contd .. • Open Source • Low cost - compared to Costly HW LB • Easy to configure - when compared to HW LB • Very Fast • More Algorithm Option • Hot reconfiguration • Can block IPs manually • Can block IPs automatically based on the hit rate
  • 9. Implementation – Building a HA Web Server 10.248.2.1 Web Server (Apache) User NAT 164.100.78.1 1. Deployment without High Availability
  • 10. Implementation – Building a HA Web Server 10.248.2.1 Web Server (Apache) User NAT 164.100.78.1 Stand By Server 2. Manual Failover Arrangement Same Content
  • 11. Implementation – Building a HA Web Server Web Server (Apache) User NAT 164.100.78.1 10.248.2.1 Stand By Server 2. Manual Failover Arrangement Down Mannually Assign IP 10.248.2.1
  • 12. Can we automate the Failover arrangement? Implementation – Building a HA Web Server
  • 13. Implementation – Building a HA Web Server 10.248.2.2 Web Server Master Node User NAT 164.100.78.1 s 3. Automate Failover Arrangement with Keepalived Up Keepalived 10.248.2.3 Web Server Backup Node Up Floating IP 10.248.2.1 Keepalived is the router programme written in C. It uses the Linux Kernel Virtual Server Module. It has many uses. Here we use it for floating a IP between two servers automatically based on their health
  • 14. Implementation – Building a HA Web Server 10.248.2.2 Web Server Master Node User NAT 164.100.78.1 3. Automate Failover Arrangement with Keepalived Down 10.248.2.3 Web Server Backup Node UpFloating IP 10.248.2.1 Keepalived Floated the IP to Backup Node
  • 15. Implementation – Building a HA Web Server Web Server Master Node User NAT 164.100.78.1 Down Keepalived – Floated the IP to Backup Node 10.248.2.1 Web Server Backup Node Up 3. Automate Failover Arrangement with Keepalived HA – Scaling - Resource Utilisation- This is a HA deployment architecture sufficient for portals with low concurrent connections .
  • 16. Implementation – Building a HA Web Server 10.248.2.2 Web Server Node-1 User NAT 164.100.78.1 4. High availability , High performance , Scale out Architecture with HA Proxy Up 10.248.2.3 Web Server Node-2 UpHAProxy Server LB 10.248.2.1 Round Robin, Static Round Robin, Least Connection, Source, URI, URL Parameter
  • 17. 10.248.2.2 Web Server Node-1 User NAT 164.100.78.1 Down 10.248.2.3 Web Server Node-2 UpHAProxy Server LB 10.248.2.1 X Is this a True HA Architecture? Implementation – Building a HA Web Server
  • 18. Implementation – Building a HA Web Server 10.248.2.2 Web Server Node-1 User NAT 164.100.78.1 UP 10.248.2.3 Web Server Node-2 UpHAProxy Server LB 10.248.2.1 DownX It is not a True HA Architecture. If the HAProxy server is down then your portal is down on this single failure. So, How to ensure HA for HAProxy itself?
  • 19. 10.248.2.4 Node-1 User NAT 164.100.78.1 10.248.2.5 Node-2 HAProxy Server Master Node LB Implementation – Building a HA Web Server HAProxy Server Backup Node Keepalived Keepalived 5. High availability , High performance , Scale out Architecture with HA Proxy 10.248.2.6 Node-3 Rsync, lsyncd, or NFS, GFS, GlusterFS, Object Storage 10.248.2.3 10.248.2.2 How to ensure HA for HAProxy itself? – Use Keepalived.
  • 20. 10.248.2.4 Node-1 User 164.100.78.1 10.248.2.5 Node-2 HAProxy Server Master Node LB Implementation – Building a HA Web Server HAProxy Server Backup Node Keepalived floated the IP to backup node Keepalived 5. High availability , High performance , Scale out Architecture with HA Proxy 10.248.2.6 Node-3 Rsync, lsyncd, or NFS, GFS, GlusterFS, Object Storage 10.248.2.3 10.248.2.2 - DOWN How to ensure HA for HAProxy itself? – Use Keepalived. X
  • 21. 10.248.2.4 Node-1 10.248.2.5 Node-2 HAProxy Server Master Node HAProxy-Keepalived– Installation HAProxy Server Backup Node 6. System Prerequisite (our environment) 10.248.2.6 Node-3 Rsync, lsyncd, or NFS, GFS, GlusterFS, Object Storage 10.248.2.3 1. OS – RHEL 7.3 2. Install keepalived (rpm) 3. Install HAProxy (Compile) 10.248.2.2
  • 22. HAProxy-Keepalived– Installation 7. Installation Steps 1. Install and enable keepalived daemon in 2 HAProxy Nodes 2. To create Virtual IP (Floating IP) 10.248.2.1 between the HAproxy Nodes – Using keepalived. 3. Compile haproxy from source with TPROXY enabled. 4. Configure haproxy in both the nodes. Also do the dependent FW and IP routing in both the nodes. 5. Change the gateway of Web-Sever1/2/3/ to Virtual IP (10.248.2.1) 6. Change the access log configuration on the web-server1 & web-server2 to capture client IP through X-Forwarded-For parameter. 7. Start haproxy & Keepalived.
  • 23. HAProxy-Keepalived– Installation 7. Keepalived #rpm –ivh keepalived-1.2.13-8.el7.x86_64 <- in Both HAProxy Servers #vi /etc/keepalived/keepalived.conf <-in HAProxy Node1 vrrp_script chk_haproxy { script "killall -0 haproxy" # check the haproxy process interval 2 # every 2 seconds weight 2 # add 2 points if OK } vrrp_instance VI_1 { interface eno49 state MASTER virtual_router_id 51 priority 101 authentication { auth_type PASS auth_pass PassWord123$ } virtual_ipaddress { 10.248.2.1 # virtual ip address } track_script { chk_haproxy } } HAProxy Server Master Node 10.248.2.2
  • 24. HAProxy-Keepalived– Installation Contd.. 7. Keepalived #vi /etc/keepalived/keepalived.conf <-in HAProxy Node2 vrrp_script chk_haproxy { script "killall -0 haproxy" # check the haproxy process interval 2 # every 2 seconds weight 2 # add 2 points if OK } vrrp_instance VI_1 { interface eno49 state BACKUP virtual_router_id 51 priority 100 authentication { auth_type PASS auth_pass PassWord123$ } virtual_ipaddress { 10.248.2.1 # virtual ip address } track_script { chk_haproxy } } HAProxy Server Backup Node 10.248.2.3
  • 25. HAProxy-Keepalived– Installation Contd.. 7. Keepalived Start the keepalived services in both the HAProxy nodes. #systemctl enable keepalived.service #systemctl start keepalived.service Now #ssh root@10.248.2.1 <- It will connect to Master node
  • 26. HAProxy-Keepalived– Installation Contd.. 7. Keepalived How to confirm that the IP 10.248.2.1 is floating between the nodes? Now both the HAProxy nodes 10.248.2.2 & 10.248.2.3 are up and running. Now #ssh root@10.248.2.1 <- It will connect to Master node (10.248.2.2). Now down the server with IP 10.248.2.2. again #ssh root@10.248.2.1 <- Now it will connect to backup node (10.248.2.3). If the master node 10.248.2.2 is up, then the IP 10.248.2.1 will be floated to this master node.
  • 27. HAProxy-Keepalived– Installation Contd.. 7. HAProxy Installation Download haproxy latest stable version 1.7.8 from ; http://www.haproxy.org/download/1.7/src/haproxy- 1.7.8.tar.gz Copy haproxy-1.7.8.tar.gz to haproxy-node1 & haproxy-node2 /usr/local/ directory. At haproxy-node1 ; # cd /usr/local/ # tar xvfz haproxy-1.7.8.tar.gz # cd haproxy-1.7.8
  • 28. HAProxy-Keepalived– Installation Contd.. 7. HAProxy Installation # make TARGET=linux2628 CPU=native USE_PCRE=1 USE_LIBCRYPT=1 USE_LINUX_SPLICE=1 USE_LINUX_TPROXY=1 # make install target=linux2628 Now haproxy binary was installed in /usr/local/sbin/ Give a soft link to /usr/sbin also; # ln -s /usr/local/sbin/haproxy /usr/sbin Now copy the haproxy startup script to /etc/init.d # scp examples/haproxy.init /etc/init.d/haproxy
  • 29. HAProxy-Keepalived– Installation Contd.. 7. HAProxy Configuration # vi /etc/haproxy/haproxy.cfg and replace it with the following content. global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 40000 user root group root daemon stats socket /var/lib/haproxy/stats
  • 30. HAProxy-Keepalived– Installation Contd.. 7. HAProxy Configuration defaults mode http timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s
  • 31. HAProxy-Keepalived– Installation Contd.. 7. HAProxy Configuration frontend myweb-http-frend bind 10.248.2.1:80 transparent mode http option httplog default_backend myweb-http-bkend backend myweb-http-bkend mode http balance source cookie SERVERID insert indirect nocache server webserv1 10.248.2.4:80 check server webserv2 10.248.2.5:80 check server webserv3 10.248.2.6:80 check
  • 32. HAProxy-Keepalived– Installation Contd.. 7. HAProxy Configuration #vi /etc/sysctl.conf net.ipv4.conf.all.rp_filter=0 net.ipv4.ip_forward=1 net.ipv4.conf.all.forwarding=1 net.ipv4.conf.all.send_redirects=1 net.ipv4.conf.eno49.send_redirects=1 net.ipv4.conf.eno49.rp_filter=0 net.ipv4.conf.eno50.rp_filter=0 load the above entries without reboot ; # sysctl -p
  • 33. HAProxy-Keepalived– Installation Contd.. 7. HAProxy Configuration Change the gateway of web servers to VIP: 10.248.2.1 #vi /etc/sysconfig/network-scripts/ifcfg-eno49 GATEWAY=10.248.2.1
  • 34. HAProxy-Keepalived– Installation Contd.. Change the access log configuration on the web-server1 , web-server2 and web- server3 to capture client IP through X-Forwarded-For parameter. On all the web servers ie. 10.248.2.4 , 10.248.2.5 & 10.248.2.6 change access log configuration as follow; # vi /usr/local/apache/httpd.conf
  • 35. HAProxy-Keepalived– Installation Contd.. SetEnvIf X-Forwarded-For "^.*..*..*..*" forwarded LogFormat "%{X-Forwarded-For}i %l %u %t "%r" %>s %b "%{Referer}i" "%{User- Agent}i"" proxy LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined CustomLog "|/bin/sh -c '/usr/bin/tee -a /var/log/apache/access_log | /usr/bin/logger -thttpd -plocal6.notice'" combined env=!forwarded CustomLog "|/bin/sh -c '/usr/bin/tee -a /var/log/apache/access_log | /usr/bin/logger -thttpd -plocal6.notice'" proxy env=forwarded #/etc/init.d/apachectl restart
  • 36. 10.248.2.4 Node-1 User NAT 164.100.78.1 10.248.2.5 Node-2 HAProxy Server Master Node LB Testing the Configuration HAProxy Server Backup Node Keepalived Keepalived 8. Testing 10.248.2.6 Node-3 Rsync, lsyncd, or NFS, GFS, GlusterFS, Object Storage 10.248.2.3 10.248.2.2
  • 37. Extra Bytes • Load balancers works on reverse proxy concept. • There are two type of Load balancers – layer-4 and layer-7 Load balancers. • If a LB does the load balancing by acting on the data available at Layer-4 of OSI – Network Model(Network/Transport Layer), then it is layer-4 LB. Here LB will be done based on IP, Ports, etc. • If a LB does the load balancing by acting on the data available at Layer-7 (Application Layer) then it is layer-7 LB. The LB will be done based on content in the URL. Ex: ‘http://...../reports’ can be directed to particular servers. • Keepalived works on VRRP – Virtual Router Redundancy Protocol.
  • 38. Extra Bytes – Contd.. • We can block IPs (causing DDoS) in HAProxy itself instead blocking at web server ; tcp-request connection reject if { src -f /etc/haproxy/blacklist.txt • Can configure HAProxy to automatically block IPs based on hit rate; acl conn_rate_abuse sc2_conn_rate gt 5 tcp-request content reject if conn_rate_abuse
  • 39. Credits Thanks to • Mr. Willy Tarreau, who still maintains the HAProxy project and a core contributor to Linux kernel. • Team of keepalived.org, working on sponsored funds to give keepalived to industry, which is being widely used in large data centre infrastructure and cloud products. • RedHat for helping me in PoC. • Our GePNIC (eProcurement) DC Support team for helping me in PoC and taking HAProxy to production.
  • 40. HAProxy-Keepalived– References References:  https://www.loadbalancer.org/blog/configure-haproxy-with-tproxy- kernel-for-full-transparent-proxy/  https://ubuntuforums.org/archive/index.php/t-2168372.html  /usr/local/haproxy-1.7.8/README  http://www.keepalived.org/  Live configuration files being used in eProcurement Project.
  • 41. Thank you …. K Ganapathi Technical Director eProcurement Project(GePNIC) National Informatics Centre Chennai, India kganapathi@nic.in