+ All Categories
Home > Technology > A Global In-memory Data System for MySQL

A Global In-memory Data System for MySQL

Date post: 08-May-2015
Category:
Upload: daniel-austin
View: 1,997 times
Download: 0 times
Share this document with a friend
Description:
This is my presentation from Percona Live! London last year. I describe my Big Data system built on MySQL/NDB and show that we can preserve the relational model for most Big Data purposes in the real world.
25
Percona Live! London, Oct. 25, 2011 v1.1 A Global In-memory Data System for MySQL Daniel Austin, PayPal Technical Staff
Transcript
Page 1: A Global In-memory Data System for MySQL

Percona Live! London, Oct. 25, 2011 v1.1

A Global In-memory Data System for MySQL

Daniel Austin, PayPal Technical Staff

Page 2: A Global In-memory Data System for MySQL

Confidential and Proprietary 2Global In-memory MySQL

Intro: Globalizing NDB

Proposed Architecture

What We Learned

Q&A

AGENDA

Page 3: A Global In-memory Data System for MySQL

Confidential and Proprietary

“UserBase: Develop a globally distributed DB For User-related data”

• Must Not Fail (99.999%)• Must Not Lose Data. Period.• Must Support Transactions• Must Be FAST• Must Support (some) SQL• May Be Buzzword-compliant (RFC 2119)

Our Mission

Page 4: A Global In-memory Data System for MySQL

Confidential and Proprietary

THE FUNDAMENTAL PROBLEM IN DISTRIBUTED DATA SYSTEMS

“How Do We Manage Reliable Distribution of Data Across Geographical Distances?”

Page 5: A Global In-memory Data System for MySQL

Confidential and Proprietary

• Modern NoSQL Systems as solutions– Hive, Cassandra, Mongo, 120+ more– Mostly designed for ‘Big Data’ problems– Low levels of maturity

• Trade-offs:– Consistency vs. Availability, Fault

Tolerance (dreaded CAP theorem)– Relational Model & X-actions dropped

To SQL or Not to SQL,’Tis the Query

Page 6: A Global In-memory Data System for MySQL

Confidential and Proprietary

• Availability of the entire system:

Asys = 1 – P(1-Pri)j

• Number of Parallel Components Needed to Achieve Availability Amin:

Nmin =

[ln(1-Amin)/ln(1-r)]

VIP

Serial

Para

llel

n

i = 1

m

j = 1

SYSTEM AVAILABILITY DEFINED

Page 7: A Global In-memory Data System for MySQL

Confidential and Proprietary

What about “High Performance”?

•Maximum lightspeed distance on Earth’s Surface: ~67 ms

•Target: data available worldwide in < 1000 ms

Sound Easy?

Think Again!

Page 8: A Global In-memory Data System for MySQL

Confidential and Proprietary 8Global In-memory MySQL

Intro: Globalizing NDB

Proposed Architecture

What We Learned

Q&A

Page 9: A Global In-memory Data System for MySQL

Confidential and Proprietary

WHY NDB?

Pro• True HA by design

– Fast recovery• Supports (some) X-

actions• Relational Model• In-memory

architecture = high performance

• Disk storage for non-indexed data (since 5.1)

• APIs, APIs, APIs

Con• Some semantic

limitations on fields• Size constraints (2

TB?) – Hardware limits

also• Higher cost/byte• Requires reasonable

data partitioning• Higher complexity

Page 10: A Global In-memory Data System for MySQL

Confidential and Proprietary

How NDB Works in One Slide

Graphics courtesy dev.mysql.com

Page 11: A Global In-memory Data System for MySQL

Confidential and Proprietary

CIRCULAR REPLICATION/FAILOVER

Graphics courtesy O’Reilly OnLamp.com

Page 12: A Global In-memory Data System for MySQL

Confidential and Proprietary

AWS Meets NDB

• Why AWS?– Cheap and easy infrastructure-in-a-box

(Or so we thought! Ha!)• Services Used:

