Introduction to Linux Virtual Server and High Availability

Introduction to Linux Virtual Server and High Availability

Outlines Introduction to Linux Virtual Server and High Availability Chen Kaiwang [email protected] December 5, 2011 Chen Kaiwang [email protected] LVS-DR and Keepalived Outlines If you don't know the theory, you don't have a way to be rigorous. Robert J. Shiller http://www.econ.yale.edu/~shiller/ Chen Kaiwang [email protected] LVS-DR and Keepalived Outlines Misery stories I Jul 2011 Too many connections at zongheng.com I Aug 2011 Realserver maintenance at 173.com quiescent persistent connections I Nov 2011 Health check at 173.com I Nov 2011 Virtual service configuration at 173.com persistent session data Chen Kaiwang [email protected] LVS-DR and Keepalived Outlines Outline of Part I Introduction to Linux Virtual Server Configuration Overview Netfilter Architecture Job Scheduling Scheduling Basics Scheduling Algorithms Connection Affinity Persistence Template Persistence Granularity Quirks Chen Kaiwang [email protected] LVS-DR and Keepalived Outlines Outline of Part II HA Basics LVS High Avaliablity Realserver Failover Director Failover Solutions Heartbeat Keepalived Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Connection Affinity Quirks Part I Introduction to Linux Virtual Server Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Configuration Overview Connection Affinity Netfilter Architecture Quirks Introduction to Linux Virtual Server Configuration Overview Netfilter Architecture Job Scheduling Scheduling Basics Scheduling Algorithms Connection Affinity Persistence Template Persistence Granularity Quirks Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Configuration Overview Connection Affinity Netfilter Architecture Quirks A Linux Virtual Serverr (LVS) is a group of servers that appear to the client as one large, fast, reliable (highly available) server. The core of the project is the ip vs code, which runs on the LVS director. I Layer 4 switch (Director) I Backend servers (Realservers) Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Configuration Overview Connection Affinity Netfilter Architecture Quirks LVS Configurations Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Configuration Overview Connection Affinity Netfilter Architecture Quirks A Packet Traversing the Netfilter System --->[1]--->[ROUTE]--->[3]--->[4]---> | ^ | | | [ROUTE] v | [2] [5] | ^ | | v | NF_IP_PRE_ROUTING [1] NF_IP_POST_ROUTING [4] NF_IP_LOCAL_IN [2] NF_IP_LOCAL_OUT [5] NF_IP_FORWARD [3] NF_ACCEPT, NF_DROP, NF_STOLEN, NF_QUEUE, NF_REPEAT Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Configuration Overview Connection Affinity Netfilter Architecture Quirks Packet Selection: IP Tables --->PRE------>[ROUTE]--->FWD---------->POST------> Conntrack | Mangle ^ Mangle Mangle | Filter | NAT (Src) NAT (Dst) | | Conntrack (QDisc) | [ROUTE] v | IN Filter OUT Conntrack | Conntrack ^ Mangle | Mangle | NAT (Dst) v | Filter Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Configuration Overview Connection Affinity Netfilter Architecture Quirks Interaction of LVS with Netfilter Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Configuration Overview Connection Affinity Netfilter Architecture Quirks Modules register with a priority, the lowest priority getting to look at the packets first. LVS registers itself with a higher priority than iptables rules, and thus iptables will get the packet first and then LVS. Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Scheduling Basics Connection Affinity Scheduling Algorithms Quirks Introduction to Linux Virtual Server Configuration Overview Netfilter Architecture Job Scheduling Scheduling Basics Scheduling Algorithms Connection Affinity Persistence Template Persistence Granularity Quirks Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Scheduling Basics Connection Affinity Scheduling Algorithms Quirks Job Scheduling Which realserver to service a new connection request Virtual service, and server pool VIP:PORT, or fwmark Scheduling granularity LVS - network connection-based DNS - host-based, TTL Quiescent feature stop the realserver from being selected by the scheduler Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Scheduling Basics Connection Affinity Scheduling Algorithms Quirks Schedulers I RR, WRR, weight and scheduling sequence I LC, WLC, estimating realserver connections? TIME WAIT I DH, LBLC, LBLCR, by dest ip, aplicable to transparent proxy where the dest ip could be variable. I SH, by client ip. I Persistent connection Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Scheduling Basics Connection Affinity Scheduling Algorithms Quirks If the realservers are offering different services and some have clients connected for a long time while others are connected for a short time, or some are compute bound, while others are network bound, then none of the schedulers will do a good job of distributing the load between the realservers. LVS doesn't have any load monitoring of the realservers. Ratz Nov 2006 After almost 10 years of my involvement with load balancers, I have to admit that no customer ever truly asked or cared about the scheduling algorithm :). This is academia for the rest of the world. Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Persistence Template Connection Affinity Persistence Granularity Quirks Introduction to Linux Virtual Server Configuration Overview Netfilter Architecture Job Scheduling Scheduling Basics Scheduling Algorithms Connection Affinity Persistence Template Persistence Granularity Quirks Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Persistence Template Connection Affinity Persistence Granularity Quirks The two meanings of persistence I Keep-Alive used for clients connecting to webservers and databases I Affinity (LVS persistence) used by cisco. Persistance opperates independant of the scheduler It looks up a persistance template and if it finds one, then it uses it, else it asks the scheduler what to do. Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Persistence Template Connection Affinity Persistence Granularity Quirks Persistence Template IP VS connection table <CIP, VIRTUAL SERVICE, RIP:PORT, FLAGS> I VIRTUAL SERVICE is either VIP:PORT or fwmark I the NONE flag is the trick # ipvsadm -L -n -c j grep NONE The two kinds of conneciton tracking I IP VS ip vs I Netfilter ip conntrack Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Persistence Template Connection Affinity Persistence Granularity Quirks Persistence Granularity Loadbalance all clients from a netmask as one group. I Applied to the CIP I Works the same whether you are using fwmark or the VIP to setup the LVS Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Connection Affinity Quirks Introduction to Linux Virtual Server Configuration Overview Netfilter Architecture Job Scheduling Scheduling Basics Scheduling Algorithms Connection Affinity Persistence Template Persistence Granularity Quirks Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Connection Affinity Quirks IP VS table entry revisited <CIP, VIRTUAL SERVICE, RIP:PORT, FLAGS> --------------------- -------- ----- ---- \ / \ \ scheduling \ \ NONE refers to templates persistence granularity others trace connections Chen Kaiwang [email protected] LVS-DR and Keepalived LVS Intro Job Scheduling Connection Affinity Quirks Clear the table # ipvsadm -C expire nodest conn (destined for a server no longer in the pool) I 1: expire entry and reset client I 0: keep entry and drop packet Clear quiescent persistent connections expire quiescent template (timeout persistent template when server goes down) ARP problem with LVS-DR Chen Kaiwang [email protected] LVS-DR and Keepalived HA Basics Solutions Part II LVS High Availability Chen Kaiwang [email protected] LVS-DR and Keepalived LVS High Avaliablity HA Basics Realserver Failover Solutions Director Failover HA Basics LVS High Avaliablity Realserver Failover Director Failover Solutions Heartbeat Keepalived Chen Kaiwang [email protected] LVS-DR and Keepalived LVS High Avaliablity HA Basics Realserver Failover Solutions Director Failover A design principle of HA systems is three distinct paths to the servers: resource-path (or public path), heartbeat, and administrative. I Single point of failure you can't protect against everything I Health check accuracy I Stateful failover I connection table I persistent session data Chen Kaiwang [email protected] LVS-DR and Keepalived LVS High Avaliablity HA Basics Realserver Failover Solutions Director Failover Realserver Failover Service check tcp, http, https, smtp, ... Server operations I Realserver pool I Added to pool I Quiescent (weight=0) I Removed from pool I Sorry server Stateful failover I conntrackd I persistent session data Chen Kaiwang [email protected] LVS-DR and Keepalived LVS High Avaliablity HA Basics Realserver Failover Solutions Director Failover Director Failover VRRP, Linux-HA I VIP takeover unsolicited ARP I Server state sync daemon Chen Kaiwang [email protected] LVS-DR and Keepalived HA Basics Heartbeat Solutions Keepalived HA Basics LVS High Avaliablity Realserver Failover Director

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    36 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us