©2018Percona.1
PeterZaitsev
Using MySQL for Distributed DatabaseArchitectures
CEO,PerconaSCALE16x,Pasadena,CAMarch9,2018
©2018Percona.2
AboutPercona
SolutionsforyoursuccesswithMySQL,MariaDB andMongoDB
Support,ManagedServices,Consulting,Training,Software
OurSoftwareis100%FreeandOpenSource
SupportBroadEcosystem– MySQL,MariaDB,AmazonRDS,GoogleCloudSQL
InBusinessfor11years
Morethan3000customers,includingtopInternetcompaniesandenterprises
©2018Percona.3
Presentation
CoverBasics
WhyGoingDistributed
Howtodoit
©2018Percona.4
Distributed?
MySQLDeploymentonMorethanoneSystem
©2018Percona.5
ModernMySQLScalability
©2018Percona.6
SingleMySQLInstanceCanDo
HundredsofThousandsofQueries/Sec
TendsofThousandsofUpdates/Sec
TraverseTensofMillionsofRows/Sec
ComfortablyHandleSeveralTBDatabasesize
©2018Percona.7
LetsDoSomeMath100.000QPS
10QueriesperUserInteraction
10.000UserInteractions/sec
864.000.000UserInteractions/Day
30UserInteractions/UserAvg
28.000.000DailyActiveUsersPossible
15MofDailyActiveUserscountingtimeofdayskew
©2018Percona.8
DistributedSystemsTendTobe
MoreComplicatedtoDevelopAgainst
MoreComplicatedtoOperate
HaveAdditionalPerformanceBottlenecks
HaveComplicatedFailureModes
©2018Percona.9
WithAllofthis?
Why“GoDistributed”?
©2018Percona.10
Reasonsto“GoDistributed”
HighAvailability Scalability Data
Distribution
©2018Percona.11
HighAvailabilitywithMySQL
ColdStandby(ieDRBD)
Failover(ClassicalReplication)
Active-ActiveClustering(PXC,MySQLGroupReplication)
©2018Percona.12
Q1:WhatFailureModesDoyouConsider?
ServerCrash/ServerHardwareFailure
SoftwareBugsandStorageCorruption
NetworkFailure
“Datacenter”Failure
DeveloperMistakes/IntruderActions
©2018Percona.13
Q2:WhatDataAmIallowedtoloose?
LimitedDataLossAllowed
NoDataLoss
NoTransactionsInFlightLoss
©2018Percona.14
Q3:HowQuicklydoyouneedtoRecover?
“Immediate?”
“Seconds?”
“Minutes?”
“Hours?”
©2018Percona.15
SpeedofLightRealities
•Synchronous– Slow•Asynchronous–DataLossCanOccur
DataPropagation
CanBe
©2018Percona.16
Scalability
ScalingReads
ScalingWrites
ScalingDataSize
©2018Percona.17
DataDistribution
•UserLatencyReasons•LegalandComplianceReasons
SomeDataMustbeinSpecific
GeographicLocation
©2018Percona.18
DistributedArchitectureswithMySQL
©2018Percona.19
MainConcepts
Replication
Sharding
FailoverManagement
TrafficManagement
©2018Percona.20
Replication
HavingMultipleCopiesofthedata,updatedwithchanges
©2018Percona.21
Availability
ServiceStaysupwhencomponentfails
©2018Percona.22
AvailabilityviaRedundancy
Havemorethanonesystem
Workswellforstatelesssystems
Isnotenoughfordatabases
©2018Percona.23
AvailabilityviaReplication
RedundantComputingResource
PairedwithReplicated
Data
©2018Percona.24
WhereReplicationHappens
StorageLevel
DatabaseLevel
ApplicationLevel
©2018Percona.25
StorageLevelReplication
ReplicationinSAN/NAS,DRBD
Typicallyprovidescoldstandby
Simplechoicewhichworkswithmanysystems
AmazonAurora– SmartStorage
©2018Percona.26
Databaselevel
MostFlexible
MostCommon
Hot/WarmSpare
SomecandoActive-Active
©2018Percona.27
ApplicationLevel
Hardtogetright
Rarelyused,especially“usedright”
PartialReplication/Syncronization
Smartconflictresolution
CrossVendorRedundancy
©2018Percona.28
Sharding
Splitdatasetbycertaincriteriaandstoresuch“shards”onseparate“clusters”
©2018Percona.29
TypicalSharding
ByUser
ByCustomerAccount/Company
©2018Percona.30
Sharding andReplication
ShardingAlmostAlwaysusedwithsomekindof
Replication
©2018Percona.31
FailoverManagement
ManyReplicationModesRequire“Failover”
NeedsomeToolToDecideonFailover
NeedsomeTooltoPerformFailover
©2018Percona.32
TrafficManagement
ScalingwithLargeNumberofConnections
RoutingTraffictoRight“Shard”
Read-WriteSplitting
LoadManagement
Avoiding“Dead”Nodes
©2018Percona.33
OptionsinMySQL
©2018Percona.34
ReplicationOptionsinMySQL
ClassicalMySQLReplication
MySQLGroupReplication
PerconaXtraDBClusterandGalera
MySQL(NDB)Cluster
©2018Percona.35
ClassicalMySQLReplication
©2018Percona.36
ClassicalMySQLReplicationProperties
AsynchronousorSemi-Synchronous
Parallel(sinceMySQL5.7)
ManyMasterstoManySlaves(MySQL5.7)
NoConflictResolutionor“Protection”
NoBuilt-inFailover
©2018Percona.37
AdvancedMySQLReplicationTopologies
©2018Percona.38
PMMDashboardforReplication
©2018Percona.39
MySQLGroupReplication
©2018Percona.40
MySQLGroupReplication(Newin5.7)
“GroupofPeers”
Write-AnywhereorDedicatedWriter
AsynchronousReplicationwithFlowControl
ConflictsPreventedthroughCertification
BuiltinFailover
NoAutomatedProvisioning
©2018Percona.41
PerconaXtraDB Cluster/Galera
©2018Percona.42
PerconaXtraDB ClusterTopology
©2018Percona.43
PXC/Galera Properties
WritetoAnyNode
CertificationBasedReplication
VirtuallySynchronous;Canensurenostalereads
BuiltinFail-Over
Built-inNodeProvisioning
©2018Percona.44
TransactionCommitFlow
©2018Percona.45
PXC5.7PerformanceImprovementshttp://bit.ly/2qGCr0T andhttp://bit.ly/2pzvAIW
©2018Percona.46
PMMDashboardforPXC
©2018Percona.47
MySQLCluster
MostlyInMemoryStorage
SynchronousReplication
PessimisticLocking
ConflictDetectionwithAsyncReplication
NicheUseOnly
©2018Percona.48
Sharding inMySQL
TypicallyPainfulorVeryPainful
NoBuilt-InorStandardSolution
ManyCustomApp-LayerImplementationExists
©2018Percona.49
ThinkingaboutSharding
QueryRoutingtotherightShard
DataAggregationforCross-ShardQueries
ShardBalancing
©2018Percona.50
StatedbyteaminYouTube
NowOpenSourceinCNCF
DeployedatSlack
SupportsMySQLProtocol
SupportsCrossShardQueries
SupportsRe-Sharding
Vitess
©2018Percona.51
Vitess Architecture
©2018Percona.52
FailoverinMySQL
MHA
MySQLFailover
Orchestrator
©2018Percona.53
OrchestratorScreenshot
©2018Percona.54
TrafficManagementSolutions• NotImmediate,DoesnothandleexistingconnectionsDNS
• TCP/IPPortlevel.DoesnotunderstandMySQLProtocolHAProxy
• LikeHAProxyintheCloudElasticLoadBalancer(etc)
• CurrentlyverybasicMySQLRouter
• ProprietarySolutionsMaxScale,ScaleArc
• MySQLProtocolAware100%OpenSourceProxySolutionforMySQLProxySQL
©2018Percona.55
• 100%OpenSource• WellSupported• Read-WriteSplitting• Caching• QueryRewrites• LoadBalancing• 10k+ConnectionSupport
ProxySQL
©2018Percona.56
DedicatedsharedProxySQL 56
application server 1 application server 2 application server 3
PXC node 1 PXC node 2 PXC node 3
ProxySQL
©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
©2018Percona.58
ProxySQL atPMM
©2018Percona.59
CloudOnlyOptions
•AmazonRDS•AmazonAurora•GoogleCloudSQL•AzureDatabaseforMySQL
DBaaSinthecloudcomeswithbuilt-inHAOptions
©2018Percona.60
BeyondMySQL
©2018Percona.61
MySQLisaPartofyourDataInfrastructure
MySQLisGoodforManyThingsbutMySQLisnotGoodforEverything
©2018Percona.62
MySQLcanbeusedtogetherwith
Caching
• Redis,Memcache
FullTextSearch
• Elastic,Solr
Queue/StreamProcessing
• Kafka
AnalyticsatScale
• Hadoop,Clickhouse
©2018Percona.63
CrossTechnologyReplication
• SymmetricDS,Self-MadeSolutionTriggerBased
ReplicationTools
• Debezium,Yelp’sMySQLStreamerKafkaGateway
• ReplicationfromMySQLtoVarietyDataStoresTungstenReplicator
• MySQLtoTarantoolReplication• MySQLtoClickHouseReplication
CustomBinarLogConsumers
©2018Percona.64
Summary
LotsofOptionsExistforBuildingDistributedArchitectureswithMySQL
LotsofOptionforIntegratingMySQLwithotherOpenSourceDataStores
©2018Percona.65
Usecode10ATTENDPL18for10%discount!
©2018Percona.66
ThankYou!