SlideShare une entreprise Scribd logo
1  sur  27
Télécharger pour lire hors ligne
HAProxy – zastosowania



              Łukasz Jagiełło
    l.jagiello@gratka-technologie.pl
Agenda
●   Wstęp
●   Co to HAProxy ?
●   Zastosowania
●   Co nowego w wersji 1.5
●   Podsumowanie
Load Balancing:

●   Sprzętowe rozwiązania:
    F5, jetNEXUS, Cisco LD, Loadbalancer.org itd.
●   Sieciowe rozwiązania
    (switch, router itd.)
●   Software
Co mamy na rynku:
●   HAProxy
●   Pound
●   Pure Load Balancer
●   Pen
●   Perlbal
●   Coś jeszcze pewnie się znajdzie...
Co się liczy ?
●   HAProxy
●   Pound
Co się naprawdę liczy ?
●   HAProxy
Co to HAProxy
●   Darmowy (GPL v2)
●   Szybki
●   HA
●   Load Balancing
●   Proxy
●   TCP / HTTP
●   Multisystemowy
Możliwości
●   1U Dual Xeon ~ 15k-30k hit/sec
●   Splice() syscall – 10Gbit/s
●   16kb per session – 60k sesji na GB ramu
●   108k HTTP req per second (record !)
Budowa:
global

          log 127.0.0.1     local1 notice

          user nobody

          [...]

default

          log      global

          mode     http

          [...]

backend apache

          server   www.gr      10.0.0.1:80 check inter 3000 fall 2 rise 2

frontend web.example.pl 1.1.1.1:80

          default_backend apache

listen web.example.pl 1.1.1.1:80

          server   www.gr         10.0.0.1:80 check inter 3000 fall 2 rise 2
Zastosowania - HTTP
listen webfarm 192.168.1.1:80

       mode http

       balance roundrobin

       option httpchk HEAD /index.html HTTP/1.0

       server webA 192.168.1.11:80 cookie A check

       server webB 192.168.1.12:80 cookie B check port 81 inter 2000

       server webC 192.168.1.13:80 cookie C check

       server webD 192.168.1.14:80 cookie D check

       server bkpA   192.168.1.15:80 cookie A check backup

       server bkpB   192.168.1.16:80 cookie B check backup
Zastosowania - ACL
●   frontend frontend 0.0.0.0:80

    [...]

    acl blokada url_reg .*.aspx$

    block if blokada

    [...]

    acl static_graph url_reg .*.(jpg|gif|png|js|css|ico|swf|htc|pdf|flv)$

    use_backend varnish if static_graph



●   frontend frontend-static 0.0.0.0:801

    reqirep ^Host: (.*)    Host: static.example.pl

    default_backend nginx
Zastosowanie – ACL (2)
●   frontend wiadomosci24.pl 195.8.99.8:80

            [...]

            errorloc        500     http://blad.wiadomosci24.pl/500.html

            errorloc        502     http://blad.wiadomosci24.pl/502.html

            errorloc        503     http://blad.wiadomosci24.pl/503.html



            acl static      hdr_reg(host) -i ^(s|d|m|img|www1).(.*.)?wiadomosci24.pl

            acl blad        hdr(host) -i blad.wiadomosci24.pl



            use_backend cache if static

            use_backend blad if blad



            default_backend wiadomosci24
Zastosowania – ACL (3)
●   acl baltycki.tv hdr_reg(host) ^(www.)?baltycki.tv

    redirect location http://dziennikbaltycki.pl     if baltycki.tv



●   backend robots_denied

            option   httpchk HEAD /check.txt HTTP/1.0

            server   robots_denied   127.0.0.1:8000 check inter 3000 fall 2 rise 2

    frontend devel 192.168.0.1:80

            acl robots       url_reg /robots.txt$

            use_backend robots_denied if robots

            default_backend www_devel
Zastosowania – hit ratio

