Evolution of mongodb
-
Upload
anshuman-mishra -
Category
Documents
-
view
420 -
download
0
description
Transcript of Evolution of mongodb
![Page 1: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/1.jpg)
Evolution of Mongodb
An introduction to what and why is mongodb
![Page 2: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/2.jpg)
What is Mongodb ? Humongous
{name:mongodb,type:db}
10gen
![Page 3: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/3.jpg)
What is Mongodb ? Non-relational
Json/bson document store
Nosql What is it?
Schemaless , what is schema less? And why?
![Page 4: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/4.jpg)
Agenda Why mongodb is required or where mongodb
fits in
Mongodb schemaless architecture
Mongodb and RDBMS
Scalability and performance
Summary
![Page 5: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/5.jpg)
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
![Page 6: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/6.jpg)
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
![Page 7: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/7.jpg)
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
![Page 8: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/8.jpg)
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
![Page 9: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/9.jpg)
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 ?
![Page 10: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/10.jpg)
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?
![Page 11: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/11.jpg)
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?
![Page 12: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/12.jpg)
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.
![Page 13: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/13.jpg)
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
![Page 14: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/14.jpg)
Mongodb & RDMBS Is mongodb replacement for RDBMS?
When you should consider mongodb over RDBMS?
What are pros and cons using mongodb?
![Page 15: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/15.jpg)
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?
![Page 16: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/16.jpg)
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?
![Page 17: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/17.jpg)
Mongodb & RDMBS How mongodb exists without join?
![Page 18: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/18.jpg)
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?
![Page 19: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/19.jpg)
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?
![Page 20: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/20.jpg)
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”}
{-----},
]
}
![Page 21: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/21.jpg)
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?
![Page 22: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/22.jpg)
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
![Page 23: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/23.jpg)
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.
![Page 24: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/24.jpg)
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.
![Page 25: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/25.jpg)
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.
![Page 26: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/26.jpg)
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
![Page 27: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/27.jpg)
References stackoverflow
10 gen wiki
![Page 28: Evolution of mongodb](https://reader036.fdocuments.us/reader036/viewer/2022062512/553b7d244a79593e2c8b46e5/html5/thumbnails/28.jpg)
Thank you
Anshuman Ravi,10gen certified mongodb developer.