– EC2 (Centos 5.3, small instances for mgm & query nodes, XL for data

– Elastic IPs/ELB– EBS Volumes– S3– Cloudwatch

Page 13: A Global In-memory Data System for MySQL

Confidential and Proprietary

ARCHITECTURAL TILES

Tiling Rules• Never separate NDB & SQL• Ndb:2-SQL:1-MGM:1• Scale by adding more tiles• Failover 1st to nearest AZ• Then to nearest DC• At least 1 replica/AZ• Don’t share nodes• Mgmt nodes are redundantLimitations• AWS is network-bound @

250 MBPS – ouch!• Need specific ACL across AZ

boundaries• AZs not uniform!• No GSLB• Dynamic IPs• ELB sticky sessions !reliable

A B

C

AWS Availability Zones

NDB SQLMGM

Unused (not present in all locations)

ELB

Page 14: A Global In-memory Data System for MySQL

Confidential and Proprietary

Architecture Stack

A B A B A B

A B A B

5 AWS Data Centers:US-E, US-W, TK, EU, AS

A BA B

Scale by Tiling

Page 15: A Global In-memory Data System for MySQL

Confidential and Proprietary

Other Technologies Considered

• Paxos– Elegant-but-complex consensus-based

messaging protocol– Used in Google Megastore, Bing metadata

• Java Query Caching– Queries as serialized objects– Not yet working

• Multiple Ring Architectures– Even more complicated = no way

Page 16: A Global In-memory Data System for MySQL

Confidential and Proprietary 16Global In-memory MySQL

Intro: Globalizing NDB

Proposed Architecture

What We Learned

Q&A

Page 17: A Global In-memory Data System for MySQL

Confidential and Proprietary

SYSTEM READ/WRITE PERFORMANCE (!)

What we tested:• 32 & 256 byte char fields• Reads, writes, query speed vs. volume• Data replication speedsResults:• Global replication < 350 ms• 256 byte read < 10ms worldwide

06/19/2011 06/20/2011 06/21/2011 06/22/2011 06/23/2011

In-region replication tests

Page 18: A Global In-memory Data System for MySQL

Confidential and Proprietary

Data Models and Query Optimization for NDB

• Network Latency is an obvious issue• Data model requires all segments present

in each geo-region• Parameterized (Linked) Joins

– SPJ technique from Clustra (see Clement Frazer’s blog for details)

Page 19: A Global In-memory Data System for MySQL

Confidential and Proprietary

Commit Ordering

• Why does commit ordering matter?• Write operators are non-commutative

[W(d,t1),W(d,t2)] != 0 unless t1=t2

– Can lead to inconsistency– Can lead to timestamp corruption– Forcing sequential writes defeats Amdahl’s

rul• Can show up in GSLB scenarios

Page 20: A Global In-memory Data System for MySQL

Confidential and Proprietary

Dark Side of AWS

• Deploying NDB at scale on AWS is hard– Dynamic IPs (use hostfile)– DNS issues – Security groups (ec2-authorize)– Inconsistent EC2 deployments

• Are availability zones independent network segments?

– No GSLB (!) (rent or buy)Be Prepared to struggle a bit!

Page 21: A Global In-memory Data System for MySQL

Confidential and Proprietary

NOTES ON GLOBAL LOAD BALANCING

• Don’t try this at home – Rent or buy a

solution– BGP-based solutions

are best• Deployment and config

for AWS are tough• We tried both Zeus and

Dyn– Liked Dyn better, $$

& ease of use• Absolutely crucial part

of infrastructure!

Graphics courtesy http://www.oes.co.th

Page 22: A Global In-memory Data System for MySQL

Confidential and Proprietary

Hard Lessons, Shared

• Be Careful…– With “Eventual Consistency”-related concepts– ACID, CAP are not really as well-defined as we’d like

considering how often we invoke them• NDB is a good solution

– Real HA, real SQL– Notable limitations around fields, datatypes– Successfully competes with NoSQL systems for most use

cases – better in many cases• NoSQL Systems

– All have relatively low levels of maturity– More suitable for simple key-value models– Better for very high volumes

Page 23: A Global In-memory Data System for MySQL

Confidential and Proprietary

Summing Up on v0.7

• It works!• Very fast, very reliable• Very complicated!• AWS poses challenges that private data

centers may not experience• You can achieve high performance and

availability without giving up relational models and read consistency!

Page 24: A Global In-memory Data System for MySQL

Confidential and Proprietary

Future Directions

• Alternate solution using Pacemaker, Heartbeat– From Yves Trudeau @ Percona– Uses InnoDB, not NDB

• Implement Memcached plugin– To test NoSQL functionality, APIs

• Add simple connection-based persistence to preserve connections during failover

• Better data node distribution• Better testing & monitoring

Page 25: A Global In-memory Data System for MySQL

Twitter: @daniel_b_austinEmai: [email protected]

“In the long run, we are all dead eventually consistent.”Maynard Keynes on NoSQL Databases

With apologies and thanks to the real DB experts, Andrew Goodman, Yves Trudeau, Clement Frazer, Daniel Abadi, and everyone else!


Recommended