MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

56
© 2017 Percona 1 Dimitri Vanoverbeke (credits to Peter Zaitsev) MySQL In the Cloud Migra<on, Best Prac<ces, High Availability, Scaling Solu<on Engineer Percona University Ghent June 22th of 2017

Transcript of MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

Page 1: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona1

DimitriVanoverbeke(creditstoPeterZaitsev)

MySQLIntheCloudMigra<on,BestPrac<ces,HighAvailability,Scaling

Solu<onEngineerPerconaUniversityGhentJune22thof2017

Page 2: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona2

WhoamISolu>onengineerwithinPercona!www.twiCer.com/dim0(Personalviewsandpoten>allyNSFW)

Page 3: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona3

Letmestart….

WithsomeQues>ons!

Page 4: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona4

Ques>onOne

HowManyofyouarerunningMySQL

IntheCloud?

Page 5: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona5

Ques>onTwo

AreyourunningitinPublicCloud?PrivateCloud?

Both?

Page 6: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona6

Ques>onThree?

AreyouusingDBaaSsuchasAmazonRDSorGoogleCloudSQL?

Page 7: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona7

Ques>onFour

AreyouusingContainers?

Page 8: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona8

LetsCoversomeBasics

Page 9: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona9

Whatis“Cloud”

DynamicProgrammableInfrastructure

Page 10: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona10

PublicandPrivate

Public

• InfrastructureSharedwithotherUsers

• AmazonAWStypicalexample

Private

• InfrastructurePrivateforcompany

• OpenStackinstalla<ontypicalexample

Page 11: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona11

AllofthoseXaaS

• WorksinInfrastructurelevel:“Compute”,“Storage”,“Network”

•  Examples:AWSEC2,S3,EBS

IaaS(Infrastructureasaservice)

•  ProvidesDatabaseService(InstancesorClusters)touse•  Examples:AmazonRDS,GoogleSpanner

DBaaS(Databaseasaservice)

