MongoDB and Mysql: Which one is a better fit for me? Room 204-2:20PM-3:10PM

Similar documents
MongoDB Schema Design

Your First MongoDB Environment: What You Should Know Before Choosing MongoDB as Your Database

Migrating Oracle Databases To Cassandra

CIB Session 12th NoSQL Databases Structures

Beyond Relational Databases: MongoDB, Redis & ClickHouse. Marcos Albe - Principal Support Percona

What s new in Mongo 4.0. Vinicius Grippa Percona

MySQL for Database Administrators Ed 3.1

MySQL Database Administrator Training NIIT, Gurgaon India 31 August-10 September 2015

MongoDB Revs You Up: What Storage Engine is Right for You?

ITS. MySQL for Database Administrators (40 Hours) (Exam code 1z0-883) (OCP My SQL DBA)

How to upgrade MongoDB without downtime

Jargons, Concepts, Scope and Systems. Key Value Stores, Document Stores, Extensible Record Stores. Overview of different scalable relational systems

Scaling MongoDB. Percona Webinar - Wed October 18th 11:00 AM PDT Adamo Tonete MongoDB Senior Service Technical Service Engineer.

GridGain and Apache Ignite In-Memory Performance with Durability of Disk

NoSQL Databases MongoDB vs Cassandra. Kenny Huynh, Andre Chik, Kevin Vu

CISC 7610 Lecture 2b The beginnings of NoSQL

Choosing a MySQL HA Solution Today. Choosing the best solution among a myriad of options

Topics. History. Architecture. MongoDB, Mongoose - RDBMS - SQL. - NoSQL

Introduction to NoSQL

CSE 530A. Non-Relational Databases. Washington University Fall 2013

CO MySQL for Database Administrators

NoSQL Databases Analysis

Cassandra, MongoDB, and HBase. Cassandra, MongoDB, and HBase. I have chosen these three due to their recent

Percona Server for MySQL 8.0 Walkthrough

CIT 668: System Architecture. Distributed Databases

Relational databases

Final Exam Review 2. Kathleen Durant CS 3200 Northeastern University Lecture 23

NOSQL EGCO321 DATABASE SYSTEMS KANAT POOLSAWASD DEPARTMENT OF COMPUTER ENGINEERING MAHIDOL UNIVERSITY

The Hazards of Multi-writing in a Dual-Master Setup

MONGODB INTERVIEW QUESTIONS

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2015 Lecture 14 NoSQL

SQL, NoSQL, MongoDB. CSE-291 (Cloud Computing) Fall 2016 Gregory Kesden

Introduction Aggregate data model Distribution Models Consistency Map-Reduce Types of NoSQL Databases

Transactions and ACID

What s New in MySQL and MongoDB Ecosystem Year 2017

CISC 7610 Lecture 5 Distributed multimedia databases. Topics: Scaling up vs out Replication Partitioning CAP Theorem NoSQL NewSQL

How do we build TiDB. a Distributed, Consistent, Scalable, SQL Database

How to Scale MongoDB. Apr

MySQL Cluster Web Scalability, % Availability. Andrew

CMU SCS CMU SCS Who: What: When: Where: Why: CMU SCS

Kim Greene - Introduction

NoSQL systems. Lecture 21 (optional) Instructor: Sudeepa Roy. CompSci 516 Data Intensive Computing Systems

MongoDB An Overview. 21-Oct Socrates

Introduction to Big Data. NoSQL Databases. Instituto Politécnico de Tomar. Ricardo Campos

Database Availability and Integrity in NoSQL. Fahri Firdausillah [M ]

Database Solution in Cloud Computing

Scaling Without Sharding. Baron Schwartz Percona Inc Surge 2010

MySQL usage of web applications from 1 user to 100 million. Peter Boros RAMP conference 2013

MySQL Replication Options. Peter Zaitsev, CEO, Percona Moscow MySQL User Meetup Moscow,Russia

