Open source, high performance database. July 2012

Similar documents
Course Content MongoDB

The course modules of MongoDB developer and administrator online certification training:

MongoDB An Overview. 21-Oct Socrates

MongoDB 2.2 and Big Data

MongoDB w/ Some Node.JS Sprinkles

Outline for today. Introduction to NoSQL. MongoDB. Architecture. NoSQL Assumptions and the CAP Theorem Strengths and weaknesses of NoSQL

Intro to MongoDB. Alex Sharp.

MongoDB. History. mongodb = Humongous DB. Open-source Document-based High performance, high availability Automatic scaling C-P on CAP.

Scaling for Humongous amounts of data with MongoDB

Group13: Siddhant Deshmukh, Sudeep Rege, Sharmila Prakash, Dhanusha Varik

ITG Software Engineering

Scaling with mongodb

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

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

Document Object Storage with MongoDB

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

MongoDB. Nicolas Travers Conservatoire National des Arts et Métiers. MongoDB

Cassandra- A Distributed Database

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

Brad Dayley. Sams Teach Yourself. NoSQL with MongoDB. SAMS 800 East 96th Street, Indianapolis, Indiana, USA

MongoDB Introduction and Red Hat Integration Points. Chad Tindel Solution Architect

MONGODB INTERVIEW QUESTIONS

CIB Session 12th NoSQL Databases Structures

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

MongoDB. Kristina Chodorow September 8 th, 2009

Using the MySQL Document Store

Document Databases: MongoDB

Perspectives on NoSQL

dinner in the sky with

1 Big Data Hadoop. 1. Introduction About this Course About Big Data Course Logistics Introductions

DEMYSTIFYING BIG DATA WITH RIAK USE CASES. Martin Schneider Basho Technologies!

MySQL. The Right Database for GIS Sometimes

Transitioning from C# to Scala Using Apache Thrift. Twitter Finagle

MongoDB. copyright 2011 Trainologic LTD

Developer Internship Opportunity at I-CC

3 / 120. MySQL 8.0. Frédéric Descamps - MySQL Community Manager - Oracle

Kim Greene - Introduction

A Review to the Approach for Transformation of Data from MySQL to NoSQL

Project: Relational Databases vs. NoSQL. Catherine Easdon

MongoDB Tutorial for Beginners

A RESTFUL API WITH MONGODB. A Project. California State University, Sacramento

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

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

CSE 344 JULY 9 TH NOSQL

NoSQL Databases Analysis

SQL Azure. Abhay Parekh Microsoft Corporation

Understanding basics of MongoDB and MySQL

MongoDB Step By Step. By B.A.Khivsara Assistant Professor Department of Computer Engineering SNJB s COE,Chandwad

Online Multimedia Winter semester 2015/16

Percona Live September 21-23, 2015 Mövenpick Hotel Amsterdam

NoSQL + SQL = MySQL. Nicolas De Rico Principal Solutions Architect

MySQL Document Store. How to replace a NoSQL database by MySQL without effort but with a lot of gains?

Sharding Introduction

App Engine: Datastore Introduction

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

SQL Commands & Mongo DB New Syllabus

Database Solution in Cloud Computing

Introduction to NoSQL (MongoDB and Elastic )

MySQL Cluster Web Scalability, % Availability. Andrew

MongoDB at Visibiz. Why and how we re using MongoDB in our application. Mike Brocious Tech Lead Visibiz, Inc.

Masters in Web Development

Chapter 24 NOSQL Databases and Big Data Storage Systems

NoSQL Injection SEC642. Advanced Web App Penetration Testing, Ethical Hacking, and Exploitation Techniques S

Advanced Data Management Technologies

MySQL High Availability

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

MongoDB Schema Design

מרכז התמחות DBA. NoSQL and MongoDB תאריך: 3 דצמבר 2015 מציג: רז הורוביץ, ארכיטקט מרכז ההתמחות

CIS 601 Graduate Seminar. Dr. Sunnie S. Chung Dhruv Patel ( ) Kalpesh Sharma ( )

MongoDB schema design

MongoDB. An introduction and performance analysis. by Rico Suter

5/2/16. Announcements. NoSQL Motivation. The New Hipster: NoSQL. Serverless. What is the Problem? Database Systems CSE 414

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

Manual Trigger Sql Server 2008 Insert Multiple Rows At Once

Modern Web Application Development. Sam Hogarth

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

Scaling Without Sharding. Baron Schwartz Percona Inc Surge 2010

Database Systems CSE 414

10/18/2017. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

TITLE: PRE-REQUISITE THEORY. 1. Introduction to Hadoop. 2. Cluster. Implement sort algorithm and run it using HADOOP