•  Providesfullpla[ormforyourapplica<ondevelopment•  Examples:Heroku,AmazonElas<cBeanstalk,OpenShi\

PaaS(Placormasaservice)

Page 12: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona12

RegionsandAvailabilityZones

Region

• SpecifiesGeographicRegion• Hierarchy-Europe–West–Ireland

• HighLatencybetweenRegions

• CompleteIsola<on

AvailabilityZone

•  Islocatedintheregion• Reasonablyisolatedfromeachother

• MediumLatencybetweenAZ

Page 13: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona13

MakingitVisual

Source:haps://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html

Page 14: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona14

TopCloudProviders

Page 15: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona15

Technologiestobeawareof

Page 16: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona16

DecisionstoMake

Page 17: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona17

Shouldyoumovetothecloud?

Thisisdecisionyourarelyhave

Programmableinfrastructureisthefuture

Virtualiza>onoverheadisgoingdown

SomecloudsproviderssupportBareMetal

Page 18: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona18

Public?Private?Hybrid

PublicCloud

• Agility• Scalability• Costs• SmallandMediumBusinesses

PrivateCloud

• Control• Costs• LegacyIntegra<on

• SomeEnterpriseCompanies

HybridCloud

• InfrastructureusingBoth

• Cangetbenefitsofboth

• Atthecostofextracomplexity

Page 19: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona19

SinglevendorvsMul>Vendor

SingleVendor

• Useallfeaturesvendorhastooffer

• DangerofVendorLockIn

Mul>Vendor

• Havetouse“lowestcommondenominator”

• AvoidVendorLockIn

Page 20: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona20

DBaaS

DBaaS(ieAmazonRDS)

• Easier• Takesoffsomeopera<onalpains

• LessFlexible• MoreExpensive• MoreLock-In

IaaS(ieEC2+EBS+S3)

• Hardertorollyourown• Opera<onsonyourown(oryourpartner)

• MoreFlexible• LessExpensive• LessLock-In

Page 21: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona21

OpenSourceintheCloud

OpenSourceCompa>bleisnotsameasOpen

Source

Page 22: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona22

Migra>on

Page 23: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona23

KeepitSimple

Donottrydoingupgradeatthesame>measmigra>on

Exactlysameminorversionisop>mal

Samemajorversion-must

Page 24: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona24

MovingtoIaaSCloud

GeneralPrac>cesasinDatacenterMigra>onsapply

EasytouseBinaryBackups

Slave_compressed_protocolorcompressioninVPN

Supportu>li>esmayneedtobemodifiedforEBS/S3

Page 25: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona25

MovingtoDBaaS•  Mysqldump•  Mysqlpump•  Mydumper

Needtousedatabasedumptocopy

•  CALLmysql.rds_set_external_masterCansetexternalslave

(AmazonRDS)

•  Donothavedirectaccesstophysicalbox•  Donothaverootuser

MonitoringBackupmayneedrevision

Page 26: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona26

NewWithAmazonRDSAurora

CanusePerconaXtrabackup’sBackupto

seedtheclusterhCp://amzn.to/2pk6Iq7

Page 27: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona27

MovingfromDBaaS

LogicalDatabasedumpaswell

Replica>onsupportedforMigra>ononly

ConfigureBinaryLogReten>onmysql.rds_set_configura3on

Page 28: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona28

BestPrac>ces

Page 29: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona29

BeingCostEfficient

Knowyourcloudvendorpricingpolicies

Lookbeyond“compute”pricing

BestPrice/Performanceconfigura>oninthecloudislikelytobedifferent

AWS:ReserveInstances

AWS:SpotInstances

Page 30: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona30

GuaranteeversusBurst

Guaranteed

• Performanceresourceis“guaranteed”tohaveinworstcasescenario

• Thisiswhatyoucanplanfor

Burst

• Performanceresourcecanprovide

• Typicallynotguaranteed• Typicallylimitedinlengthtopreventabuse

Page 31: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona31

Network

UnderstandApplica>on-DatabaseNetworkLatency

SameAZOp>mal;SameRegionMusthave

10GbNetwork

Understandnetwork“jiCer”

Latencyiscri>calformostapplica>ons

Bandwidthcanbeimportantfordumpsandbatchjob

Page 32: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona32

CPU

Samewheneveryou’reinthecloudornot

MySQLusessinglethreadforsinglequery

Mul>-Coregivesgoodscalabilityfor“Web”workloads

Page 33: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona33

Memory

Usemainlyasacache

VeryimportantforPerformance

Page 34: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona34

StorageInstanceLocal

Storage

• Mayormaynotbeavailable

• NotHighlyavailable

• MaybeinexpensiveandhighPerformance

CloudBlockStorage

• Reliable• Remote•  SeparatelyPrices• EBSonAWS

File/ObjectStorage

•  StoreFiles/Objects

• Nointerac<veblocklevelaccess

•  S3onAWS

Page 35: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona35

ThingstoNote

Youcan’tgetanycombina>on

EBSPerformancedependsontheinstancesize

ProvisionedIOPsforOp>malPerformance

Glacierstorageforoldbackups

Page 36: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona36

Opera>ngSystem

ConsiderCloudOp>mizedLinuxVersions

AtveryleastuseRecentLinuxVersions

“CloudOnly”Linuxmightbeinconvenientfordevelopment

Page 37: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona37

MySQLVersionandConfigura>on

UseRecentVersion

DonotcountongoodDefaults

Page 38: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona38

DBaaS

Thereisessen>allysamesystemsunderneath!

Mostofsameprac>cesApply

Page 39: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona39

DBaaSisnotalwaysfaster

Source:haps://twindb.com/rds-vs-aurora-vs-ec2-benchmark/

Page 40: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona40

HighAvailability

Page 41: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona41

YourChoices

Rollyourown

UseDBaaS

Page 42: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona42

ThingstoConsider

Youhavelesscontrolorvisibilityintotheinfrastructure

ThingsasIPtake–overmightnotwork

Page 43: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona43

LoadBalancers

CloudLoadBalancer(Elas>cLoadBalanceratAWS)

HAProxy

ProxySQL

Page 44: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona44

MaintainingcopiesofData

MySQLReplica>on

MySQLGroupReplica>on

PerconaXtraDBReplica>on(PXC)andGalera

Page 45: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona45

WhyPerconaXtraDBClusterintheCloud

Read/Writetoanynodeworksgreatwithsimpleloadbalancers

Automa>cProvisioningandAutoScaling

Canrunwithlocalinstancestorage

Candeployacrossmul>pleAZ

Page 46: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona46

Scaling

Page 47: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona47

ScalabilityintheCloud

“BeCer”

• Duetocloudop<mizedop<onslikeAmazonAurora

“Worse”

• Duetorestrictedhardwarechoices

Page 48: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona48

ScalingHow

ScaleUp

• Ver<calScaling• ScalewiththeHarwareSize–CPUs,Memory,Storage

ScaleOut

• HorizontalScaling• Scalebyaddingnodes

Page 49: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona49

Badreputa>onofScalingUp…but

• 3-5TBdatabasesize• 100K+queries/sec• 5M+rowsread/sec• 100Krowsmodified/sec

ReasonablecommodityMySQL

ServerCanhandle

Page 50: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona50

ScalingWhat?

Reads

Writes

DataSize

Page 51: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona51

ScalingReads

Replica>on

Caching

MovingsomeloadfromMySQL

Page 52: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona52

ScalingWrites

NewMySQLVersions

ParallelReplica>on

TokuDB

Func>onalPar>>oning

Sharding

Page 53: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona53

NewinSharding

ProxySQL

Vitess

Page 54: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona54

ScalingDataSize

Func>onalPar>>oningandSharding

DataArchiving

TokuDBforCompression

OuenOpera>onsdrivethisneedsnotAppPerformance

Page 55: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

©2017Percona55

PerconaLiveEuropeCallforPapers&Registra>onareOpen!

ChampioningOpenSourceDatabases▪ MySQL,MongoDB,OpenSourceDatabases▪ TimeSeriesDatabases,PostgreSQL,RocksDB▪ Developers,Business/CaseStudies,Opera<ons▪ September25-27th,2017▪ RadissonBluRoyalHotel,Dublin,Ireland

SubmitYourProposalbyJuly17th!www.percona.com/live/e17

Page 56: MySQL In the Cloud - Percona€¦ · MySQL In the Cloud Migraon, Best Prac

DATABASE PERFORMANCE MATTERS DatabasePerformanceMaCersDatabasePerformanceMaCersDatabasePerformanceMaCersDatabasePerformanceMaCersDatabasePerformanceMaCers