●   backend cache

            stick store-request src

            stick-table type ip size 200k expire 30m

            server   cache01          10.5.0.11:80 check inter 3000 fall 2 rise 2

            server   cache02          10.5.0.12:80 check inter 3000 fall 2 rise 2

            server   cache03          10.5.0.13:80 check inter 3000 fall 2 rise 2
Zastosowania – World IPv6 Day
defaults

    log                    global

    mode                   tcp

    option                 dontlognull

    [...]

frontend www.gratka.pl     195.8.99.42:80,2a02:1320:ffff:0:195:8:99:42:80

          [...]

          default_backend www



listen    ipv6proxy443     2A02:1320:FFFF:FFFF::1:443

          mode     tcp

          server   ipv4server443    10.0.0.1:443
Zastosowania - HTTPS
●   Stunnel:

    [https]

    accept    = 443

    connect = 127.0.0.1:4443

    TIMEOUTclose = 0



●   HAProxy:

    frontend ssl-frontend 0.0.0.0:4443

              reqadd   SSL: on

              default_backend www-backend




    * Pound ma wbudowaną obsługę SSL
Zastosowania - SMTP
●   listen smtp :25

            mode tcp

            maxconn 500

            option tcplog

            balance roundrobin

            server smtp1 xx.xx.xx.xx:25 check inter 10000

            server smtp2 xx.xx.xx.xx:25 check inter 10000
Zastosowania - MySQL
# DB write cluster

#   Failure scenarios:

#   - replication 'up' on db01 & db02 = writes to db01

#   - replication 'down' on db02      = writes to db01

#   - replication 'down' on db01      = writes to db02

#   - replication 'down' on db01 & db02    = go nowhere, split-brain, cluster FAIL!

#   - mysql 'down' on db02                 = writes to db01_backup

#   - mysql 'down' on db01                 = writes to db02_backup

#   - mysql 'down' on db01 & db02          = go nowhere, cluster FAIL!
Zastosowanie – MySQL (2)
backend cluster_db_write

# - max 1 db server available at all times

# - db01 is preferred (top of list)

# - db_backups set their 'up' or 'down' based on results from monitor_dbs

mode     tcp

option   tcpka

balance roundrobin

option   httpchk GET /dbs

server   db01 172.16.0.60:3306 weight 1 check port 9201 inter 1s rise 2 fall 1

server   db02 172.16.0.61:3306 weight 1 check port 9201 inter 1s rise 2 fall 1 backup

server db01_backup 172.16.0.60:3306 weight 1 check port 9301 inter 1s rise 2 fall 2 addr
127.0.0.1 backup

server db02_backup 172.16.0.61:3306 weight 1 check port 9302 inter 1s rise 2 fall 2 addr
127.0.0.1 backup
Zastosowanie – SSH/SSL
●   listen ssl :443

      tcp-request inspect-delay 2s

      acl is_ssl req_ssl_ver 2:3.1

      tcp-request content accept if is_ssl

      use_backend ssh if !is_ssl

      server www-ssl :444

      timeout client 2h



    backend ssh

      mode tcp

      server ssh :22

      timeout server 2h
Co nowego w 1.5
●   frontend a

     bind ...

     stick-table type ip size 200k expire 2m store conn_cur

     acl source_is_abuser sc1_conn_cur gt 2

     tcp-request connection track-sc1 src     if ! source_is_abuser

     use_backend slow if source_is_abuser

     default_backend fast



     backend slow

     server a ... maxconn 1 check

     server b ... maxconn 1 check



     backend fast

     server a ... maxconn 10 check

     server b ... maxconn 10 check
Co nowego w 1.5 (2)
●           listen ssh

                bind :22

                mode tcp

                maxconn 100

                stick-table type ip size 20 expire 10s store conn_cnt

                tcp-request content reject if { src_update_count gt 3 }

                server local 127.0.0.1:22



