Top Banner
© 2017 Percona 1 Peter Zaitsev MySQL vs MongoDB Choosing right technology for your application CEO,Percona SCALE 15x 3 March 2017, Pasadena,CA
66

MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

Apr 16, 2018

Download

Documents

buithuy
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona1

PeterZaitsev

MySQLvsMongoDBChoosingrighttechnologyforyourapplication

CEO,PerconaSCALE15x3March2017,Pasadena,CA

Page 2: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona2

MySQLvsMongoDB

VS

Page 3: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona3

BiggerQuestion

WhatOpenSourceDatabaseTechnologies IshouldbeusingforMy

Application?

Page 4: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona4

EvenBiggerQuestion

WhatDatabaseTechnologiesIshouldbeusingforMyApplication

Page 5: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona5

OpenSource

IncreasingnumberofOpenSourceFirstCompanies

OnlyuseProprietarySoftwarewhentherearenootherchoices

Cost,ReducedVendorLockInarethemainfactors

Page 6: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona6

OpenSourcevsProprietarytrends

Page 7: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona7

NewGenerationTechnologies– OpenSource

Page 8: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona8

PolyglotPersistence

ChooseMultipleDatabasesystems

UseTheirStrongSides

Page 9: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona9

ArchitectureExamples

MainOperationStore+AuxiliaryServices

MicroServiceswiththeirownstores

DataBus/DataFlow

Page 10: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona10

ForExample

MySQLasmaindatastore

UseMemcacheorRedisforcaching

ElasticSearchforSearch

KafkatotransferdatatoElasticSearch,Hadoop

Page 11: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona11

ChoosingtheDataStore

SQL(Relational)

NoSQL(NonRelational)

Page 12: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona12

ManyNoSQLDataModels

KeyValue(Memcache)

WideColumn(Cassandra)

Document(MongoDB)

Graph(Neo4J)

Page 13: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona13

WhyMySQLvsMongoDB?

Page 14: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona14

MyMySQLvsMongoDB

MostPopularOpenSourceRelationalandNonRelationalstorage

BothTechnologiesstartedwithFocusonExceptionalEaseofUse

Theseare2TechnologieswefocusatPercona

Page 15: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona15

PerconaSoftwareforMySQLandMongoDB

MySQL

• PerconaServerforMySQL• PerconaXtraDBCluster• PeronaXtrabackup• PerconaToolkit• PerconaMonitoringandManagement

• TokuDBStorageEngine

MongoDB

• PerconaServerforMySQL•MongoRocksDBStorageEngine(RocksDBBased)

• PerconaMemoryEngineforMongoDB

• PerconaToolkit• PerconaMonitoringandManagement

Page 16: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona16

FullDisclosure

IPersonallyknowMySQLmuchbetterthan

MongoDB

Page 17: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona17

NoSQLonMySQL

StartingMySQL5.7MySQLSupportsNoSQLInterface

MongoDBLikeCRUDaccess

WithTransactionSupport

WithoutGoodShardingSolution

Notyetcommonlyadopted

Page 18: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona18

TopThingstoConsider

TeamPreferencesandExperience

DevelopmentProcessandApplicationLifecycle

DataModel TransactionsandConsistency

Performance Scalability Administration Legal

Page 19: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona19

TeamPreferencesandExperience

AbsolutelyKeyQuestion!

UnlovedTechnology– RecipeforDisaster

Problemsmayhavemorethanonesolution

ConsiderOriginalDevelopmentandFullLifecycle

Page 20: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona20

TeamExperienceMySQLvsMongoDB

MySQL

• VeryMatureTechnology• SQLStandard• Easiertomovetootherrelationaldatabases

• Transactions• AlotofChoices

MongoDB

•ModernandDynamic• DonotneedtolearnnastySQL• DynamicSchema• ComplexQueriesarerecipeforcomplexproblems

• EasierScalability• NativeIntegrationJavascript,JSON

Page 21: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona21

DevelopmentProcessandLifeCycle

FasterDevelopmentpaceormorecontrol?

