Evolution of mongodb

Post on 24-Apr-2015

420 views 0 download

description

 

Transcript of Evolution of mongodb

Evolution of Mongodb

An introduction to what and why is mongodb

What is Mongodb ? Humongous

{name:mongodb,type:db}

10gen

What is Mongodb ? Non-relational

Json/bson document store

Nosql What is it?

Schemaless , what is schema less? And why?

Agenda Why mongodb is required or where mongodb

fits in

Mongodb schemaless architecture

Mongodb and RDBMS

Scalability and performance

Summary

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level Fifth Outline Level Sixth Outline Level

Seventh Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level Fifth level

Why Mongodb ? Where mongodb fits

in the world?

Click to edit Master text styles

Second level Third level

Fourth level Fifth level

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level Fifth Outline Level Sixth Outline Level

Seventh Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level Fifth level

Why Mongodb ? Where mongodb fits in the world?

Relational based DBMS is not known to be scalable

You require high end hardware architecture for performance when it comes to RDMBS

RDBMS data storage is not easy flexible

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level Fifth Outline Level Sixth Outline Level

Seventh Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level Fifth level

Why Mongodb ?

Relational db is not known to be very scalable and performance oriented unless if you have very good hardware but if you go for commodity based server it will still provide its rich functionality but wont be performance oriented and hence not much scalable

Some softwares like Memcache,redis or other key-value store is very good when it comes to performance and scalability but often they provide a limited functionality

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level Fifth Outline Level Sixth Outline Level

Seventh Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level Fifth level

Why Mongodb ?

Mongodb fills the gap between these two so its very performance oriented and scalable and have rich set of functionality too that often comparable to what RDMBS provides ,

It does deliberately though omit few functionality of RDBMS in order to retain scalability and performance.

Mongo db does not support Joins , Transactions and schema less

We will come to it for more when we gonna discuss difference between mongodb and relational db in coming section

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level Fifth Outline Level Sixth Outline Level

Seventh Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level Fifth level

Schema less

Mongodb is schema less What does it mean Why ?

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level Fifth Outline Level Sixth Outline Level

Seventh Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level Fifth level

Schema less

And one of reason for it is being schemaless Is It stores data as json document or in other word as javascript object and objectOften is schemaless one object can have different data and type then other.

Why object is being stored instead of data?

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level Fifth Outline Level Sixth Outline Level

Seventh Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level Fifth level

Schema less

Why object is being stored instead of data?

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level Fifth Outline Level Sixth Outline Level

Seventh Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level Fifth level

Schema lessWhy object is being stored instead of data?

One size doesn’t fits allWe often need to interact with data objects in programs instead of data itselfNo ORM requiredObject and its hierarchy is more closer to programming model.

Click to edit the outline text format

Second Outline Level

Third Outline Level

Fourth Outline Level Fifth Outline Level Sixth Outline Level

Seventh Outline LevelClick to edit Master text styles

Second level

Third level

Fourth level Fifth level

Schema lessSchemaless architecture of database

Objects are different to each otherAgilityNo Alter table

db.students.save({name:“user1”,type:”student”})db.students.save({name:”user2”,type:”student”,favsubjects:[ ‘math’,’english’] })We can change schema of existing document toodb.students.save({name:“user1”,type:”student”,favcolors:[‘blue’,’purple’]})

We will be discussing more about schema in next section Mongodb relative to relational

Mongodb & RDMBS Is mongodb replacement for RDBMS?

When you should consider mongodb over RDBMS?

What are pros and cons using mongodb?

Mongodb & RDMBS What are pros and cons using mongodb?

Tradeoffs

Mongodb provides: Flexibility

Performance

Scalability

Does not support :

Joins

Transactions

Why join and transactions are not being supported?

Mongodb & RDMBS Why join and transactions are not being

supported?

Cos it has to be scalable and performance oriented. Using join will limit its scalability and transactions affect performance.

Transactions often not required until you are building some secure , real time app which is very transactional.

Though mongodb does provides atomic operations but its currently limited to one document only.

How mongodb exists without join?

Mongodb & RDMBS How mongodb exists without join?

Mongodb & RDMBS

How mongodb exists without join?

And the answer is it support embed.

Mongodb document being json fundamentally , can have embedded sub-documents with it.

So a json document fundamentally comprised of a dictionary can have another array and even other dictionaries embedded to it.

e.g :

{

post : “abc”,

authors:[“aron”,”linda”],

comments:[

{name: “dfdffd” ,content:”fdfdf”}

{-----},

]

}

Embed ? Isn't it violating normal form rules?

Mongodb & RDMBS Embed ? Isn't it violating normal form rules?

It Does and it could be beneficial or harmful depends on when you are using it.

When to embed or not?

Mongodb & RDMBSWhen to embed or not?

When to embed:

. If it is being often accessed with main document, then embed it.

. If change to embedded document is most likely not to be done

When not to embed:

If size of document is going to be over 16 mb.

{

post : “abc”,

authors:[“aron”,”linda”],

comments:[

{name: “dfdffd” ,content:”fdfdf”}

{-----},

]

}

Mongodb & RDMBS

If your DB is 3NF and you don’t do any joins (you’re just selecting a bunch of tables and putting all the objects together, AKA what most people do in a web app), MongoDB would probably for you.

• When you should consider mongodb over RDBMS?

Mongodb & RDMBS Is mongodb replacement for RDBMS?

Its not when your application fall in below Categories:

High transactional  applications

Ad-hoc business intelligence

Problems which require a sql solution

Scalability and performanceScalability:

Bigdata

Replications

Fault-tolerence

High-availability

MongoDB provides two types of scaling.

Read scaling: is provided by Replica Sets.

Write scaling is provided by Sharding.

Scalability and performanceScalability:

Replica sets:

A MongoDB replica set is a cluster of mongod instances that replicate amongst one another and ensure automated failover

Sharding:

MongoDB’s sharding system allows users to partition a collection within a database to distribute the collection’s documents across a number of mongod instances or shards , sharding is often termed as load-balancing feature of mongodb to ensure high traffic insert wouldn’t affect performance.

Scalability and performanceMongodb and performance:

Is it comparable to RDMBS? Mysql?

Point is it has got all and sometimes even more, that required for being a performance oriented dbms.

and it depends on how you design your db.

Support indexes

Support distributed db architecture

Most of the case mongodb is faster and requires less memory look up round then RDBMS to fetch records.

And this is why mongodb is considerable for app which requires performance boost and optimization.

SummaryMongodb is fast, reliable, scalable database management system. The main advantages as mentioned before are flexibility, scalability and performance , it is promising yet has some tradeoffs and therefore currently cannot replace the RDBMs for each situation. It is a different type of database which can be a solution, based on the requirements of the situation. It will not replace RDBMs databases and it might run well side-by-side in the future

References stackoverflow

10 gen wiki

Google

Thank you

Anshuman Ravi,10gen certified mongodb developer.