●   3 połączenia SSH na 10sec
Co nowego w 1.5 (3)
●   peers mypeers

        peer haproxy1 192.168.0.1:1024

        peer haproxy2 192.168.0.2:1024

        peer haproxy3 10.2.0.1:1024



    backend mybackend

        mode tcp

        balance roundrobin

        stick-table type ip size 20k peers mypeers

        stick on src



        server srv1 192.168.0.30:80

        server srv2 192.168.0.31:80
Podsumowanie
●   Wydajna
●   Konfigurowalna
●   Dobra dokumentacja
●   Easy -> Hard
●   Wieloplatformowa aplikacja
●   Doskonałe porfolio użytkowników
Gdzie szukać pomocy ?

●   Dokumentacja:
    http://haproxy.1wt.eu/download/1.4/doc/

●   Lista Dyskusyjna:
    http://www.formilux.org/archives/haproxy/
Pytania?

Contenu connexe

Tendances

X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
Yiwei Ma
 
Setting up mongo replica set
Setting up mongo replica setSetting up mongo replica set
Setting up mongo replica set
Sudheer Kondla
 
The Magic of Hot Streaming Replication, Bruce Momjian
The Magic of Hot Streaming Replication, Bruce MomjianThe Magic of Hot Streaming Replication, Bruce Momjian
The Magic of Hot Streaming Replication, Bruce Momjian
Fuenteovejuna
 

Tendances (20)

Object Storage with Gluster
Object Storage with GlusterObject Storage with Gluster
Object Storage with Gluster
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkg
 
A little systemtap
A little systemtapA little systemtap
A little systemtap
 
Redis as a message queue
Redis as a message queueRedis as a message queue
Redis as a message queue
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Oracle cluster installation with grid and nfs
Oracle cluster  installation with grid and nfsOracle cluster  installation with grid and nfs
Oracle cluster installation with grid and nfs
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Setting up mongo replica set
Setting up mongo replica setSetting up mongo replica set
Setting up mongo replica set
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
 
Pf: the OpenBSD packet filter
Pf: the OpenBSD packet filterPf: the OpenBSD packet filter
Pf: the OpenBSD packet filter
 
Vagrant
VagrantVagrant
Vagrant
 
Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)Replica Sets (NYC NoSQL Meetup)
Replica Sets (NYC NoSQL Meetup)
 
GlusterFS As an Object Storage
GlusterFS As an Object StorageGlusterFS As an Object Storage
GlusterFS As an Object Storage
 
Python, Keras, Hello world, Installation, Binary Classification
Python, Keras, Hello world, Installation, Binary ClassificationPython, Keras, Hello world, Installation, Binary Classification
Python, Keras, Hello world, Installation, Binary Classification
 
Comparison of foss distributed storage
Comparison of foss distributed storageComparison of foss distributed storage
Comparison of foss distributed storage
 
Linux network stack
Linux network stackLinux network stack
Linux network stack
 
The Magic of Hot Streaming Replication, Bruce Momjian
The Magic of Hot Streaming Replication, Bruce MomjianThe Magic of Hot Streaming Replication, Bruce Momjian
The Magic of Hot Streaming Replication, Bruce Momjian
 
Oracle cluster installation with grid and iscsi
Oracle cluster  installation with grid and iscsiOracle cluster  installation with grid and iscsi
Oracle cluster installation with grid and iscsi
 
Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
 
Centralized + Unified Logging
Centralized + Unified LoggingCentralized + Unified Logging
Centralized + Unified Logging
 

En vedette (6)

GlusterFS
GlusterFSGlusterFS
GlusterFS
 
Magento implementation - by Divante.co
Magento implementation - by Divante.coMagento implementation - by Divante.co
Magento implementation - by Divante.co
 
INTERSPORT e-Commerce with Divante
INTERSPORT e-Commerce with DivanteINTERSPORT e-Commerce with Divante
INTERSPORT e-Commerce with Divante
 
