負載均衡開源解決方案_第1頁
負載均衡開源解決方案_第2頁
負載均衡開源解決方案_第3頁
負載均衡開源解決方案_第4頁
負載均衡開源解決方案_第5頁
已閱讀5頁,還剩24頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、負載均衡開源解決方案負載均衡開源解決方案Load Balancing Using Open Source SoftwaresMSN: MAIL: CUID: FinalBSD2/29Layer 4-7Layer4-7Switch軟件工作層F54-7NetScaler4-7LVS4HAProxy4-73/29ScheduleBasicallyHardware/GUI/CLI (Configure method)/HA (Config Sync)Load balance relatedvirtual server/node/pool/pool memberMonitorsSorry serverM

2、aintenance ModeLoad balance methodPersistenceSNAT/RNATSNAT/RNATServer ProtectionServer ProtectionACL/Content SwitchACL/Content SwitchGSLBGSLBPerformancePerformance4/29We are hereBasicallyLB relatedPersistenceSNAT/RNATServer ProtectionACL/CSGSLB5/29Hardware/GUI/CLI/HACommercialOpen SourceF5NetScalerL

3、VSHAProxyHardwareGUICLIHA6/29HAProxy Hot Reconfiguration mv /etc/haproxy/config /etc/haproxy/config.old mv /var/run/haproxy.pid /var/run/haproxy.pid.old mv /etc/haproxy/config.new /etc/haproxy/config kill -TTOU $(cat /var/run/haproxy.pid.old) if haproxy -p /var/run/haproxy.pid -f /etc/haproxy/config

4、; then echo New instance successfully loaded, stopping previous one. kill -USR1 $(cat /var/run/haproxy.pid.old) rm -f /var/run/haproxy.pid.old exit 1 else echo New instance failed to start, resuming previous one. kill -TTIN $(cat /var/run/haproxy.pid.old) rm -f /var/run/haproxy.pid mv /var/run/hapro

5、xy.pid.old /var/run/haproxy.pid mv /etc/haproxy/config /etc/haproxy/config.new mv /etc/haproxy/config.old /etc/haproxy/config exit 0 fi保存之前狀態(tài)停止老的監(jiān)聽成功,清理老的連接和pid失敗,恢復(fù)老的配置7/29We are hereBasicallyLB relatedPersistenceSNAT/RNATServer ProtectionACL/CSGSLB8/29Conceptsvirtual server:80pool(nam

6、e=cgi_boxes)member(server=:80)member(server=:80)member(server=:80)pool(name=asp_boxes)member(server=:80)member(server=:80)member(server=:80)VIPvirtual server:443pool(name=ssl_boxes)member(server=:443)member(server=10.1

7、.1.2:443)member(server=:443)VIPLoadBalancingIntelligent Traffic Control(look at URL, client IP addr., etc.)Port-basedTraffic DirectionIP Addr.-basedTraffic DirectionIncoming requestMonitorAvailability requirementSNAT/NATPriority-based member activationACTION of servicedownSlow R

8、amp TimePool/pool member statistics9/29MonitorsMonitor類型SimpleECVEAVICMP/GW ICMP/TCP ECHOTCP/HTTP/HTTPS外部程序/FTP下載一個文件到LTM系統(tǒng)上,看是否下載成功/IMAP/LDAP/MSSQL/NNTP/Oracle/POP3/RADIUS/Real Server/SIP/SMTP/SOAP/WMI自定義monitor10/29HAProxy Monitor listen webfarm :80 mode http balance roundrobin cookie S

9、ERVERID insert indirect option httpchk HEAD /index.html HTTP/1.0 server webA 1:80 cookie A check server webB 2:80 cookie B check port 81 inter 2000 server webC 3:80 cookie C check server webD 4:80 cookie D checkhttp:/11/29HAProxy Sorry Serverlisten webfarm

10、 :80 mode http balance roundrobin cookie SERVERID insert indirect option httpchk HEAD /index.html HTTP/1.0 server webA 1:80 cookie A check server webB 2:80 cookie B check port 81 inter 2000 server webC 3:80 cookie C check server webD 4:80 cookie

