66
© 2018 Percona. 1 Peter Zaitsev Using MySQL for Distributed Database Architectures CEO, Percona SCALE 16x, Pasadena, CA March 9, 2018

UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.1

PeterZaitsev

Using MySQL for Distributed DatabaseArchitectures

CEO,PerconaSCALE16x,Pasadena,CAMarch9,2018

Page 2: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.2

AboutPercona

SolutionsforyoursuccesswithMySQL,MariaDB andMongoDB

Support,ManagedServices,Consulting,Training,Software

OurSoftwareis100%FreeandOpenSource

SupportBroadEcosystem– MySQL,MariaDB,AmazonRDS,GoogleCloudSQL

InBusinessfor11years

Morethan3000customers,includingtopInternetcompaniesandenterprises

Page 3: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.3

Presentation

CoverBasics

WhyGoingDistributed

Howtodoit

Page 4: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.4

Distributed?

MySQLDeploymentonMorethanoneSystem

Page 5: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.5

ModernMySQLScalability

Page 6: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.6

SingleMySQLInstanceCanDo

HundredsofThousandsofQueries/Sec

TendsofThousandsofUpdates/Sec

TraverseTensofMillionsofRows/Sec

ComfortablyHandleSeveralTBDatabasesize

Page 7: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.7

LetsDoSomeMath100.000QPS

10QueriesperUserInteraction

10.000UserInteractions/sec

864.000.000UserInteractions/Day

30UserInteractions/UserAvg

28.000.000DailyActiveUsersPossible

15MofDailyActiveUserscountingtimeofdayskew

Page 8: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.8

DistributedSystemsTendTobe

MoreComplicatedtoDevelopAgainst

MoreComplicatedtoOperate

HaveAdditionalPerformanceBottlenecks

HaveComplicatedFailureModes

Page 9: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.9

WithAllofthis?

Why“GoDistributed”?

Page 10: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.10

Reasonsto“GoDistributed”

HighAvailability Scalability Data

Distribution

Page 11: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.11

HighAvailabilitywithMySQL

ColdStandby(ieDRBD)

Failover(ClassicalReplication)

Active-ActiveClustering(PXC,MySQLGroupReplication)

Page 12: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.12

Q1:WhatFailureModesDoyouConsider?

ServerCrash/ServerHardwareFailure

SoftwareBugsandStorageCorruption

NetworkFailure

“Datacenter”Failure

DeveloperMistakes/IntruderActions

Page 13: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.13

Q2:WhatDataAmIallowedtoloose?

LimitedDataLossAllowed

NoDataLoss

NoTransactionsInFlightLoss

Page 14: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.14

Q3:HowQuicklydoyouneedtoRecover?

“Immediate?”

“Seconds?”

“Minutes?”

“Hours?”

Page 15: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.15

SpeedofLightRealities

•Synchronous– Slow•Asynchronous–DataLossCanOccur

DataPropagation

CanBe

Page 16: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.16

Scalability

ScalingReads

ScalingWrites

ScalingDataSize

Page 17: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.17

DataDistribution

•UserLatencyReasons•LegalandComplianceReasons

SomeDataMustbeinSpecific

GeographicLocation

Page 18: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.18

DistributedArchitectureswithMySQL

Page 19: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.19

MainConcepts

Replication

Sharding

FailoverManagement

TrafficManagement

Page 20: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.20

Replication

HavingMultipleCopiesofthedata,updatedwithchanges

Page 21: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.21

Availability

ServiceStaysupwhencomponentfails

Page 22: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.22

AvailabilityviaRedundancy

Havemorethanonesystem

Workswellforstatelesssystems

Isnotenoughfordatabases

Page 23: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.23

AvailabilityviaReplication

RedundantComputingResource

PairedwithReplicated

Data

Page 24: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.24

WhereReplicationHappens

StorageLevel

DatabaseLevel

ApplicationLevel

Page 25: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.25

StorageLevelReplication

ReplicationinSAN/NAS,DRBD

Typicallyprovidescoldstandby

Simplechoicewhichworkswithmanysystems

AmazonAurora– SmartStorage

Page 26: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.26

Databaselevel

MostFlexible

MostCommon

Hot/WarmSpare

SomecandoActive-Active

Page 27: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.27

ApplicationLevel

Hardtogetright

Rarelyused,especially“usedright”

PartialReplication/Syncronization

Smartconflictresolution

CrossVendorRedundancy

Page 28: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.28

Sharding

Splitdatasetbycertaincriteriaandstoresuch“shards”onseparate“clusters”

Page 29: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.29

TypicalSharding

ByUser

ByCustomerAccount/Company

Page 30: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.30

Sharding andReplication

ShardingAlmostAlwaysusedwithsomekindof

Replication

Page 31: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.31

FailoverManagement

ManyReplicationModesRequire“Failover”

NeedsomeToolToDecideonFailover

NeedsomeTooltoPerformFailover

Page 32: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.32

TrafficManagement

ScalingwithLargeNumberofConnections

RoutingTraffictoRight“Shard”

Read-WriteSplitting

LoadManagement

Avoiding“Dead”Nodes

Page 33: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.33

OptionsinMySQL

Page 34: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.34