E-Commerce Technology
E-Commerce TechnologyE-Commerce Technology
E-Commerce Technology
 
E-Commerce Case Studies
E-Commerce Case StudiesE-Commerce Case Studies
E-Commerce Case Studies
 
e-Commerce Trends from 2014 to 2015 by Divante.co
e-Commerce Trends from 2014 to 2015 by Divante.coe-Commerce Trends from 2014 to 2015 by Divante.co
e-Commerce Trends from 2014 to 2015 by Divante.co
 

Similaire à Haproxy - zastosowania

Стек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атак
Стек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атакСтек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атак
Стек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атак
Positive Hack Days
 
Kettunen, miaubiz fuzzing at scale and in style
Kettunen, miaubiz   fuzzing at scale and in styleKettunen, miaubiz   fuzzing at scale and in style
Kettunen, miaubiz fuzzing at scale and in style
DefconRussia
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
Ontico
 

Similaire à Haproxy - zastosowania (20)

Prezentacja zimowisko 2014
Prezentacja zimowisko 2014Prezentacja zimowisko 2014
Prezentacja zimowisko 2014
 
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
 
Стек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атак
Стек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атакСтек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атак
Стек Linux HTTPS/TCP/IP для защиты от HTTP-DDoS-атак
 
DockerCon EU '17 - Dockerizing Aurea
DockerCon EU '17 - Dockerizing AureaDockerCon EU '17 - Dockerizing Aurea
DockerCon EU '17 - Dockerizing Aurea
 
Velocity 2011 - Our first DDoS attack
Velocity 2011 - Our first DDoS attackVelocity 2011 - Our first DDoS attack
Velocity 2011 - Our first DDoS attack
 
"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy
 
Kettunen, miaubiz fuzzing at scale and in style
Kettunen, miaubiz   fuzzing at scale and in styleKettunen, miaubiz   fuzzing at scale and in style
Kettunen, miaubiz fuzzing at scale and in style
 
Varnish - PLNOG 4
Varnish - PLNOG 4Varnish - PLNOG 4
Varnish - PLNOG 4
 
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
Tempesta FW - Framework и Firewall для WAF и DDoS mitigation, Александр Крижа...
 
Replacing Squid with ATS
Replacing Squid with ATSReplacing Squid with ATS
Replacing Squid with ATS
 
ReplacingSquidWithATS
ReplacingSquidWithATSReplacingSquidWithATS
ReplacingSquidWithATS
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
VMworld 2016: vSphere 6.x Host Resource Deep Dive
VMworld 2016: vSphere 6.x Host Resource Deep DiveVMworld 2016: vSphere 6.x Host Resource Deep Dive
VMworld 2016: vSphere 6.x Host Resource Deep Dive
 
How to monitor NGINX
How to monitor NGINXHow to monitor NGINX
How to monitor NGINX
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuilding
 
Analyze Virtual Machine Overhead Compared to Bare Metal with Tracing
Analyze Virtual Machine Overhead Compared to Bare Metal with TracingAnalyze Virtual Machine Overhead Compared to Bare Metal with Tracing
Analyze Virtual Machine Overhead Compared to Bare Metal with Tracing
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22
 
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-BaljevicHow to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
How to-mount-3 par-san-virtual-copy-onto-rhel-servers-by-Dusan-Baljevic
 
Tweaking performance on high-load projects
Tweaking performance on high-load projectsTweaking performance on high-load projects
Tweaking performance on high-load projects
 