MongoDB for C# Developers

Understanding NoSQL Database Implementations

IBM DB2 JSON An overview of DB capabilities as a JSON document store

Oracle NoSQL Database Enterprise Edition, Version 18.1

MarkLogic 8 Overview of Key Features COPYRIGHT 2014 MARKLOGIC CORPORATION. ALL RIGHTS RESERVED.

MySQL as a Document Store. Ted Wennmark

MySQL & NoSQL: The Best of Both Worlds

MongoDB Web Architecture

5/1/17. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

What s new in Mongo 4.0. Vinicius Grippa Percona

Non-Relational Databases. Pelle Jakovits

Oracle NoSQL Database Enterprise Edition, Version 18.1

Microsoft vision for a new era

The NoSQL Ecosystem. Adam Marcus MIT CSAIL

Open Source Database Ecosystem in Peter Zaitsev 3 October 2016

What s New in MySQL and MongoDB Ecosystem Year 2017

OPEN SOURCE DB SYSTEMS TYPES OF DBMS

A Non-Relational Storage Analysis

Big Data Analytics. Rasoul Karimi

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

Transcription:

Open source, high performance database July 2012 1

Quick introduction to mongodb Data modeling in mongodb, queries, geospatial, updates and map reduce. Using a location-based app as an example Example works in mongodb JS shell 2

3

MongoDB is a scalable, high-performance, open source, document-oriented database. Fast Querying In-place updates Full Index Support Replication /High Availability Auto-Sharding Aggregation; Map/Reduce GridFS 4

Better data locality In-Memory Caching Auto-Sharding Read scaling Write scaling Relational MongoDB We just can't get any faster than the way MongoDB handles our data. Tony Tam CTO, Wordnik 5

MongoDB is Implemented in C++ Windows, Linux, Mac OS-X, Solaris Drivers are available in many languages 10gen supported C, C# (.Net), C++, Erlang, Haskell, Java, JavaScript, Perl, PHP, Python, Ruby, Scala, nodejs Multiple community supported drivers 6

RDBMS Table Row(s) Index Partition Join Schema MongoDB Collection JSON Document Index Shard Embedding/Linking (implied Schema) 7