Goal of the presentation is to give an introduction of NoSQL databases, why they are there.

Integrity in Distributed Databases

ICALEPS 2013 Exploring No-SQL Alternatives for ALMA Monitoring System ADC

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Accelerate MySQL for Demanding OLAP and OLTP Use Case with Apache Ignite December 7, 2016

DATABASE SYSTEMS. Database programming in a web environment. Database System Course, 2016

Percona XtraDB Cluster

Choosing a MySQL HA Solution Today

Modern Database Concepts

Percona XtraDB Cluster MySQL Scaling and High Availability with PXC 5.7 Tibor Korocz

Choosing a MySQL High Availability Solution. Marcos Albe, Percona Inc. Live Webinar June 2017

Aurora, RDS, or On-Prem, Which is right for you

Accessing other data fdw, dblink, pglogical, plproxy,...

Course Content MongoDB

Perspectives on NoSQL

MySQL Architecture and Components Guide

Distributed Data Store

MySQL Storage Engines Which Do You Use? April, 25, 2017 Sveta Smirnova

Essential Skills - RDBMS and SQL

Percona XtraDB Cluster powered by Galera. Peter Zaitsev CEO, Percona Slide Credits: Vadim Tkachenko Percona University, Washington,DC Sep 12,2013

Scaling for Humongous amounts of data with MongoDB

Scaling. Marty Weiner Grayskull, Eternia. Yashh Nelapati Gotham City

SCALABLE CONSISTENCY AND TRANSACTION MODELS

Introduction to NoSQL Databases

MySQL for Developers Ed 3

MongoDB - a No SQL Database What you need to know as an Oracle DBA

Oral Questions and Answers (DBMS LAB) Questions & Answers- DBMS

NewSQL Databases. The reference Big Data stack

Building Highly Available and Scalable Real- Time Services with MySQL Cluster

InnoDB: Status, Architecture, and Latest Enhancements

<Insert Picture Here> MySQL Cluster What are we working on

How Percona Contributes to Open Source Database Ecosystem. Peter Zaitsev 5 October 2016

MongoDB Tutorial for Beginners

Shen PingCAP 2017

A Survey Paper on NoSQL Databases: Key-Value Data Stores and Document Stores

Design Patterns for Large- Scale Data Management. Robert Hodges OSCON 2013

<Insert Picture Here> Introduction to MySQL

MySQL High Availability

Making MongoDB Accessible to All. Brody Messmer Product Owner DataDirect On-Premise Drivers Progress Software

How we build TiDB. Max Liu PingCAP Amsterdam, Netherlands October 5, 2016

Chapter 24 NOSQL Databases and Big Data Storage Systems

Open Source Database Ecosystem in Peter Zaitsev 3 October 2016

Overview. * Some History. * What is NoSQL? * Why NoSQL? * RDBMS vs NoSQL. * NoSQL Taxonomy. *TowardsNewSQL

Accelerate MySQL for Demanding OLAP and OLTP Use Cases with Apache Ignite. Peter Zaitsev, Denis Magda Santa Clara, California April 25th, 2017

NoSQL systems: sharding, replication and consistency. Riccardo Torlone Università Roma Tre

Scalability of web applications

Non-Relational Databases. Pelle Jakovits

Introduction to MySQL Cluster: Architecture and Use

CMSC 461 Final Exam Study Guide

Databases : Lecture 1 2: Beyond ACID/Relational databases Timothy G. Griffin Lent Term Apologies to Martin Fowler ( NoSQL Distilled )

MongoDB. copyright 2011 Trainologic LTD

Transcription:

MongoDB and Mysql: Which one is a better fit for me? Room 204-2:20PM-3:10PM

About us Adamo Tonete MongoDB Support Engineer Agustín Gallego MySQL Support Engineer

Agenda What are MongoDB and MySQL; NoSQL and Relational concepts; Main differences between MySQL and MongoDB; MongoDB and MySQL similarities; Query Language; Performance comparison; Security; Best usage cases; Q&A

