Scaling MySQL -- NY Code Camp

Post on 14-Aug-2015

212 views 0 download

Tags:

transcript

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

1

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

2

Insert Picture Here

MySQL Scaling§ Dave Stokes

MySQL Community Manager

David.Stokes@Oracle.com

@stoker

slideshare.net/davestokes

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

3

Safe Harbor Agreement

.The following is intended to outline our general product direction. It is

intended for information purposes only, and may not be incorporated into

any contract. It is not a commitment to deliver any material, code, or

functionality, and should not be relied upon in making purchasing decision.

The development, release, and timing of any features or functionality

described for Oracle’s products remains at the sole discretion of Oracle.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

4

You want to get a bigger, badder MySQL --BUT what are the costs???

Budget

Complexity

Application

Opportunity

Sanity!

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

5

LAMP Stack https://en.wikipedia.org/wiki/LAMP_(software_bundle)

LAMP is an archetypal model of web service solution stacks, named as an acronym of the names of its original four open-source components: the Linux operating system, the Apache HTTP Server, the MySQL relational database management system (RDBMS), and the PHP programming language. The LAMP components are largely interchangeable and not limited to the original selection. As a solution stack, LAMP is suitable for building dynamic web sites and web applications.

Since its creation, the LAMP model has been adapted to other componentry, though typically consisting of free and open-source software. For example, an equivalent installation on the Microsoft Windows family of operating systems is known as WAMP.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

6

Simple Stuff

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

7

Option 0

Run the Latest, Greatest MySQL

MySQL 5.5 was 20% faster than 5.1! 5.6 is another 10-15%

--Make sure your config file matches your hardware

--ANALYSE TABLE – Maintenance of indexes, statistics

--Check for SLOW QUERIES, QUERIES w/o INDEXES

--TUNE QUERIES

This is the least complex, less upsetting, and usually lowest budget cost option

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

8

Option 0.1

Add in a Memcached Layer

● Cache for quick access

● Session Data

● Sports Scores

● Opens up NoSQL accessto InnoDB later

This is the second least complex, less upsetting, and usually lowest budget cost

option but does make you change your application to become 'cache aware'.

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

9

Insert Picture Here

What database serviceLevels do you Need toProvide?

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

10

UpTime versus Response Time versus Access

Things to be engineered/negotiated upfront

Up Time

– How much down time can you afford?

Response Time

– How long is too long to wait?

Access

– How many do you need to serve simultaneously.

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

11

Vertical Scaling

● Sometimes a newer, bigger server is the next logical step

● All eggs in newer basket

● Not limitless

● Tossing $$ at problem

● Transition pain

● May not openbottlenecks

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

12

Insert Picture Here

Simple Level 1 -Splitting Reads /Writes

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

13

Use MySQL Replication to Split Read/Writes

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

14

MySQL Replication

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

15

READ Splitting

Most Common Scaling Technique

● More complex environment

● Application Changes

● Easier with PHP & Java

● Low opportunity and sanity costs

● Less risk of one server stopping operations

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

16

https://blog.engineyard.com/2014/easy-read-write-splitting-php-mysqlnd

● PHP Developers Have it Easy!

● Use the mysqlnd_ms Native Driver Extension

– Read/write splits

– Load balancing

– No change to application

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

17

Read Splitting—Easy Way

Use MySQL Utilities to copy master, set up failover

● mysqlserverclone

● mysqlfailover

– When master dies, most up to date slave (GTID) promoted automatically

● Mysqlrplcheck & mysqlrplshow

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

18

MySQL Fabric

● Set up highly available groups of servers or shards

● 'Smarts' in the controller, no change to application

● Automatic fail over

● Re - shard on the fly

● As easy yo set up asreplication

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

19

Insert Picture Here

Simple Level 2Moderately Easy, BetterAvailability

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

20

Distributed ReplicatedBlock Device (DRBD)

● High Availability

More complex environment

● Proven, supported

● Please practice fail over

and back

● Easy to manage but

not HA panacea

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

21

Cloud

High Availability, low cost (sometimes)

Slightly more complex environment

● Proven, supported

● Best for ephemeral data, may not make upper management

comfortable (or you)

● Easy to manage but not HA panacea

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

22

Insert Picture HereComplex Level N^NNever, Ever Down

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

23

MySQL ClusterFor 99.999% uptime, upper bound on response time

Extremely Complex

● No single point of

failure = lots of $$

hardware

● Not general

purpose MySQL

Auto sharding

● Add/Subtract nodes at will

● Replicate between

geographically separated

locations

● Need a smart staff

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

24

MySQL Cluster Shards Data Automatically

● Single or multiple data node failures do not bring down a cluster

● Easy to add/remove data nodes

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

25

MySQL Cluster Topology

● Nodes

– MGMT – startup/add node

– Data – Where data lives

– Mysql – the RDMS

● Can be engineered for no

single point of failure

● Easily replicate across data centers

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

26

Insert Picture HereBigData

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

27

Ask ten DBAs to define 'Big Data' and You WillGet At Least Eleven Answers

● BIG as massive amounts

– Define MASSIVE

● BIG as in fast

● Define fast

● BIG as lots of eyes

● BIG as all of the the above!!!

● How many simultaneous users

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

28

The Three Vs of Big Data

● Volume

● Variety

● Velocity

● (maybe) Veracity

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

29

End Goal of your Big Data?

● Never, ever toss any data away?

● How will be it managed, examined, maintained, documented, and used?

● Latent needs?

● Data warehouse or Digital Landfill

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

30

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

31

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

32

The Easiest Way to Get Speed

NoSQL/Memcached to InnoDB/NBD

● 9x faster by skipping parser, optimizer

● Key/Value pair access

and SQL access of same data

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

33

Easiest Way to Gain Size

Columnar Storage Engines for MySQL

● Not InnoDB

● Unique features, quirks

● Need > 26,000,000,000 rows to start seeing 'sweet spot'

● Use new server, don't scrimp

See Calpont and Infobright

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

34

Hadoop-- getting data from MySQL to Hadoop

80% of Hadoop Installations feed from MySQL

● Hadoop is made up of several components

● Twisty little maze, all alike

● Use Apache Bigtop

– Tested for interoperability

● Cloudera & Horton Works have great tutorials

● Kinda 'SQL-ish'

● Squoop and MySQL Hadoop Applier to move data

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

35

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

36

Partitioning and Sharding /Dividing and Conquering

Partitions built-in to MySQL

● Nice management tool

– Rolling quarters/months

– Fast drops

● No change to application but

higher complexity, low

opportunity cost

Sharding

● Much more complex

application and operations

● Not off shelf

● Hard to re-engineer

● Works

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

37

MySQL Fabric

● Lets you shard and reshard

● Very new

● Looking for feedback

● Http://labs.mysql.com

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

38

Insert Picture Here

Wrap up

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

39

Goals – What are you trying toaccomplishDefine problem completely

● Who produces, who consumes

data

● Negotiate performance rates

● Plan for failure, catastrophe

● Design for long life

What does end solution look/feel like?

● Platforms

● Speed

● Access areas

● Security

● Serenity

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

40

MySQL Marinate

● Free virtual class to learn MySQL run by the Boston MySQL Users Group

– 1 chapter a week

– Homework graded helpfully

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

41

MySQL Connect

● San Francisco● September 27th – October 2nd

● LA MySQL User Group will have some passes to raffle

● How do we discount for other groups?

Copyright © 2015, Oracle and/or its affiliates. All rights reserved.

42

Q&A

David.Stokes@Oracle.com @stoker

slideshare.net/davestokes

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

43

Insert Picture Here

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

44

Graphic Section Divider