11、 D check server bkpA 5:80 cookie A check backup server bkpB 6:80 cookie B check backuphttp:/12/29HAProxy Maintenance Modehttp:/Updating.Updating.503 Service UnavailableNo server is available to handle this request. 13/29Load balancing algorithm Round RobinWrr(Ratio(member), Rat

12、io(Node)Dynamic Ratio:根據(jù)對服務(wù)器性能的觀察來動態(tài)設(shè)置weight,觀察點包括連接數(shù)、響應(yīng)時間等。Fastest(node) & Fastest(application): 服務(wù)器/應(yīng)用的最快響應(yīng)時間LC(Member) & LC(node)Observed(member) & Observed(node)Predictive(member) & Predictive(node)SourceURL HASHURL Param14/29We are hereBasicallyLB relatedPersistenceSNAT/RNATServer ProtectionACL

13、/CSGSLB15/29PersistenceClientServer AGET /URI1 HTTP/1.1HTTP request (no cookie)TCP handshakeTCP handshakeGET /URI1 HTTP/1.1HTTP request (no cookie)HTTP/1.1 200 OKHTTP reply (no cookie)HTTP/1.1 200 OKHTTP reply (with inserted cookie)pickserver GET /URI2 HTTP/1.1HTTP request (with same cookie)TCP hand

14、shakeTCP handshakeGET /URI2 HTTP/1.1HTTP request (with same cookie)HTTP/1.1 200 OKHTTP reply (no cookie)HTTP/1.1 200 OKHTTP reply (updated cookie)cookiespecifiesserver First HitSecond HitSet-Cookie: SERVERID=A Cookie: SERVERID=A Cookie persistence 1.1 HTTP Cookie Insert 1.2 HTTP Cookie Rewrite 1.3 H

15、TTP Cookie Passive 1.4 Cookie HashDestination Address affinity persistenceHash persistenceMSRDP persistenceSIP persistence(session Initiation protocol)Souce address affnity persistenceSSL persistenceUniversal persistenceinsertrewriteprefixlisten webfarm :80 mode http balance roundrobin co

16、okie SERVERID insert indirect option httpchk HEAD /index.html HTTP/1.0 server webA 1:80 cookie A check server webB 2:80 cookie B check server webC 3:80 cookie C check server webD 4:80 cookie D check16/29SNAT & RNATExternal vlanInternal vlanVIP:221.238.249.

17、177MAPPED IP: eth0: eth1: SNATRNATbackend private # Connect to the servers using our 00 source address source 00backend transparent_ssl1 # Connect to the SSL farm from the clients source address source 00 usesrc clientip server railsA 192

18、.168.1.11:80 source 01 check server railsB 2:80 minconn 4 maxconn 12 check server railsC 3:80 minconn 4 maxconn 12 check17/29We are hereBasicallyLB relatedPersistenceSNAT/RNATServer ProtectionACL/CSGSLB18/29Server ProtectionAttack (SYN Flood)Connection LimitTimeoutSu

19、rge QueueSlow StartF5Syn ProxyACL/iControl/iRulesNetScalerSyn Cookie/TCP offload/Content Filter/ACLLVSIptables?HAProxyACLlisten appfarm :80 mode http maxconn 10000 option httpclose option abortonclose option forwardfor balance roundrobin server railsA 1:80 minconn 4 maxconn 12

20、check server railsB 2:80 minconn 4 maxconn 12 check server railsC 3:80 minconn 4 maxconn 12 check contimeout 60000weightmaxconn19/29TimeoutTimeout client客戶端連接的閑置時間timeout clitimeout同上、已廢棄timeout connect服務(wù)器端連接的超時時間(嘗試連接)timeout contimeout同上、已廢棄timeout http-request一個完整的HTTP請求的超時時

21、間(僅針對header,降低DDoS風險,連接堆積危險)timeout queue隊列中等待的超時時間,當服務(wù)器連接滿時,多余的請求會放到服務(wù)器或者proxy實例的queue里面。返回503timeout server服務(wù)器端連接的閑置時間timeout srvtimeout同上、已廢棄timeout tarpit使用reqtarpit后,連接保持打開的時間,超時則關(guān)閉Clientproxyserver20/29We are hereBasicallyLB relatedPersistenceSNAT/RNATServer ProtectionACL/CSGSLB21/29HAProxy AC

22、Lreq_lenwait_endreq_ssl_verLayer 4 and belowLayer 4 Contentmethodreq_verpath_*url_*hdr_*Layer 7 ContentHTTP_1.1METH_GETPre-defined ACLsrc/dst src_port/dst_port dst_connnbsrv(backend) acl missing_cl hdr_cnt(Content-length) eq 0 block if HTTP_URL_STAR !METH_OPTIONS | METH_POST missing_cl block if METH

23、_GET HTTP_CONTENT block unless METH_GET or METH_POST or METH_OPTIONSTo select a different backend for requests to static contents on the www siteand to every request on the img, video, download and ftp hosts : acl url_static path_beg /static /images /img /css acl url_static path_end .gif .png .jpg .

24、css .js acl host_www hdr_beg(host) -i www acl host_static hdr_beg(host) -i img. video. download. ftp. # now use backend static for all static-only hosts, and for static urls # of host www. Use backend www for the rest. use_backend static if host_static or host_www url_static use_backend www if host_

25、www22/29Content Switch (UIE/iRule/ACL)frontend public reqisetbe Host: img static # The URI will use a specific keyword soon reqisetbe * /(img|css)/ static reqisetbe * /admin/stats stats default_backend dynamic# The static backend backend for Host: img, /img and /css.backend static backend dynamic ba

26、ckend stats if (http_uri ends_with “.gif”) use pool image_serverselse if (http_uri starts_with “/foo”) use pool foo_serverselse if (http_cookie(“XYZ-Type”) = “direct”) use pool cookie_serverselse if (findstr(http_uri, “?type=”, 6, “&”) = “cgi”) use pool cgi_serverselse use pool web_servers acl url_s

27、tatic path_beg /static /images /img /css acl url_static path_end .gif .png .jpg .css .js acl host_www hdr_beg(host) -i www acl host_static hdr_beg(host) -i img. video. download. ftp. use_backend static if host_static or host_www url_static use_backend www if host_www23/29We are hereBasicallyLB relat

28、edPersistenceSNAT/RNATServer ProtectionACL/CSGSLB24/29GSLB如何實現(xiàn)如何實現(xiàn)CDN和站點容災(zāi)?!和站點容災(zāi)?!Illustrated25/29PerformanceKeep-AliveCompressionIn-memory CacheServer OffloadTCP Buffering26/29Logging listen proxy-out mode http option httplog option logasap log global server cache1 :3128 # log the name

29、of the virtual server capture request header Host len 20 # log the amount of data uploaded during a POST capture request header Content-Length len 10 # log the beginning of the referrer capture request header Referer len 20 # server name (useful for outgoing proxies only) capture response header Server len 20 # logging the content-length is useful with option logasap capture response header Content-Length len 10 # log the expected cache behaviour on the response capture response header Cache-Control len 827/29HTTP Header Manipulation reqdel reqdenyreqpassreqtarp

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論