DataAlwaysHaveSchema

IsDataBelongtoApplicationorusedbyMultipleApplications

ApplicationLifeTime

ApplicationActivedevelopmenttime

Page 22: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona22

DevelopmentinMySQLandMongoDB

MySQL

• RelationalDatabaserequiresmoreplanningandcontrol

• Easytousedatafrommanyapplications

• Manyapplications15+Years• CanuseSQLandNoSQLInterface

MongoDB

• DevelopmentPace• NoNeedtoSynchronizeSchemabetweenApplicationandDatabase

• ClearPathtoScalability

Page 23: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona23

DataModel

OptimalDataModeldependsontheApplicationandTeamExperince

Page 24: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona24

DataModelinMySQLvsMongoDB

MySQL

• RelationalDataModel• Easytoreflectrelationshipsbetweenobjects

• Changedatainoneplace• QueryResult- Table

MongoDB

• DocumentOrientedDataModel• Documentscanembedotherdocuments

• EasytorepresentJSONdatacommoninWebApplications

• ComplexJOINscanoftenbeavoided• QueryResult– ListofDocuments(differentstructure)

Page 25: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona25

ModelDesignExample

PeopleandtheirPassports

Peoplemayhavemorethanonpassport

NotEveryoneHasaPassport

Page 26: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona26

RelationalSchemaDesign

Page 27: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona27

EasyToAnswerVariousQuestions• NumberofPeople

• SELECTcount(*)FROMpeople• ValidityDateofPersonspassport

• SELECTvalid_until frompassportsps joinpeoplepl ONps.people_id =pl.idWHEREname='Stephane‘

• WhoDoesnothaveAPassport?• SELECTnameFROMpeoplepl LEFTJOINpassportsps ONps.people_id =

pl.idWHEREps.idISNULL

Page 28: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona28

MongoDBDesignExample

Page 29: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona29

MongoDBandMySQLTerms

MySQL

• Database/Schema• Table• Row• Column• PrimaryKey• Join

MongoDB

• Database• Collection• Document• Field• PrimaryKey• EmbeddedDocumentorLinking

Page 30: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona30

AccessLanguage

SQL

•Structured•Query•Language

CRUD

•Create•Read•Update•Delete

Page 31: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona31

SQLvsCRUD- InsertSQL CRUD

Page 32: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona32

SQLvsCRUDUpdate

Page 33: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona33

SQLvsCRUD- Delete

Page 34: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona34

SQLvsCRUD- Search

Page 35: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona35

SQLvsCRUD- Count

Page 36: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona36

SQLvsCRUD- Aggregation

Page 37: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona37

TransactionsandConsistency

• Atomicity• Consistency• Isolation• Durability

Page 38: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona38

TransactionsinMySQLvsMongoDB

MySQL

•ACIDTransactionsofarbitrarysize

MongoDB

•ACIDonthedocumentlevel

Page 39: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona39

MongoDBReadsareDirtyReads

ReadingaLargeResultwillReturnDocumentsfromdifferentpointintime

SameDocumentCan(rarely)beReturnedMorethanOnce

Page 40: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona40

Performance

VeryHardtoCompareDirectly

DependsalotontheApplicationArchitecture

ManyBenchmarkscomparedifferentDurabilityorSettings

MongoDBScalesBettersosinglenodeperformancelessofafocus

Page 41: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona41

MySQLvsMongoDBPerformanceTestbyMarkCallaghan:http://bit.ly/2epDJqD

Page 42: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona42

Scalablilty

•Scalabilitywithinsinglesystem•Scalabilityformultiplesystems•Scalingreads,writes,datasize

WhatdoIneedtodotoscalemyApplicationfrom100to100.000.000

users?

Page 43: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona43

ScalabilityMySQLandMongoDB

MySQL

• Scaleswellwithsinglesystemsize

• CanbescaledtoFacebookScale• Easytoscaleformediumsizeapplications

• ScalingReadswithReplication• ShardingisPainful

MongoDB