ReplicationOptionsinMySQL

ClassicalMySQLReplication

MySQLGroupReplication

PerconaXtraDBClusterandGalera

MySQL(NDB)Cluster

Page 35: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.35

ClassicalMySQLReplication

Page 36: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.36

ClassicalMySQLReplicationProperties

AsynchronousorSemi-Synchronous

Parallel(sinceMySQL5.7)

ManyMasterstoManySlaves(MySQL5.7)

NoConflictResolutionor“Protection”

NoBuilt-inFailover

Page 37: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.37

AdvancedMySQLReplicationTopologies

Page 38: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.38

PMMDashboardforReplication

Page 39: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.39

MySQLGroupReplication

Page 40: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.40

MySQLGroupReplication(Newin5.7)

“GroupofPeers”

Write-AnywhereorDedicatedWriter

AsynchronousReplicationwithFlowControl

ConflictsPreventedthroughCertification

BuiltinFailover

NoAutomatedProvisioning

Page 41: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.41

PerconaXtraDB Cluster/Galera

Page 42: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.42

PerconaXtraDB ClusterTopology

Page 43: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.43

PXC/Galera Properties

WritetoAnyNode

CertificationBasedReplication

VirtuallySynchronous;Canensurenostalereads

BuiltinFail-Over

Built-inNodeProvisioning

Page 44: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.44

TransactionCommitFlow

Page 45: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.45

PXC5.7PerformanceImprovementshttp://bit.ly/2qGCr0T andhttp://bit.ly/2pzvAIW

Page 46: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.46

PMMDashboardforPXC

Page 47: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.47

MySQLCluster

MostlyInMemoryStorage

SynchronousReplication

PessimisticLocking

ConflictDetectionwithAsyncReplication

NicheUseOnly

Page 48: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.48

Sharding inMySQL

TypicallyPainfulorVeryPainful

NoBuilt-InorStandardSolution

ManyCustomApp-LayerImplementationExists

Page 49: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.49

ThinkingaboutSharding

QueryRoutingtotherightShard

DataAggregationforCross-ShardQueries

ShardBalancing

Page 50: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.50

StatedbyteaminYouTube

NowOpenSourceinCNCF

DeployedatSlack

SupportsMySQLProtocol

SupportsCrossShardQueries

SupportsRe-Sharding

Vitess

Page 51: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.51

Vitess Architecture

Page 52: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.52

FailoverinMySQL

MHA

MySQLFailover

Orchestrator

Page 53: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.53

OrchestratorScreenshot

Page 54: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.54

TrafficManagementSolutions• NotImmediate,DoesnothandleexistingconnectionsDNS

• TCP/IPPortlevel.DoesnotunderstandMySQLProtocolHAProxy

• LikeHAProxyintheCloudElasticLoadBalancer(etc)

• CurrentlyverybasicMySQLRouter

• ProprietarySolutionsMaxScale,ScaleArc

• MySQLProtocolAware100%OpenSourceProxySolutionforMySQLProxySQL

Page 55: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.55

• 100%OpenSource• WellSupported• Read-WriteSplitting• Caching• QueryRewrites• LoadBalancing• 10k+ConnectionSupport

ProxySQL

Page 56: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.56

DedicatedsharedProxySQL 56

application server 1 application server 2 application server 3

PXC node 1 PXC node 2 PXC node 3

ProxySQL

Page 57: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.57

ProxySQL onapplicationsideapplication server 1 application server 2 application server 3

PXC node 1 PXC node 2 PXC node 3

57

ProxySQL ProxySQL ProxySQL

Page 58: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.58

ProxySQL atPMM

Page 59: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.59

CloudOnlyOptions

•AmazonRDS•AmazonAurora•GoogleCloudSQL•AzureDatabaseforMySQL

DBaaSinthecloudcomeswithbuilt-inHAOptions

Page 60: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.60

BeyondMySQL

Page 61: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.61

MySQLisaPartofyourDataInfrastructure

MySQLisGoodforManyThingsbutMySQLisnotGoodforEverything

Page 62: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.62

MySQLcanbeusedtogetherwith

Caching

• Redis,Memcache

FullTextSearch

• Elastic,Solr

Queue/StreamProcessing

• Kafka

AnalyticsatScale

• Hadoop,Clickhouse

Page 63: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.63

CrossTechnologyReplication

• SymmetricDS,Self-MadeSolutionTriggerBased

ReplicationTools

• Debezium,Yelp’sMySQLStreamerKafkaGateway

• ReplicationfromMySQLtoVarietyDataStoresTungstenReplicator

• MySQLtoTarantoolReplication• MySQLtoClickHouseReplication

CustomBinarLogConsumers

Page 64: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.64

Summary

LotsofOptionsExistforBuildingDistributedArchitectureswithMySQL

LotsofOptionforIntegratingMySQLwithotherOpenSourceDataStores

Page 65: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.65

Usecode10ATTENDPL18for10%discount!

Page 66: UsingMySQLforDistributedDatabase Architectures · © 2018 Percona. 2 About Percona Solutions for your success with MySQL,MariaDBand MongoDB Support, Managed Services, Consulting,

©2018Percona.66

ThankYou!