{ _id : ObjectId("4c4ba5c0672c685e5e8aabf3"), author : "Asya", date : ISODate("2012-02-02T11:52:27.442Z"), text : "About MongoDB...", tags : [ "tech", "databases" ], comments : [{ author : "Fred", date : ISODate("2012-02-03T17:22:21.124Z"), Post Ever!" }], comment_count : 1 } text : "Best 8

JSON has powerful, limited set of datatypes Mongo extends datatypes with Date, Int types, Id, MongoDB stores data in BSON BSON is a binary representation of JSON Optimized for performance and navigational abilities Also compression See: bsonspec.org 9

MySQL START TRANSACTION; INSERT INTO contacts VALUES (NULL, joeblow ); INSERT INTO contact_emails VALUES ( NULL, joe@blow.com, LAST_INSERT_ID() ), ( NULL, joseph@blow.com, LAST_INSERT_ID() ); COMMIT; MongoDB db.contacts.save( { username: joeblow, emailaddresses: [ joe@blow.com, joseph@blow.com ] } ); Native drivers for dozens of languages Data maps naturally to OO data structures 10

Want to build an app where users can check in to a location Leave notes or comments about that location 11

"As a user I want to be able to find other locations nearby" Need to store locations (Offices, Restaurants, etc) name, address, tags coordinates User generated content e.g. tips / notes 12

"As a user I want to be able to 'checkin' to a location" Checkins User should be able to 'check in' to a location Want to be able to generate statistics: Recent checkins Popular locations 13

loc1, loc2, loc3 user1, user2 checkin1, checkin2 locations users checkins 14

> location_1 = { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012 } 15

> location_1 = { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012 } > db.locations.find({name: "Lotus Flower"}) 16

> location_1 = { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012 } > db.locations.ensureindex({name: 1}) > db.locations.find({name: "Lotus Flower"}) 17

> location_2 = { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012, } tags: ["restaurant", "dumplings"] 18

> location_2 = { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012, } tags: ["restaurant", "dumplings"] > db.locations.ensureindex({tags: 1}) 19

> location_2 = { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012, } tags: ["restaurant", "dumplings"] > db.locations.ensureindex({tags: 1}) > db.locations.find({tags: "dumplings"}) 20

> location_3 = { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012, tags: ["restaurant", "dumplings"], } lat_long: [52.5184, 13.387] 21

> location_3 = { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012, tags: ["restaurant", "dumplings"], } lat_long: [52.5184, 13.387] > db.locations.ensureindex({lat_long: "2d"}) 22

> location_3 = { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012, tags: ["restaurant", "dumplings"], } lat_long: [52.5184, 13.387] > db.locations.ensureindex({lat_long: "2d"}) > db.locations.find({lat_long: {$near:[52.53, 13.4]}}) 23

// creating your indexes: > db.locations.ensureindex({tags: 1}) > db.locations.ensureindex({name: 1}) > db.locations.ensureindex({lat_long: "2d"}) // finding places: > db.locations.find({lat_long: {$near:[52.53, 13.4]}}) // with regular expressions: > db.locations.find({name: /^Din/}) // by tag: > db.locations.find({tag: "dumplings"}) 24

Atomic operators: $set, $unset, $inc, $push, $pushall, $pull, $pullall, $bit 25

// initial data load: > db.locations.insert(location_3) // adding a tip with update: > db.locations.update( {name: "Lotus Flower"}, {$push: { tips: { user: "Asya", date: "28/03/2012", tip: "The hairy crab dumplings are awesome!"} }}) 26

> db.locations.findone() { name: "Lotus Flower", address: "123 University Ave", city: "Palo Alto", post_code: 94012, tags: ["restaurant", "dumplings"], lat_long: [52.5184, 13.387], tips:[{ user: "Asya", date: "28/03/2012", tip: "The hairy crab dumplings are awesome!" }] } 27

"As a user I want to be able to 'checkin' to a location" Checkins User should be able to 'check in' to a location Want to be able to generate statistics: Recent checkins Popular locations 28

> user_1 = { _id: "asya@10gen.com", name: "Asya", twitter: "asya999", checkins: [ {location: "Lotus Flower", ts: "28/03/2012"}, {location: "Meridian Hotel", ts: "27/03/2012"} ] } > db.users.ensureindex({checkins.location: 1}) > db.users.find({checkins.location: "Lotus Flower"}) 29

// find all users who've checked in here: > db.users.find({"checkins.location":"lotus Flower"}) 30

// find all users who've checked in here: > db.users.find({"checkins.location":"lotus Flower"}) // find the last 10 checkins here? > db.users.find({"checkins.location":"lotus Flower"}).sort({"checkins.ts": -1}).limit(10) 31

// find all users who've checked in here: > db.users.find({"checkins.location":"lotus Flower"}) // find the last 10 checkins here: - Warning! > db.users.find({"checkins.location":"lotus Flower"}).sort({"checkins.ts": -1}).limit(10) Hard to query for last 10 32

> user_2 = { _id: "asya@10gen.com", name: "Asya", twitter: "asya999", } > checkin_1 = { location: location_id, user: user_id, ts: "20/03/2010" } > db.checkins.ensureindex({user: 1}) > db.checkins.find({user: user_id}) 33

// find all users who've checked in here: > location_id = db.checkins.find({"name":"lotus Flower"}) > u_ids = db.checkins.find({location: location_id}, {_id: -1, user: 1}) > users = db.users.find({_id: {$in: u_ids}}) // find the last 10 checkins here: > db.checkins.find({location: location_id}).sort({ts: -1}).limit(10) // count how many checked in today: > db.checkins.find({location: location_id, ts: {$gt: midnight}} ).count() 34

// Find most popular locations > agg = db.checkins.aggregate( {$match: {ts: {$gt: now_minus_3_hrs}}}, {$group: {_id: "$location",numentries: {$sum: 1}}} ) > agg.result [{"_id": "Lotus Flower", "numentries" : 17}] 35

// Find most popular locations > map_func = function() { emit(this.location, 1); } > reduce_func = function(key, values) { return Array.sum(values); } > db.checkins.mapreduce(map_func, reduce_func, {query: {ts: {$gt: now_minus_3_hrs}}, out: "result"}) > db.result.findone() {"_id": "Lotus Flower", "value" : 17} 36

Deployment 37

Single server - need a strong backup plan P 38

Single server - need a strong backup plan P Replica sets - High availability - Automatic failover P S S 39

Single server - need a strong backup plan P Replica sets - High availability - Automatic failover Sharded - Horizontally scale - Auto balancing P S S P S S P S S 40

Content Management Operational Intelligence E Commerce User Data Management High Volume Data Feeds 41

42

download at mongodb.org conferences, appearances, and meetups http://www.10gen.com/events Facebook Twitter LinkedIn http://bit.ly/mongofb @mongodb http://linkd.in/joinmongo support, training, and this talk brought to you by 43