Linux Load Balancing and MySQL Replication

Preview:

DESCRIPTION

Slides from Shohei Azuma's talk on CSU East Bay LUG on 2008-03-15

Citation preview

Linux Load Balancing andMySQL Replication

Shohei Azuma

Load Balancing

Ultramonkey Layer 4 / Layer 7 http://sourceforge.jp/projects/ultramonkey-l7 OSI Model Layer 4

TCP, UDP, SPX, NetBEUI

OSI Model Layer 7 HTTP, SMTP, SNMP, FTP, Telnet

Requirements Two identical Linux Servers

Ultramonkey Layer4

Technology Linux Virtual Server Heartbeat Ldirectord ipvsadmin

Types of Load Balancing rr, wrr, lc, wlc masq , gate

http://enterprisezine.jp/article/detail/228?p=2

Ultramonkey Layer 7

Technology Linux Virtual Server Heartbeat l7directord l7vsadmin

Types of Load Balancing rr, lc masq (gate no longer works)

Cont.d

Layer 7 Specific character string

if *.php go to server1, esle -> server2 Session persistence

shopping carts, payments, etc SSL Cockie Replication

Sample configuration http://ultramonkey-l7.sourceforge.jp/index_en.html

MySQL Replication

Why replication Failover, Backup, load balancing, etc

Terms Binary logs, master, slave, ndb, position, Cluster

Cluster more than 2 storage nodes, one manager, and more than

two API nodes http://dev.mysql.com/doc/refman/5.1/ja/images/cluster-replication-overview.png Requires a lot of memory Require very fast connections. (Gigabit reccomended)

One Way Replication

Master -> Slave Replication One Master DB server, and slave DB server When Master is updated, slave will be updated Apps only writes to master server

Multi Way Replication

Server 1 :Master1, Slave 1 Server 2 :Master2, Slave 2

Master1 -> Slave2 replication, Master2 -> slave2 replication, Must be careful not to be in race cond.

Better if one is read only

Configuration

Issues Only writable to one of the hosts to avoid

inconsistent tables Loads will be based on the web server's loads Moving to cluster will be too costly

MySQL Multi Master Configuration http://www.onlamp.com/pub/a/onlamp/2006/04/20/advanced-mysql-replication.html Multi-Master with cluster for remote sites

http://dev.mysql.com/doc/refman/5.1/ja/images/cluster-replication-overview.png

Ultramonkey + MySQL

Two web servers with 2 NICs

Two MySQL servers Scalable on separete

layer Move Muti-Master to

cluster when adding many more nodes

References

Ultramonkey Project Download http://sourceforge.jp/projects/ultramonkey-l7

masquerading/Gating http://enterprisezine.jp/article/detail/228?p=2

MySQL Cluster Diagram http://dev.mysql.com/doc/refman/5.1/ja/images/cluster-replication-overview.png

Recommended