mysql high-availability and scale-out architectures

33
1 Copyright 2007 Oli Sennhauser The World’s Most Popular Open Source Database MySQL High-Availability and Scale-Out architectures Oli Sennhauser Senior Consultant [email protected]

Upload: fromdual-gmbh

Post on 09-May-2015

3.479 views

Category:

Technology


5 download

TRANSCRIPT

  • 1.MySQL High-Availability and Scale-Out architectures Oli SennhauserSenior [email protected] 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 1

2. Introduction Who we are? What we want?Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 2 3. Table of ContentsScale-Up vs. Scale-OutMySQL ReplicationMySQL HA solutionMySQL ClusterApplication architectural solutionsOther architectural stuffIts your turn...Let us build a replicationCopyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 3 4. When do we think about architecture? Performance problems HA requirementsCopyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 4 5. Scale-up vs. Scale-Out Scale-up Scale-outtRelaxation of constraintsCopyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 5 6. MySQL Replication The MySQL answer: Master-Slave-Replication:Application2 types of sessions!!!rtwMaster Slave1 Slave2Slave3 ...LB roEven Oracle uses the expression scale-out now!Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 6 7. MySQL Replication in detailApplro rt wasynchronous! IO thread M SSQL thread...bin-logbin-logrelay-logrelay-log wide distance possible! thin line possible!Copyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 7 8. MySQL Replication varieties Cascaded replication:Mblack holeSISI SI...SE! S1S2 S3 S4S5 S6 S7S8 ...for example Yahoo!Copyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 8 9. MySQL Replication varieties HA with hot standby Slave: Appl VIP HA solution SbackupM SstandbyS1S2S3 active active fail over!Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 9 10. MySQL HA solution HA with MySQL:ApplVIP heartbeatMMDRBD S1S2 S3 99.99% HA (four nine) active passive fail over!Copyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 10 11. MySQL HA solution HA with MySQL and SAN:ApplVIP heartbeatMMSAN S1S2 S3Copyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 11 12. Multi-Master Replication actually Master-Master ReplicationApplAppl VIP/LBM1M2 S11 S12S13 S21S22S23 This architecture does NOT solve your writeproblems!!!Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 12 13. Multi-Master Replication HA Multi-Master ReplicationAppl Appl VIP/LBVIPVIPM1 M1M2M2DRBDDRBD S11 S12S13 S21S22S23Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 13 14. Shared disk cluster DB1DB2DB2ro! shareddisk This is in 99.9% of the cases NOT your solution!!! It looks like Oracle RAC but MySQL does NOT(yet) have the instruments needed! Can be useful in some special kinds of reporting.Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 14 15. Where are we now? The architectures above solved: your read problems. some HA requirements. But they did not solve: your write problems! And what when we need: higher HA? synchronous replication? more write speed?Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 15 16. MySQL ClusterShared-nothing architectureSynchronous replication (2-Phase commit)Fast automatic fail overHigh performance (also writing)High transactional throughputNo special components requiredIn-Memory database (in 5.1 also disk support)Scalable, 1000s of transactions per second99.999% HA (five nine)On-line upgrade path (at least on GA within same version)Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 16 17. MySQL Cluster architectureApplicationApplicationApplication Application ApplicationApplicationmy.cnfSQLNodesMySQL MySQL MySQL ServerServerServer NDB Cluster (Data nodes) config.iniDBDBMGMDataNodes ServerDBDBMGM client MgmtNodesCopyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 17 18. MySQL Cluster HA featuresMySQLXMySQL XMySQLX MySQLXMySQLServer ServerServerServer ServerNDB APIDataNDB Data ManagementNode Storage Engine Node Server X DataX Data NodeNodeX ServerManagementMySQL ClusterCopyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 18 19. Cluster with Replication for read scale-out (Reporting):Appl rw mysqld mysqldmysqldndbd ndbdS1 S2 S3ndbd ndbd ReportingCopyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 19 20. Cluster with Replication Cluster-Cluster replication for disaster fail over(MySQL 5.0): Appl fail over rw mysqldmysqldmysqld mysqld mysqldmysqldndbdndbd ndbd ndbdndbdndbd ndbd ndbdCopyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 20 21. Cluster with Replication Cluster-Cluster replication for disaster fail over(MySQL 5.1): Applfail over rw mysqldmysqldmysqld mysqld mysqldmysqldndbdndbd ndbd ndbdndbdndbd ndbd ndbdCopyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 21 22. Cluster with Replication circular Cluster-Clusterreplication (>= MySQL5.1.18?):Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 22 23. Cluster examplesSession handlingTelecom (Mobile)VoIPRSS-Feed aggregationMailOn-line Games Use cluster where you need HA you have high write load you do little Joins and GroupingCopyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 23 24. How to go on? Read is a caching problem! More RAM or scale-out.Write is a batching problem! Batch your load, Buy stronger I/O system. Use MySQL Cluster. SSD!What then?Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 24 25. SSD disruption I/O system without any movable parts! SSD = Solid State disk (Flash memory, NAND,NOR chips, RAM-SAN). During the last year(s) Price from 15000 USD / 160 Gbyte -> 100 USD /32 Gbyte 10-50 times faster than mechanical I/O systems 1 Mio write cycles dead :-( (special FS!) RAM: Huge amount of memory is cheap!This will disrupt the database world!Copyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 25 26. What then? With or without SSD we will reach a physicallimit. What then? Application partitioning: Split applications OLTP vs. OLAP all in one Segment your applicationCopyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 26 27. Application partitioning OLTP vs. OLAP hot business data (trx) vs. old reporting data All in one Sessions, user tracking, ads, chat, booking Segment split by for example 1 Mio users (split by user_id).Copyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 27 28. Architecture examplesCopyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 28 29. Architecture examplesCopyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 29 30. Architecture examplesCopyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 30 31. Architecture examplesCopyright 2007 Oli Sennhauser The Worlds Most Popular Open Source Database 31 32. Some more architecture stuff? Databases are slow!!! Whenever possible try to avoid databases! Usememcached for example. The SP trap. Stored Procedures are a lock in! Try to avoid SP! Use Materialized Views (MV) and/or shadowtables. VM/SAN is nice for consolidation but not forperformance/scale-out! Backup and Staging MySQL ProxyCopyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 32 33. Now its your turn... Your problems? Let us build a replication...Copyright 2007 Oli SennhauserThe Worlds Most Popular Open Source Database 33