MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability,...

55
© 2017 Percona 1 Peter Zaitsev MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup June 12 th , 2017

Transcript of MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability,...

Page 1: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona1

PeterZaitsev

MySQLIntheCloudMigration,BestPractices,HighAvailability,Scaling

CEOLosAngelesMySQLMeetupJune12th,2017

Page 2: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona2

Letmestart….

WithsomeQuestions!

Page 3: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona3

QuestionOne

HowManyofyouarerunningMySQLInthe

Cloud?

Page 4: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona4

QuestionTwo

AreyourunningitinPublicCloud?Private

Cloud?Both?

Page 5: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona5

QuestionThree?

AreyouusingDBaaSsuchasAmazonRDSorGoogleCloudSQLorrunningyourown?

Page 6: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona6

QuestionFour

AreyouusingContainers?(SuchasDocker)

Page 7: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona7

LetsCoversomeBasics

Page 8: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona8

Whatis“Cloud”

DynamicProgrammableInfrastructure

Page 9: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona9

PublicandPrivate

Public

•InfrastructureSharedwithotherUsers

•AmazonAWStypicalexample

Private

•InfrastructurePrivateforcompany

•OpenStackinstallationtypicalexample

Page 10: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona10

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

• Examples:AWSEC2,S3,EBS

IaaS(Infrastructureasaservice)

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

DBaaS(Databaseasaservice)

• Providesfullplatformforyourapplicationdevelopment• Examples:Heroku,AmazonElasticBeanstalk,OpenShift

PaaS(Platformasaservice)

Page 11: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona11

RegionsandAvailabilityZones

Region

• SpecifiesGeographicRegion• Hierarchy- NorthAmerica–West– California

• HighLatencybetweenRegions

• CompleteIsolation

AvailabilityZone

• Islocatedintheregion• Reasonablyisolatedfromeachother

• MediumLatencybetweenAZ

Page 12: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona12

MakingitVisual

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

Page 13: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona13

TopCloudProviders

Page 14: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona14

Technologiestobeawareof

Page 15: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona15

DecisionstoMake

Page 16: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona16

Shouldyoumovetothecloud?

Thisisdecisionyourarelyhave

Programmableinfrastructureisthefuture

Virtualizationoverheadisgoingdown

SomecloudsproviderssupportBareMetal

Page 17: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona17

Public?Private?Hybrid

PublicCloud

• Agility• Scalability• Costs• SmallandMediumBusinesses

PrivateCloud

• Control• Costs• LegacyIntegration

• SomeEnterpriseCompanies

HybridCloud

• InfrastructureusingBoth

• Cangetbenefitsofboth

• Atthecostofextracomplexity

Page 18: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona18

SinglevendorvsMultiVendor

SingleVendor

•Useallfeaturesvendorhastooffer

•DangerofVendorLockIn

MultiVendor

•Havetouse“lowestcommondenominator”

•AvoidVendorLockIn

Page 19: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona19

DBaaS

DBaaS(ieAmazonRDS)

• Easier• Takesoffsomeoperationalpains

• LessFlexible• MoreExpensive• MoreLock-In

IaaS(ieEC2+EBS+S3)

• Hardertorollyourown• Operationsonyourown(oryourpartner)

• MoreFlexible• LessExpensive• LessLock-In

Page 20: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona20

OpenSourceintheCloud

OpenSourceCompatibleisnotsameasOpen

Source

Page 21: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona21

Migration

Page 22: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona22

KeepitSimple

Donottrydoingupgradeatthesametimeasmigration

Exactlysameminorversionisoptimal

Samemajorversion- must

Page 23: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona23

MovingtoIaaSCloud

GeneralPracticesasinDatacenterMigrationsapply

EasytouseBinaryBackups

Slave_compressed_protocolorcompressioninVPN

SupportutilitiesmayneedtobemodifiedforEBS/S3

Page 24: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona24

MovingtoDBaaS• Mysqldump• Mysqlpump• Mydumper

Needtousedatabasedumptocopy

• CALLmysql.rds_set_external_masterCansetexternalslave

(AmazonRDS)

• Donothavedirectaccesstophysicalbox• Donothaverootuser

MonitoringBackupmayneedrevision

Page 25: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona25

NewWithAmazonRDSAurora

CanusePerconaXtrabackup’sBackupto

seedtheclusterhttp://amzn.to/2pk6Iq7

Page 26: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona26

MovingfromDBaaS

LogicalDatabasedumpaswell

ReplicationsupportedforMigrationonly

ConfigureBinaryLogRetentionmysql.rds_set_configuration

Page 27: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona27

BestPractices

Page 28: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona28

BeingCostEfficient

Knowyourcloudvendorpricingpolicies

Lookbeyond“compute”pricing

BestPrice/Performanceconfigurationinthecloudislikelytobedifferent

AWS:ReserveInstances

AWS:SpotInstances

