Haproxy - zastosowania
Upcoming SlideShare
Loading in...5

Haproxy - zastosowania



Przykłady zastosowań HAProxy.

Przykłady zastosowań HAProxy.



Total Views
Views on SlideShare
Embed Views



5 Embeds 424

http://blog.jagiello.org 406
http://www.linkedin.com 7
https://www.linkedin.com 7
http://translate.googleusercontent.com 2
http://feeds.feedburner.com 2



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Haproxy - zastosowania Haproxy - zastosowania Presentation Transcript

  • 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 View slide
  • Co mamy na rynku:● HAProxy● Pound● Pure Load Balancer● Pen● Perlbal● Coś jeszcze pewnie się znajdzie... View slide
  • 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 local1 notice user nobody [...]default log global mode http [...]backend apache server www.gr check inter 3000 fall 2 rise 2frontend web.example.pl default_backend apachelisten web.example.pl server www.gr check inter 3000 fall 2 rise 2
  • Zastosowania - HTTPlisten webfarm mode http balance roundrobin option httpchk HEAD /index.html HTTP/1.0 server webA cookie A check server webB cookie B check port 81 inter 2000 server webC cookie C check server webD cookie D check server bkpA cookie A check backup server bkpB cookie B check backup
  • Zastosowania - ACL● frontend frontend [...] 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 reqirep ^Host: (.*) Host: static.example.pl default_backend nginx
  • Zastosowanie – ACL (2)● frontend wiadomosci24.pl [...] 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 check inter 3000 fall 2 rise 2 frontend devel 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 check inter 3000 fall 2 rise 2 server cache02 check inter 3000 fall 2 rise 2 server cache03 check inter 3000 fall 2 rise 2
  • Zastosowania – World IPv6 Daydefaults log global mode tcp option dontlognull [...]frontend www.gratka.pl,2a02:1320:ffff:0:195:8:99:42:80 [...] default_backend wwwlisten ipv6proxy443 2A02:1320:FFFF:FFFF::1:443 mode tcp server ipv4server443
  • Zastosowania - HTTPS● Stunnel: [https] accept = 443 connect = TIMEOUTclose = 0● HAProxy: frontend ssl-frontend 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_dbsmode tcpoption tcpkabalance roundrobinoption httpchk GET /dbsserver db01 weight 1 check port 9201 inter 1s rise 2 fall 1server db02 weight 1 check port 9201 inter 1s rise 2 fall 1 backupserver db01_backup weight 1 check port 9301 inter 1s rise 2 fall 2 addr127.0.0.1 backupserver db02_backup weight 1 check port 9302 inter 1s rise 2 fall 2 addr127.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● 3 połączenia SSH na 10sec
  • Co nowego w 1.5 (3)● peers mypeers peer haproxy1 peer haproxy2 peer haproxy3 backend mybackend mode tcp balance roundrobin stick-table type ip size 20k peers mypeers stick on src server srv1 server srv2
  • 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?