What are MongoDB and MySQL

What is MongoDB Document Oriented Database NoSQL Open source It is currently the most common NoSQL database out there. High Performance Database Different storage engines for different use cases

What is MySQL Relational Database Management System The "M" in LAMP stack Second most popular RDBMS According to DB-Engines' ranking Its architecture supports use of different storage engines Many different kinds of topologies used: Master - Slave Master - Master (active and passive) Multimaster - Slave Ring replication Tree or pyramid Multimaster Cluster (Group Replication or Galera Cluster)

NoSQL and Relational concepts

Database Concept A database is an organized collection of: Data Schemas Tables Queries Reports Views Other elements. Wikipedia

Relational Database Concept Written in the early 70s Records and attributes define relations Uses normalizations SQL Language Procedures Triggers Foreign keys Transactions - ACID

Non-Relational Database Concept Started in the 2000s; Non-relational concept. No tables or normalization; Query language is different than standard SQL; Made for new programming languages. Fast development; Relies on CAP theorem.

Main differences between MySQL and MongoDB

Differences between MongoDB and MySQL Some features we will compare: Normalization Transactions Query language Data storage and retrieval Indexes differences How to distribute and scale

How different is MongoDB from MySQL/RDBS NoSQL and SQL are not enemies they are meant to complete each other While MongoDB is a young NoSQL database, MySQL is a mature relational database. In some cases, using MongoDB as the main database is not the best thing to do. However, MongoDB can offer a very fast growing environment without too much effort.

How different is MongoDB from MySQL/RDBS Comparing Data distribution: MongoDB expects data to grow beyond machine limitations. MySQL does have a few add-ons to allow data distribution among instances. MySQL expects to work in a single machine (at least for writes). MongoDB doesn't allow ACID transactions, but it works with the CAP theorem.

Normalization Normal forms MongoDB features best practices to organize your data, but there are no hard rules to do so. MySQL strongly suggests using 3rd normal form (3NF) to avoid data duplication.

Normalization @ each intersection is a single scalar value

Normalization { } "_id" : ObjectId("507f1f77bcf86cd799439011"), "studentid" : 100, "firstname" : "Jonathan", "middlename" : "Eli", "lastname" : "Tobin", "classes" : [ { "courseid" : "PHY101", "grade" : "B", "coursename" : "Physics 101", "credits" : 3 }, { "courseid" : "BUS101", "grade" : "B+", "coursename" : "Business 101", "credits" : 3 } ]

ACID transactions What is ACID? Atomicity transactions should function as a single, indivisible unit of work Consistency the database should always move from one consistent state to the next Isolation the results of a transaction are (usually) invisible to other transactions until the transaction is finished Durability once committed, a transaction's changes are permanent

ACID transactions How is ACID represented in MySQL? Atomicity if autocommit=on (default), every statement is committed immediately if not, COMMIT or ROLLBACK should be used explicitly Consistency uses the doublewrite buffer and crash recovery Isolation various isolation levels from which to choose from: RU, RC, RR and S Durability there are many configuration options available for this, among which are: innodb_flush_log_at_trx_commit and sync_binlog

ACID transactions How is ACID represented in MongoDB? Atomicity single document level & no snapshotting for reads Consistency primary = strong secondaries = your choice Isolation not really, but $isolated can help Durability configurable w:majority and/or j:true

CAP theorem CAP theorem was proposed by Eric Allen in 2000 A distributed system can't have the 3 guarantees at the same time. One must be sacrificed

CAP theorem Consistence Availability Partition Tolerant A Anyone will get the same response, data is consistent among instances C P

CAP theorem Consistence Availability Partition Tolerant A System will always respond to requests, no downtime. C P

CAP theorem Consistence Availability Partition Tolerant A System can handle errors (network, hardware failure) C P