Page 29: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona29

GuaranteeversusBurst

Guaranteed

•Performanceresourceis“guaranteed”tohaveinworstcasescenario

•Thisiswhatyoucanplanfor

Burst

•Performanceresourcecanprovide

•Typicallynotguaranteed•Typicallylimitedinlengthtopreventabuse

Page 30: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona30

Network

UnderstandApplication-DatabaseNetworkLatency

SameAZOptimal;SameRegionMusthave

10GbNetwork

Understandnetwork“jitter”

Latencyiscriticalformostapplications

Bandwidthcanbeimportantfordumpsandbatchjob

Page 31: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona31

CPU

Samewheneveryou’reinthecloudornot

MySQLusessinglethreadforsinglequery

Multi-Coregivesgoodscalabilityfor“Web”workloads

Page 32: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona32

Memory

Usemainlyasacache

VeryimportantforPerformance

Page 33: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona33

StorageInstanceLocal

Storage

• Mayormaynotbeavailable

• NotHighlyavailable

• MaybeinexpensiveandhighPerformance

CloudBlockStorage

• Reliable• Remote• SeparatelyPrices• EBSonAWS

File/ObjectStorage

• StoreFiles/Objects• Nointeractiveblocklevelaccess

• S3onAWS

Page 34: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona34

ThingstoNote

Youcan’tgetanycombination

EBSPerformancedependsontheinstancesize

ProvisionedIOPsforOptimalPerformance

Glacierstorageforoldbackups

Page 35: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona35

OperatingSystem

ConsiderCloudOptimizedLinuxVersions

AtveryleastuseRecentLinuxVersions

“CloudOnly”Linuxmightbeinconvenientfordevelopment

Page 36: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona36

MySQLVersionandConfiguration

UseRecentVersion

DonotcountongoodDefaults

Page 37: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona37

DBaaS

Thereisessentiallysamesystemsunderneath!

MostofsamepracticesApply

Page 38: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona38

DBaaS isnotalwaysfaster

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

Page 39: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona39

HighAvailability

Page 40: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona40

YourChoices

Rollyourown

UseDBaaS

Page 41: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona41

ThingstoConsider

Youhavelesscontrolorvisibilityintotheinfrastructure

ThingsasIPtake–overmightnotwork

Page 42: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona42

LoadBalancers

CloudLoadBalancer(ElasticLoadBalanceratAWS)

HAProxy

ProxySQL

Page 43: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona43

MaintainingcopiesofData

MySQLReplication

MySQLGroupReplication

PerconaXtraDBReplication(PXC)andGalera

Page 44: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona44

WhyPerconaXtraDB ClusterintheCloud

Read/Writetoanynodeworksgreatwithsimpleloadbalancers

AutomaticProvisioningandAutoScaling

Canrunwithlocalinstancestorage

CandeployacrossmultipleAZ

Page 45: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona45

Scaling

Page 46: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona46

ScalabilityintheCloud

“Better”

•DuetocloudoptimizedoptionslikeAmazonAurora

“Worse”

•Duetorestrictedhardwarechoices

Page 47: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona47

ScalingHow

ScaleUp

•VerticalScaling•ScalewiththeHarwareSize– CPUs,Memory,Storage

ScaleOut

•HorizontalScaling•Scalebyaddingnodes

Page 48: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona48

BadreputationofScalingUp…but

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

ReasonablecommodityMySQL

ServerCanhandle

Page 49: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona49

ScalingWhat?

Reads

Writes

DataSize

Page 50: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona50

ScalingReads

Replication

Caching

MovingsomeloadfromMySQL

Page 51: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona51

ScalingWrites

NewMySQLVersions

ParallelReplication

TokuDB

FunctionalPartitioning

Sharding

Page 52: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona52

NewinSharding

ProxySQL

Vitess

Page 53: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona53

ScalingDataSize

FunctionalPartitioningandSharding

DataArchiving

TokuDBforCompression

OftenOperationsdrivethisneedsnotAppPerformance

Page 54: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

©2017Percona54

PerconaLiveEuropeCallforPapers&RegistrationareOpen!

ChampioningOpenSourceDatabases▪MySQL,MongoDB,OpenSourceDatabases▪TimeSeriesDatabases,PostgreSQL,RocksDB▪Developers,Business/CaseStudies,Operations▪September25-27th,2017▪RadissonBlu RoyalHotel,Dublin,Ireland

SubmitYourProposalbyJuly17th!www.percona.com/live/e17

Page 55: MySQL In the Cloud - Percona · MySQL In the Cloud Migration, Best Practices, High Availability, Scaling CEO Los Angeles MySQL Meetup ... •Amazon AWS typical example Private •Infrastructure

DATABASE PERFORMANCEMATTERS

DatabasePerformanceMattersDatabasePerformanceMattersDatabasePerformanceMattersDatabasePerformanceMattersDatabasePerformanceMatters