Dernier

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Haproxy - zastosowania

  • 1.
  • 2. HAProxy – zastosowania Łukasz Jagiełło l.jagiello@gratka-technologie.pl
  • 3. Agenda ● Wstęp ● Co to HAProxy ? ● Zastosowania ● Co nowego w wersji 1.5 ● Podsumowanie
  • 4. Load Balancing: ● Sprzętowe rozwiązania: F5, jetNEXUS, Cisco LD, Loadbalancer.org itd. ● Sieciowe rozwiązania (switch, router itd.) ● Software
  • 5. Co mamy na rynku: ● HAProxy ● Pound ● Pure Load Balancer ● Pen ● Perlbal ● Coś jeszcze pewnie się znajdzie...
  • 6. Co się liczy ? ● HAProxy ● Pound
  • 7. Co się naprawdę liczy ? ● HAProxy
  • 8. Co to HAProxy ● Darmowy (GPL v2) ● Szybki ● HA ● Load Balancing ● Proxy ● TCP / HTTP ● Multisystemowy
  • 9. Możliwości ● 1U Dual Xeon ~ 15k-30k hit/sec ● Splice() syscall – 10Gbit/s ● 16kb per session – 60k sesji na GB ramu ● 108k HTTP req per second (record !)
  • 10. Budowa: global log 127.0.0.1 local1 notice user nobody [...] default log global mode http [...] backend apache server www.gr 10.0.0.1:80 check inter 3000 fall 2 rise 2 frontend web.example.pl 1.1.1.1:80 default_backend apache listen web.example.pl 1.1.1.1:80 server www.gr 10.0.0.1:80 check inter 3000 fall 2 rise 2
  • 11. Zastosowania - HTTP listen webfarm 192.168.1.1:80 mode http balance roundrobin option httpchk HEAD /index.html HTTP/1.0 server webA 192.168.1.11:80 cookie A check server webB 192.168.1.12:80 cookie B check port 81 inter 2000 server webC 192.168.1.13:80 cookie C check server webD 192.168.1.14:80 cookie D check server bkpA 192.168.1.15:80 cookie A check backup server bkpB 192.168.1.16:80 cookie B check backup
  • 12. Zastosowania - ACL ● frontend frontend 0.0.0.0:80 [...] acl blokada url_reg .*.aspx$ block if blokada [...] acl static_graph url_reg .*.(jpg|gif|png|js|css|ico|swf|htc|pdf|flv)$ use_backend varnish if static_graph ● frontend frontend-static 0.0.0.0:801 reqirep ^Host: (.*) Host: static.example.pl default_backend nginx
  • 13. Zastosowanie – ACL (2) ● frontend wiadomosci24.pl 195.8.99.8:80 [...] errorloc 500 http://blad.wiadomosci24.pl/500.html errorloc 502 http://blad.wiadomosci24.pl/502.html errorloc 503 http://blad.wiadomosci24.pl/503.html acl static hdr_reg(host) -i ^(s|d|m|img|www1).(.*.)?wiadomosci24.pl acl blad hdr(host) -i blad.wiadomosci24.pl use_backend cache if static use_backend blad if blad default_backend wiadomosci24
  • 14. Zastosowania – ACL (3) ● acl baltycki.tv hdr_reg(host) ^(www.)?baltycki.tv redirect location http://dziennikbaltycki.pl if baltycki.tv ● backend robots_denied option httpchk HEAD /check.txt HTTP/1.0 server robots_denied 127.0.0.1:8000 check inter 3000 fall 2 rise 2 frontend devel 192.168.0.1:80 acl robots url_reg /robots.txt$ use_backend robots_denied if robots default_backend www_devel
  • 15. Zastosowania – hit ratio ● backend cache stick store-request src stick-table type ip size 200k expire 30m server cache01 10.5.0.11:80 check inter 3000 fall 2 rise 2 server cache02 10.5.0.12:80 check inter 3000 fall 2 rise 2 server cache03 10.5.0.13:80 check inter 3000 fall 2 rise 2
  • 16. Zastosowania – World IPv6 Day defaults log global mode tcp option dontlognull [...] frontend www.gratka.pl 195.8.99.42:80,2a02:1320:ffff:0:195:8:99:42:80 [...] default_backend www listen ipv6proxy443 2A02:1320:FFFF:FFFF::1:443 mode tcp server ipv4server443 10.0.0.1:443
  • 17. Zastosowania - HTTPS ● Stunnel: [https] accept = 443 connect = 127.0.0.1:4443 TIMEOUTclose = 0 ● HAProxy: frontend ssl-frontend 0.0.0.0:4443 reqadd SSL: on default_backend www-backend * Pound ma wbudowaną obsługę SSL
  • 18. Zastosowania - SMTP ● listen smtp :25 mode tcp maxconn 500 option tcplog balance roundrobin server smtp1 xx.xx.xx.xx:25 check inter 10000 server smtp2 xx.xx.xx.xx:25 check inter 10000
  • 19. Zastosowania - MySQL # DB write cluster # Failure scenarios: # - replication 'up' on db01 & db02 = writes to db01 # - replication 'down' on db02 = writes to db01 # - replication 'down' on db01 = writes to db02 # - replication 'down' on db01 & db02 = go nowhere, split-brain, cluster FAIL! # - mysql 'down' on db02 = writes to db01_backup # - mysql 'down' on db01 = writes to db02_backup # - mysql 'down' on db01 & db02 = go nowhere, cluster FAIL!
  • 20. Zastosowanie – MySQL (2) backend cluster_db_write # - max 1 db server available at all times # - db01 is preferred (top of list) # - db_backups set their 'up' or 'down' based on results from monitor_dbs mode tcp option tcpka balance roundrobin option httpchk GET /dbs server db01 172.16.0.60:3306 weight 1 check port 9201 inter 1s rise 2 fall 1 server db02 172.16.0.61:3306 weight 1 check port 9201 inter 1s rise 2 fall 1 backup server db01_backup 172.16.0.60:3306 weight 1 check port 9301 inter 1s rise 2 fall 2 addr 127.0.0.1 backup server db02_backup 172.16.0.61:3306 weight 1 check port 9302 inter 1s rise 2 fall 2 addr 127.0.0.1 backup
  • 21. Zastosowanie – SSH/SSL ● listen ssl :443 tcp-request inspect-delay 2s acl is_ssl req_ssl_ver 2:3.1 tcp-request content accept if is_ssl use_backend ssh if !is_ssl server www-ssl :444 timeout client 2h backend ssh mode tcp server ssh :22 timeout server 2h
  • 22. Co nowego w 1.5 ● frontend a bind ... stick-table type ip size 200k expire 2m store conn_cur acl source_is_abuser sc1_conn_cur gt 2 tcp-request connection track-sc1 src if ! source_is_abuser use_backend slow if source_is_abuser default_backend fast backend slow server a ... maxconn 1 check server b ... maxconn 1 check backend fast server a ... maxconn 10 check server b ... maxconn 10 check
  • 23. Co nowego w 1.5 (2) ● listen ssh bind :22 mode tcp maxconn 100 stick-table type ip size 20 expire 10s store conn_cnt tcp-request content reject if { src_update_count gt 3 } server local 127.0.0.1:22 ● 3 połączenia SSH na 10sec
  • 24. Co nowego w 1.5 (3) ● peers mypeers peer haproxy1 192.168.0.1:1024 peer haproxy2 192.168.0.2:1024 peer haproxy3 10.2.0.1:1024 backend mybackend mode tcp balance roundrobin stick-table type ip size 20k peers mypeers stick on src server srv1 192.168.0.30:80 server srv2 192.168.0.31:80
  • 25. Podsumowanie ● Wydajna ● Konfigurowalna ● Dobra dokumentacja ● Easy -> Hard ● Wieloplatformowa aplikacja ● Doskonałe porfolio użytkowników
  • 26. Gdzie szukać pomocy ? ● Dokumentacja: http://haproxy.1wt.eu/download/1.4/doc/ ● Lista Dyskusyjna: http://www.formilux.org/archives/haproxy/