+ All Categories
Home > Technology > Drop acid

Drop acid

Date post: 14-May-2015
Category:
Upload: mike-feltman
View: 823 times
Download: 2 times
Share this document with a friend
Description:
Session on NoSQL Databases and MongoDB. I stole the title from someone who deserves credit, but unfortunately, can't remember who. I blame the acid.
Popular Tags:
29
NoSQL - Death to Relational Databases Mike Feltman F1 Technologies
Transcript
Page 1: Drop acid

NoSQL - Death to Relational Databases

Mike FeltmanF1 Technologies

Page 2: Drop acid

Agenda• The NoSQL Movement• MongoDB Discussion & Demo• Discussion

Page 3: Drop acid

The NoSQL MovementNo SQL Databases:

Non-relationalLess ACID More BASECAP TradingHighly ScalableHighly Performant

NoSQL = Not Only SQL

Page 4: Drop acid

Less ACID• Atomic • basically means supports transactions

• Consistent• Has hard constraints & rejects non-conforming data

• Isolated • No peaking at incomplete commits

• Durable• Once a commit is finished, it lasts forever.

Page 5: Drop acid

More BASE• Basically Available • Soft-state • Eventually consistent

Page 6: Drop acid

CAP Trading• Consistency (client perceives set of operations

completed)• Availability (operations terminate with an

expected result)• Partition tolerance (operations will complete,

even if a required resource is unavailable)• Only 2 are possible in distributed systems.– Eric Brewer

Page 7: Drop acid

The NoSQL MovementWhy:• SQL is tedious and difficult• Strongly typed schemas are inflexible and painful

to maintain• Inadequate performance of RDBMS on huge data

stores• Poor Scalability of RDBMS• Poor Replication Support

Page 8: Drop acid

Types of NoSQL Databases• Document Stores• Graph• Key/Value Store• Object Database• Tabular

Page 9: Drop acid

Major Players• Mongodb (10gen)• CouchDB (Apache)• Cassandra (Apache –

formerly Facebook)• BigTable – (Google)• Berkeley DB (Oracle)

• Dynamo (Amazon)• MObStor (Yahoo)• Haystack (Facebook)• Voldemort (LinkedIn)• HBase/Hadoop (Apache

& Microsoft)

Page 10: Drop acid

MongoDBCombining the best features of document

databases, key-value stores, and RDBMSes.

• Scalable• High-Performance• Open Source• Schema-free• Document Oriented

Page 11: Drop acid

MongoDB Features• Document-oriented

storage (BSON)• Dynamic Queries• Full index support

(including embedded objects & arrays)

• Fast, in-place updates• Efficient Blob storage

• Replication• Auto-sharding• MapReduce• Driver support for many

languages• Cross-Platform• Admin Tools

Page 12: Drop acid

Document Oriented Storage

• Data is stored in BSON– Binary-encoded

serialization of JSON-like documents.

– Lightweight, traversable & efficient

– Supports embedded objects & arrays

– Document = Record

{ firstName: “Nicklas”, lastName: “Lidstrom”, team: “Red Wings”, stanleyCups : [1997, 1998, 2002, 2008], norrisTrophies : [2001, 2002, 2003, 2006, 2007, 2008] }

Page 13: Drop acid

Dynamic Queries• No indexes required to

find data.• RDBMSes all support

this as well.

Examples• All records:db.players.find({})• All Red Wingsdb.players.find({“team”:

“Red Wings”})

Page 14: Drop acid

Index Support• B-Tree format• Default index on PK• Supports unique, compound, document

indexes (indexes on nested documents) and multikeys indexes (allows indexing of arrays of values)

Page 15: Drop acid

Fast in-place updates• Updates are made to existing documents

within a collection. • Many “NoSQL” databases (such as CouchDB)

do not support updates and instead store versions of records.

Page 16: Drop acid

Efficient Blob Storage• Blob = Binary Large Object• Up to 4MB within document• GridFS specification is followed for larger

items and external files

Page 17: Drop acid

Replication• Enhanced master-slave configuration– one server active for writes at a time.– Provides failover and redundancy– Implemented with Replica Pairs• When master fails slave takes over• When slave fails control reverts to master

• Limited Master-master

Page 18: Drop acid

Auto-Sharding• Sharding: – Breaking database down into “shards” and

spreading those across distributed/commodity servers.

– highly scalable approach for increased throughput and performance of high-transaction, large database applications.

– MongoDB manages data storage and retrieval behind the scenes.

Page 19: Drop acid

MapReduce

• Term comes from Google. – Patented framework for

processing huge datasets on certain kinds of distributable problems using a large number of servers.

– MongoDB applies it to single server instances as well.

• Useful for batch operations

• Aggregation: NoSQL answer to GROUP BY

Page 20: Drop acid

Drivers• .NET (C#)• JavaScript• Python• PHP• Ruby• Java• C++

• Perl• JVM– Clojure– Groovy– Scala

Page 21: Drop acid

Cross-Platform• 32 bit & 64 bit versions available for:– Windows– OS X– Linux– Solaris

Page 22: Drop acid

Admin Tools• Command Shell• Simple limited REST (http) Interface• Mongostat• Mongosniff (Unix only – use tcpdump on

Windows)• Backup & Restore

Page 23: Drop acid

MongoDB TerminologyTraditional RDBMS• Database• Table• Record• Field

MongoDB• Database• Collection• Document• Key

Page 24: Drop acid

Demo!• Start the server (if it’s not running).

C:\mongodb\bin\mongod• Start the shell

C:\mongodb\bin\mongo

Page 25: Drop acid

The MongoDB Shell

Page 26: Drop acid

Database Commands• Open Database• Create Database

• use (database name)• use (database name)

Page 27: Drop acid

How it works• Focused on documents

– Document = sequence of key value pairs in bson• Value can be another document• Additional types vs. JSON. ie dates, regexp

• Messages (cpassed over TCP/IP) in BSON drivers convert code to BSON• Memory mapped storage engine (MMSE) – all disk access takes place

through MMSE• Query Optimizer:

– Find( {x:10, y:”foo”})– Launches multiple simultaneous queries based on indexes & table scan. Stops

when one finishes, remembers which one was the fastest for future similar queries. Can use hint option to specify which index to use.

Page 28: Drop acid

Why?• Applications where schema gets in the way• Performance• Scalability• RAD• More natural fit with OO Languages

Page 29: Drop acid

Resources• www.mongodb.org


Recommended