• Scalabilitywasfocuseduponfromtheearlyversions

• BuiltinSharding• ShardingforScalability,ReplicationisforHA

Page 44: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona44

DatabaseOperationsWhatDevelopersdonotlikethinkingabout

Automation

Backups

VersionUpdates

Monitoring

DisasterRecovery

PerformanceManagement

Page 45: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona45

OperationsMySQLandMongoDB

MySQL

• Flexibility• Manywaystosolveproblems• ManyOpenSourceToolsavailable

• OutoftheboxManualFailoverinReplication

MongoDB

• Simplicity• VirtuallyZeroAdministration• FewerOpenSourceOperationTools

• StrongConnectiontoMongoDBOpsManager

Page 46: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona46

License

MySQL

•GPLorProprietary

MongoDB

•AGPLorProprietary

Page 47: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona47

SolvedMongoDBProblems• PoorconcurrentwriteperformancewithMMAPv1

• FixedbyWiredTiger andMongoRocks• PoordiskspaceusagewithMMAPv1

• FixedbyWiredTiger andMongoRocks• Nowaytovalidatedocuments

• DocumentValidationsinceMongoDB3.2• NoJOIN

• LimitedsupportinaggregationframeworkstartingMongoDB3.2

Page 48: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona48

TypicalMySQLExample

• FullFeatureTransactionsareimportant• RelationalModelisagoodfit• Datasizeistypicallynotrequiringsharding• LongTermApplicationdevelopment• Samedatausedbymanyapplicationsdirectly

OnlineEcommerce

Page 49: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona49

TypicalMongoDBExample

• Extremescalingmightbeneededifgamebecomespopular

• Dataisusedbyoneapplication• Dataiscomplicatedanddoesnotfitrelationalmodelwell

• Documentlevelconsistencyisoftenenough• Lowpaceofdevelopmentafter“launch”

OnlineGame

Backend

Page 50: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona50

ExtraMaterialOtherthingsworthsharing

Page 51: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona51

JustReleased!

Page 52: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona52

PerconaServerforMongoDB3.4

100%FreeandOpenSource

100%CompatiblewithMongoDB3.4

AdditionalMemoryEngineandMongoRocks

PluggableAuthenticationas

inMongoDBEnterprise

AuditingasinMongoDBEnterprise

AdvancedQueryPerformanceMonitoring

HotBackupsforWiredTiger

Page 53: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona53

PerconaMonitoringandManagement

• Comprehensive Database Focused Monitoring

• 100% Open Source Roll-your-own solution

• Easy to install and use

• Supports MySQL and MongoDB

• Version 1.1 focuses on Trending and Query Analyses

• Management Features to Come

Page 54: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona54

WhatQueriesarecausingtheload?

Page 55: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona55

Whyaretheycausingthisload?

Page 56: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona56

Howtofixthem

Page 57: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona57

SystemInformation

Page 58: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona58

WhathappensonOSandHardwareLevel

Page 59: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona59

AswellasDatabaseLevel

Page 60: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona60

DetailedMongoDBStorageEngineMonitoring

Page 61: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona61

CheckouttheDemohttp://pmmdemo.percona.com

Page 62: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona62

Page 63: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona63

Page 64: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona64

MeetusatBooth#219

Page 65: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

©2017Percona65

AboutPerconaSolutionsforyoursuccesswithMySQLandMongoDB

Support,ManagedServices,Software

OurSoftwareis100%OpenSource

SupportBroadEcosystem– MySQL,MariaDB,AmazonRDS

InBusinessformorethan10years

Morethan3000customers,includingtopInternetcompaniesandenterprises

Page 66: MySQL vs MongoDB - Percona · My MySQL vs MongoDB Most Popular Open Source Relational and Non Relational storage Both Technologies started with Focus on Exceptional Ease of Use

DATABASE PERFORMANCEMATTERS

DatabasePerformanceMattersDatabasePerformanceMattersDatabasePerformanceMattersDatabasePerformanceMattersDatabasePerformanceMatters