CAP theorem A Relational Databases MySQL Postgres Cassandra Riaki C P MongoDB Redis

Data Storage and Data Retrieval MySQL has predefined table definitions Each column can have one (and only one) data type assigned to it There are some limits imposed: columns: 4096 row length: 64 Kb these can change depending on which storage engine is used SQL is a declarative language We can tell MySQL what we want, without worrying about how it is looked for From the application side, there are connectors available for communicating with the server https://www.mysql.com/products/connector/

Data Storage and Data Retrieval Unlike MySQL, MongoDB doesn't have a predefined schema but it does use declarative query language. Documents can have different fields with different data types, for example {x : 1, y : ['test']} and {x : 'percona', y : ISODate('2018-01-01')} are both valid MongoDB documents for the same collection.

Data Storage and Data Retrieval MongoDB doesn't use 3rd form normalization but MySQL does. All documents must contain as much information as possible. There are no joins, only linked documents. Max document size is 16 MB.

Comparing topologies Replica-sets Clusters and shards Master Slave

Scalability What is scalability? "the ability to add capacity by adding resources" Scale up (a.k.a.: vertically) improve hardware resources Scale out (a.k.a.: horizontally) add more nodes

Scalability MongoDB: uses shards to scale writes uses secondaries to scale reads MySQL: can use partitioning and sharding to scale writes (but it's not easy to implement) uses slaves to scale reads

MongoDB and MySQL similarities

How similar is MongoDB to MySQL But these databases are not completely different They share: Security Indexing Multi-user access Concurrency

How similar is MongoDB to MySQL Database terms and concept mapping MySQL MongoDB Database Table Row Column Database Collection Document Key

How similar is MongoDB to MySQL Security: Granular security level User roles Different storage engines: Both mongodb and MySQL share the idea of pluggable storage engine MongoDB engines are: WiredTiger, MMAPv1, InMemory, RocksDB MySQL engines are: InnoDB, MyISAM, MyRocks, Memory, and many more

Query Language

Query Language We will compare mongo SQL and mysql SQL languages briefly and we'll see simple workflow for both: create schema create table insert into table select from table update and delete select with join (mysql only)

Query Language - MySQL

Query Language - MySQL

SQL Definition https://dev.mysql.com/doc/refman/5.7/en/select.html

MongoDB Query Language

"NoSQL" Query Language NoSQL CQL Graph Javascript

Security

Security Both databases feature user and roles as well as enhanced security such as LDAP integration, certificates, and audits Percona Server for MongoDB and Percona Server for MySQL do offer entreprise-grade authentication plugins for free

Security - MongoDB MongoDB has roles since version 2.4 Currently we can set collection at table level granularity LDAP is only available on MongoDB Enterprise but Percona server comes with this plugin free of charge. Audit plugin

Security - MySQL Roles will be available on version 8.0+ We can set permission at database and table-level granularity Grants can be further refined into more atomic privileges CREATE SELECT INSERT UPDATE... MySQL Enterprise functionality (provided to some extent by Percona Server): LDAP authentication Encryption Audit

Performance comparison

Performance There is no way to compare both performance. Each database has its own features and some are faster than others. As a document oriented database MongoDB doesn't a predefined schema and neither a relationship among collections which makes finds really fast (when reading only one document) For example: If using lookups in mongodb the query can be very slow. In the other hand, mysql does that with majesty as it is design to work with tables and conjunctions...

Performance Generic concepts to keep best performance Create indexes (not for all the fields) Split or purge data to keep the database small Be precise on your query (avoid reading unnecessary documents, columns) Use fast disks when the working set doesn't fit in RAM More cores means more parallel job and so on...

Best usage cases

Best Use case There is no right nor wrong answer here although mongodb tend to be more used in application that doesn't require transactions (as its nature) mysql are often used when ACID is required. https://www.percona.com/about-percona/customers https://www.percona.com/about-percona/case-studies

Q&A

Q&A

Rate Our Session #54

Thank You!