SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Introduction to MongoDB 										Silicon Valley Code Camp 																			Oct 8th, 2011
Before we start…… NoSQL is a movement, its not antiSQL Relational Databases have their place, but they are not the only solution Diversify - Best tool for the job The footers contain quotes from the video Mongo DB is Web Scale
Agenda Relational Databases vs. NoSQL CAP Theorem  MongoDB at a high level Collections, Documents Inserting, Querying and Updating Other MongoDB Commands Replication Topologies Using MongoDB via a driver Few Internals Administration
Relational Databases Have been around for years De-facto standard for any persistence  ACID compliant Rigid Schema Usually hard to scale over a distributed network  Normalization is almost always a requirement ORMs tend to limit the optimizations you can do to the queries. Relational Databases were'nt built for Web Scale. They have impotence mismatch.
NoSQL Why? Not everything can be modeled in a relational construct Cluster-aware out of the box. Replication, shardingetc. is built into the core Schemaless (Mostly) Open Source, Community supported High performance by design and not ball-and-chained with ACID
CAP Theorem : Pick Two Consistency – Each client sees the same data Availability – The system is always available for any reads and writes Partition Tolerance – The system can tolerate any communication failure across the network (except someone pulling the plug across the datacenters). At any given point in time, only two of the above hold true in any distributed datastore. If thats what they need to do to get those kick ass benchmarks, then its a great design.
Visual Guide to NoSQL Databases Source: http://blog.nahurst.com/visual-guide-to-nosql-systems
How do they make up? Usually the NoSQL databases are AP, or CP. Consistency  Eventually consistent Write concerns Availability Read-only  stale data
MongoDB : High Level Document-based Database Schemaless Cluster-aware Easy Querying/Javascript Support Memory Mapped Drivers in all the popular languages Excellent developer velocity (Supported by 10gen) Durable via Journaling C-P System based on the CAP theorem MongoDB handles WebScale. You turn it on and it scales right up.
Collections The closest comparison to a MongoDB Collection in the relational world is a Table A collection is not bound by a schema A collection has a namespace Can be a capped collection It contains BSON documents
Documents Closest comparison in the relational world is a Row in a Table. Must reside within a Collection Looks like (structured) JSON, stored as BSON within a collection Limited to 16MB (as of 2.0) Larger sizes supported via GridFS Reference : http://www.bsonspec.org. Defined as Binary-encoded Serialization format for JSON-like Documents.
Inserting Documents Console defaults to localhost port 27017 show databases show collections Insert a document in a collection Bulk inserts via Javascript
Querying and Updating Documents Query a document Select certain fields Using limit, skip, sort and count Using explain In Place Updates $inc, $push, $pull, $pop, $slice, $in, $nin Indexing on fields MongoDB is a Document Database, that does not need joins. It uses Map Reduce.
Other console commands db.stats() db.collection.stats() db.isMaster() rs.status() db.currentOp() db.serverStatus()
Replication: Master Slave  Achieved by “declaring” 1 node as the master, and “declaring” many nodes as its slaves Single point of failure/No failover Can add any number of slaves easily May need to put slaves behind a load balancer
Replication : ReplicaSets Achieved by creating a cluster, called a replSet, and adding “members” to it. The “primary” and “secondary” roles are decided among the nodes. There is no permanent “master” or “slave”. Automatic Failover via voting Arbiter may be needed if there are even number of nodes to break a tie Easy to add new members Adding load-balancing will void failover
Accessing MongoDBProgramatically Scala Using casbah Code to insert a document Code to find/query Code to update
Object-Document Mappers Mongo Drivers understand Hashes, or DBObjects. A DBObject essentially is a Map The class needs to be converted to a DBObject, either by the developer or by the driver. Some such mappers also provide a DAO which makes it easy to perform CRUD operations. MongoMapper for Ruby Salat for Scala Morphia for Java
Internals Data is memory mapped, so writes can scale as no disk IO is performed with every write. Delayed writes to the disc, default 60 seconds. Always easier to keep the indices and the working set of the data in the memory to avoid swapping Pre-allocated files in increments Smart algorithm to add padding to the storage when the document sizes are inconsistent Durability is achieved by journaling, introduced in 1.7
Replication Internals The almighty Oplog – Capped Collection Acts like a tx log which the slaves or secondaries read from and apply. getmore on the primary/master every 4s Failover and voting Delayed sync Using rs.slaveOk() to query the secondaries in a replSet
Scaling MongoDB Be smart with your schema design Know ahead of time if the system will be read-heavy or write-heavy Use explain(), use indices Do not fetch the entire document - select fields. Keep an eye on index misses and page faults via mongostat Denormalize- avoid links, use embeds. You can never replicate enough Horizontal scaling via sharding If /dev/null is faster then WebScale, I’ll use it. Does /dev/null support sharding?
Backups Lock the database for a cold backup Use filer snapshots Use mongodump -> BSON, mongorestore to restore Use mongoexport -> JSON, mongoimport to restore Spare slaves always help
Monitoring MMS Developed by 10gen Munin Plugins available to monitor MongoDB Server Nagios For Machine Health Check
Comparison of NoSQL Solutions Source: http://perfectmarket.com/blog/not_only_nosql_review_solution_evaluation_guide_chart
We’re hiring!corp.ign.com/careers, and @ignjobs Scala Java PHP/Zend Rails ElasticSearch MongoDB MySQL HTML5 Jquery Mobile Sencha Touch Phonegap Wordpress ActionScript/Flash Redis/Memcached CI/CD
About Manish Pandit  Sr. Engineering Manager 	IGN Entertainment http://linkedin.com/in/mpandit @lobster1234

Weitere ähnliche Inhalte

Was ist angesagt?

Google Megastore
Google MegastoreGoogle Megastore
Google Megastore
bergwolf
 
Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)
Kai Zhao
 
Storage talk
Storage talkStorage talk
Storage talk
christkv
 
Hardware Provisioning for MongoDB
Hardware Provisioning for MongoDBHardware Provisioning for MongoDB
Hardware Provisioning for MongoDB
MongoDB
 

Was ist angesagt? (20)

Benchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDB
Benchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDBBenchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDB
Benchmarking Top NoSQL Databases: Apache Cassandra, Apache HBase and MongoDB
 
MongoDB DOC v1.5
MongoDB DOC v1.5MongoDB DOC v1.5
MongoDB DOC v1.5
 
Google Megastore
Google MegastoreGoogle Megastore
Google Megastore
 
Some key value stores using log-structure
Some key value stores using log-structureSome key value stores using log-structure
Some key value stores using log-structure
 
Gfs vs hdfs
Gfs vs hdfsGfs vs hdfs
Gfs vs hdfs
 
Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)Mongodb introduction and_internal(simple)
Mongodb introduction and_internal(simple)
 
HBaseCon 2012 | Gap Inc Direct: Serving Apparel Catalog from HBase for Live W...
HBaseCon 2012 | Gap Inc Direct: Serving Apparel Catalog from HBase for Live W...HBaseCon 2012 | Gap Inc Direct: Serving Apparel Catalog from HBase for Live W...
HBaseCon 2012 | Gap Inc Direct: Serving Apparel Catalog from HBase for Live W...
 
ImpalaToGo and Tachyon integration
ImpalaToGo and Tachyon integrationImpalaToGo and Tachyon integration
ImpalaToGo and Tachyon integration
 
MongoDB presentation
MongoDB presentationMongoDB presentation
MongoDB presentation
 
Tech Talk: RocksDB Slides by Dhruba Borthakur & Haobo Xu of Facebook
Tech Talk: RocksDB Slides by Dhruba Borthakur & Haobo Xu of FacebookTech Talk: RocksDB Slides by Dhruba Borthakur & Haobo Xu of Facebook
Tech Talk: RocksDB Slides by Dhruba Borthakur & Haobo Xu of Facebook
 
GFS & HDFS Introduction
GFS & HDFS IntroductionGFS & HDFS Introduction
GFS & HDFS Introduction
 
The Hive Think Tank: Rocking the Database World with RocksDB
The Hive Think Tank: Rocking the Database World with RocksDBThe Hive Think Tank: Rocking the Database World with RocksDB
The Hive Think Tank: Rocking the Database World with RocksDB
 
Glusterfs and Hadoop
Glusterfs and HadoopGlusterfs and Hadoop
Glusterfs and Hadoop
 
Gluster Webinar: Introduction to GlusterFS v3.3
Gluster Webinar: Introduction to GlusterFS v3.3Gluster Webinar: Introduction to GlusterFS v3.3
Gluster Webinar: Introduction to GlusterFS v3.3
 
Hadoop architecture-tutorial
Hadoop  architecture-tutorialHadoop  architecture-tutorial
Hadoop architecture-tutorial
 
Optimizing RocksDB for Open-Channel SSDs
Optimizing RocksDB for Open-Channel SSDsOptimizing RocksDB for Open-Channel SSDs
Optimizing RocksDB for Open-Channel SSDs
 
Log Structured Merge Tree
Log Structured Merge TreeLog Structured Merge Tree
Log Structured Merge Tree
 
Storage talk
Storage talkStorage talk
Storage talk
 
Ceph and RocksDB
Ceph and RocksDBCeph and RocksDB
Ceph and RocksDB
 
Hardware Provisioning for MongoDB
Hardware Provisioning for MongoDBHardware Provisioning for MongoDB
Hardware Provisioning for MongoDB
 

Andere mochten auch

E Learning 2 E
E Learning 2 EE Learning 2 E
E Learning 2 E
hainira
 
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΒΙΟΛΟΓΙΑΣ Α ΛΥΚΕΙΟΥ 2011-12φεκ διδασκαλιασ βιολογιασ α λυκειο...
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΒΙΟΛΟΓΙΑΣ Α ΛΥΚΕΙΟΥ 2011-12φεκ διδασκαλιασ βιολογιασ α λυκειο...ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΒΙΟΛΟΓΙΑΣ Α ΛΥΚΕΙΟΥ 2011-12φεκ διδασκαλιασ βιολογιασ α λυκειο...
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΒΙΟΛΟΓΙΑΣ Α ΛΥΚΕΙΟΥ 2011-12φεκ διδασκαλιασ βιολογιασ α λυκειο...
Christos Gotzaridis
 
Keep Our Boreal As A Sink
Keep Our Boreal As A SinkKeep Our Boreal As A Sink
Keep Our Boreal As A Sink
Dean McKeown
 
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixOSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
Manish Pandit
 
Political Cartoon
Political CartoonPolitical Cartoon
Political Cartoon
Amy
 
第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource
Kaz Watanabe
 
2012 0614 mobility tech focus pres (wrt)
2012 0614 mobility tech focus pres (wrt)2012 0614 mobility tech focus pres (wrt)
2012 0614 mobility tech focus pres (wrt)
Bill Tomoff
 
استخدام المدونات و الويكي في التعليم
استخدام المدونات و الويكي في التعليماستخدام المدونات و الويكي في التعليم
استخدام المدونات و الويكي في التعليم
Fawaz Gogo
 
EFFICACIA DI UN SISTEMA DI VISUALIZZAZIONE SOCIALE NELL‟INFLUENZARE UN CAMBIO...
EFFICACIA DI UN SISTEMA DI VISUALIZZAZIONE SOCIALE NELL‟INFLUENZARE UN CAMBIO...EFFICACIA DI UN SISTEMA DI VISUALIZZAZIONE SOCIALE NELL‟INFLUENZARE UN CAMBIO...
EFFICACIA DI UN SISTEMA DI VISUALIZZAZIONE SOCIALE NELL‟INFLUENZARE UN CAMBIO...
Michele Pierangeli
 
20150901 Mapping Yorkshire
20150901 Mapping Yorkshire20150901 Mapping Yorkshire
20150901 Mapping Yorkshire
dbyhundred
 
Onlinetools&Job Search2010
Onlinetools&Job Search2010Onlinetools&Job Search2010
Onlinetools&Job Search2010
Cindy Edwards
 

Andere mochten auch (20)

E Learning 2 E
E Learning 2 EE Learning 2 E
E Learning 2 E
 
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΒΙΟΛΟΓΙΑΣ Α ΛΥΚΕΙΟΥ 2011-12φεκ διδασκαλιασ βιολογιασ α λυκειο...
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΒΙΟΛΟΓΙΑΣ Α ΛΥΚΕΙΟΥ 2011-12φεκ διδασκαλιασ βιολογιασ α λυκειο...ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΒΙΟΛΟΓΙΑΣ Α ΛΥΚΕΙΟΥ 2011-12φεκ διδασκαλιασ βιολογιασ α λυκειο...
ΦΕΚ ΔΙΔΑΣΚΑΛΙΑΣ ΒΙΟΛΟΓΙΑΣ Α ΛΥΚΕΙΟΥ 2011-12φεκ διδασκαλιασ βιολογιασ α λυκειο...
 
Keep Our Boreal As A Sink
Keep Our Boreal As A SinkKeep Our Boreal As A Sink
Keep Our Boreal As A Sink
 
Innovation, Openness And ICTs
Innovation, Openness And ICTsInnovation, Openness And ICTs
Innovation, Openness And ICTs
 
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at NetflixOSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
 
Mapping an all-weather Tour de France
Mapping an all-weather Tour de FranceMapping an all-weather Tour de France
Mapping an all-weather Tour de France
 
Ace ppt for asean japan energy efficient conference-final
Ace ppt for asean japan energy efficient conference-finalAce ppt for asean japan energy efficient conference-final
Ace ppt for asean japan energy efficient conference-final
 
ΦΥΣΙΚΗ ΤΩΝ ΡΕΥΣΤΩΝ ερωτήσεις για το 2ο θέμα
ΦΥΣΙΚΗ ΤΩΝ ΡΕΥΣΤΩΝ ερωτήσεις για το 2ο θέμαΦΥΣΙΚΗ ΤΩΝ ΡΕΥΣΤΩΝ ερωτήσεις για το 2ο θέμα
ΦΥΣΙΚΗ ΤΩΝ ΡΕΥΣΤΩΝ ερωτήσεις για το 2ο θέμα
 
Political Cartoon
Political CartoonPolitical Cartoon
Political Cartoon
 
第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource第49回Php勉強会@関東 Datasource
第49回Php勉強会@関東 Datasource
 
2012 0614 mobility tech focus pres (wrt)
2012 0614 mobility tech focus pres (wrt)2012 0614 mobility tech focus pres (wrt)
2012 0614 mobility tech focus pres (wrt)
 
استخدام المدونات و الويكي في التعليم
استخدام المدونات و الويكي في التعليماستخدام المدونات و الويكي في التعليم
استخدام المدونات و الويكي في التعليم
 
EFFICACIA DI UN SISTEMA DI VISUALIZZAZIONE SOCIALE NELL‟INFLUENZARE UN CAMBIO...
EFFICACIA DI UN SISTEMA DI VISUALIZZAZIONE SOCIALE NELL‟INFLUENZARE UN CAMBIO...EFFICACIA DI UN SISTEMA DI VISUALIZZAZIONE SOCIALE NELL‟INFLUENZARE UN CAMBIO...
EFFICACIA DI UN SISTEMA DI VISUALIZZAZIONE SOCIALE NELL‟INFLUENZARE UN CAMBIO...
 
20150901 Mapping Yorkshire
20150901 Mapping Yorkshire20150901 Mapping Yorkshire
20150901 Mapping Yorkshire
 
Calendário II Divisão Zona Sul
Calendário II Divisão Zona SulCalendário II Divisão Zona Sul
Calendário II Divisão Zona Sul
 
Onlinetools&Job Search2010
Onlinetools&Job Search2010Onlinetools&Job Search2010
Onlinetools&Job Search2010
 
Θεματικη οργανωση της Φυσικής Γ΄Γυμν.
Θεματικη οργανωση της Φυσικής Γ΄Γυμν.Θεματικη οργανωση της Φυσικής Γ΄Γυμν.
Θεματικη οργανωση της Φυσικής Γ΄Γυμν.
 
MongoSF 2011 - Using MongoDB for IGN's Social Platform
MongoSF 2011 - Using MongoDB for IGN's Social PlatformMongoSF 2011 - Using MongoDB for IGN's Social Platform
MongoSF 2011 - Using MongoDB for IGN's Social Platform
 
ThirdSpace: orchestrating collaborative activities in PLEs for formal learning
ThirdSpace: orchestrating collaborative activities in PLEs for formal learningThirdSpace: orchestrating collaborative activities in PLEs for formal learning
ThirdSpace: orchestrating collaborative activities in PLEs for formal learning
 
Makeup Consultations & Professional Makeup: A Beautiful Education
Makeup Consultations & Professional Makeup: A Beautiful EducationMakeup Consultations & Professional Makeup: A Beautiful Education
Makeup Consultations & Professional Makeup: A Beautiful Education
 

Ähnlich wie Silicon Valley Code Camp: 2011 Introduction to MongoDB

mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
RoopaR36
 
Mongo presentation conf
Mongo presentation confMongo presentation conf
Mongo presentation conf
Shridhar Joshi
 
DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012
Appirio
 

Ähnlich wie Silicon Valley Code Camp: 2011 Introduction to MongoDB (20)

mongodb11 (1) (1).pptx
mongodb11 (1) (1).pptxmongodb11 (1) (1).pptx
mongodb11 (1) (1).pptx
 
Mongo db transcript
Mongo db transcriptMongo db transcript
Mongo db transcript
 
Mongo presentation conf
Mongo presentation confMongo presentation conf
Mongo presentation conf
 
Top MongoDB interview Questions and Answers
Top MongoDB interview Questions and AnswersTop MongoDB interview Questions and Answers
Top MongoDB interview Questions and Answers
 
MongoDB 2.4 and spring data
MongoDB 2.4 and spring dataMongoDB 2.4 and spring data
MongoDB 2.4 and spring data
 
Nosql seminar
Nosql seminarNosql seminar
Nosql seminar
 
nosql [Autosaved].pptx
nosql [Autosaved].pptxnosql [Autosaved].pptx
nosql [Autosaved].pptx
 
No SQL - MongoDB
No SQL - MongoDBNo SQL - MongoDB
No SQL - MongoDB
 
Mongodb basics and architecture
Mongodb basics and architectureMongodb basics and architecture
Mongodb basics and architecture
 
DynamoDB Gluecon 2012
DynamoDB Gluecon 2012DynamoDB Gluecon 2012
DynamoDB Gluecon 2012
 
Gluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDBGluecon 2012 - DynamoDB
Gluecon 2012 - DynamoDB
 
Mongo db
Mongo dbMongo db
Mongo db
 
MongoDb - Details on the POC
MongoDb - Details on the POCMongoDb - Details on the POC
MongoDb - Details on the POC
 
Introduction to MongoDB.pptx
Introduction to MongoDB.pptxIntroduction to MongoDB.pptx
Introduction to MongoDB.pptx
 
Mongodb
MongodbMongodb
Mongodb
 
MongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of viewMongoDB vs Mysql. A devops point of view
MongoDB vs Mysql. A devops point of view
 
Mongo db dhruba
Mongo db dhrubaMongo db dhruba
Mongo db dhruba
 
MongoDB
MongoDBMongoDB
MongoDB
 
NoSql Databases
NoSql DatabasesNoSql Databases
NoSql Databases
 
Mongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorialMongo Bb - NoSQL tutorial
Mongo Bb - NoSQL tutorial
 

Mehr von Manish Pandit

Mehr von Manish Pandit (20)

Disaster recovery - What, Why, and How
Disaster recovery - What, Why, and HowDisaster recovery - What, Why, and How
Disaster recovery - What, Why, and How
 
Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018Serverless Architectures on AWS in practice - OSCON 2018
Serverless Architectures on AWS in practice - OSCON 2018
 
Disaster Recovery and Reliability
Disaster Recovery and ReliabilityDisaster Recovery and Reliability
Disaster Recovery and Reliability
 
OAuth2 primer
OAuth2 primerOAuth2 primer
OAuth2 primer
 
Immutable AWS Deployments with Packer and Jenkins
Immutable AWS Deployments with Packer and JenkinsImmutable AWS Deployments with Packer and Jenkins
Immutable AWS Deployments with Packer and Jenkins
 
AWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and JavaAWS Lambda with Serverless Framework and Java
AWS Lambda with Serverless Framework and Java
 
AWS Primer and Quickstart
AWS Primer and QuickstartAWS Primer and Quickstart
AWS Primer and Quickstart
 
Securing your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID ConnectSecuring your APIs with OAuth, OpenID, and OpenID Connect
Securing your APIs with OAuth, OpenID, and OpenID Connect
 
Silicon Valley 2014 - API Antipatterns
Silicon Valley 2014 - API AntipatternsSilicon Valley 2014 - API Antipatterns
Silicon Valley 2014 - API Antipatterns
 
Scalabay - API Design Antipatterns
Scalabay - API Design AntipatternsScalabay - API Design Antipatterns
Scalabay - API Design Antipatterns
 
API Design Antipatterns - APICon SF
API Design Antipatterns - APICon SFAPI Design Antipatterns - APICon SF
API Design Antipatterns - APICon SF
 
Motivation : it Matters
Motivation : it MattersMotivation : it Matters
Motivation : it Matters
 
Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2Building Apis in Scala with Playframework2
Building Apis in Scala with Playframework2
 
Scala at Netflix
Scala at NetflixScala at Netflix
Scala at Netflix
 
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGNIntroducing Scala to your Ruby/Java Shop : My experiences at IGN
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
 
Evolving IGN’s New APIs with Scala
 Evolving IGN’s New APIs with Scala Evolving IGN’s New APIs with Scala
Evolving IGN’s New APIs with Scala
 
IGN's V3 API
IGN's V3 APIIGN's V3 API
IGN's V3 API
 
Java and the JVM
Java and the JVMJava and the JVM
Java and the JVM
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Silicon Valley Code Camp 2011: Play! as you REST
Silicon Valley Code Camp 2011: Play! as you RESTSilicon Valley Code Camp 2011: Play! as you REST
Silicon Valley Code Camp 2011: Play! as you REST
 

Kürzlich hochgeladen

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Silicon Valley Code Camp: 2011 Introduction to MongoDB

  • 1. Introduction to MongoDB Silicon Valley Code Camp Oct 8th, 2011
  • 2. Before we start…… NoSQL is a movement, its not antiSQL Relational Databases have their place, but they are not the only solution Diversify - Best tool for the job The footers contain quotes from the video Mongo DB is Web Scale
  • 3. Agenda Relational Databases vs. NoSQL CAP Theorem MongoDB at a high level Collections, Documents Inserting, Querying and Updating Other MongoDB Commands Replication Topologies Using MongoDB via a driver Few Internals Administration
  • 4. Relational Databases Have been around for years De-facto standard for any persistence ACID compliant Rigid Schema Usually hard to scale over a distributed network Normalization is almost always a requirement ORMs tend to limit the optimizations you can do to the queries. Relational Databases were'nt built for Web Scale. They have impotence mismatch.
  • 5. NoSQL Why? Not everything can be modeled in a relational construct Cluster-aware out of the box. Replication, shardingetc. is built into the core Schemaless (Mostly) Open Source, Community supported High performance by design and not ball-and-chained with ACID
  • 6. CAP Theorem : Pick Two Consistency – Each client sees the same data Availability – The system is always available for any reads and writes Partition Tolerance – The system can tolerate any communication failure across the network (except someone pulling the plug across the datacenters). At any given point in time, only two of the above hold true in any distributed datastore. If thats what they need to do to get those kick ass benchmarks, then its a great design.
  • 7. Visual Guide to NoSQL Databases Source: http://blog.nahurst.com/visual-guide-to-nosql-systems
  • 8. How do they make up? Usually the NoSQL databases are AP, or CP. Consistency Eventually consistent Write concerns Availability Read-only stale data
  • 9. MongoDB : High Level Document-based Database Schemaless Cluster-aware Easy Querying/Javascript Support Memory Mapped Drivers in all the popular languages Excellent developer velocity (Supported by 10gen) Durable via Journaling C-P System based on the CAP theorem MongoDB handles WebScale. You turn it on and it scales right up.
  • 10. Collections The closest comparison to a MongoDB Collection in the relational world is a Table A collection is not bound by a schema A collection has a namespace Can be a capped collection It contains BSON documents
  • 11. Documents Closest comparison in the relational world is a Row in a Table. Must reside within a Collection Looks like (structured) JSON, stored as BSON within a collection Limited to 16MB (as of 2.0) Larger sizes supported via GridFS Reference : http://www.bsonspec.org. Defined as Binary-encoded Serialization format for JSON-like Documents.
  • 12. Inserting Documents Console defaults to localhost port 27017 show databases show collections Insert a document in a collection Bulk inserts via Javascript
  • 13. Querying and Updating Documents Query a document Select certain fields Using limit, skip, sort and count Using explain In Place Updates $inc, $push, $pull, $pop, $slice, $in, $nin Indexing on fields MongoDB is a Document Database, that does not need joins. It uses Map Reduce.
  • 14. Other console commands db.stats() db.collection.stats() db.isMaster() rs.status() db.currentOp() db.serverStatus()
  • 15. Replication: Master Slave Achieved by “declaring” 1 node as the master, and “declaring” many nodes as its slaves Single point of failure/No failover Can add any number of slaves easily May need to put slaves behind a load balancer
  • 16. Replication : ReplicaSets Achieved by creating a cluster, called a replSet, and adding “members” to it. The “primary” and “secondary” roles are decided among the nodes. There is no permanent “master” or “slave”. Automatic Failover via voting Arbiter may be needed if there are even number of nodes to break a tie Easy to add new members Adding load-balancing will void failover
  • 17. Accessing MongoDBProgramatically Scala Using casbah Code to insert a document Code to find/query Code to update
  • 18. Object-Document Mappers Mongo Drivers understand Hashes, or DBObjects. A DBObject essentially is a Map The class needs to be converted to a DBObject, either by the developer or by the driver. Some such mappers also provide a DAO which makes it easy to perform CRUD operations. MongoMapper for Ruby Salat for Scala Morphia for Java
  • 19. Internals Data is memory mapped, so writes can scale as no disk IO is performed with every write. Delayed writes to the disc, default 60 seconds. Always easier to keep the indices and the working set of the data in the memory to avoid swapping Pre-allocated files in increments Smart algorithm to add padding to the storage when the document sizes are inconsistent Durability is achieved by journaling, introduced in 1.7
  • 20. Replication Internals The almighty Oplog – Capped Collection Acts like a tx log which the slaves or secondaries read from and apply. getmore on the primary/master every 4s Failover and voting Delayed sync Using rs.slaveOk() to query the secondaries in a replSet
  • 21. Scaling MongoDB Be smart with your schema design Know ahead of time if the system will be read-heavy or write-heavy Use explain(), use indices Do not fetch the entire document - select fields. Keep an eye on index misses and page faults via mongostat Denormalize- avoid links, use embeds. You can never replicate enough Horizontal scaling via sharding If /dev/null is faster then WebScale, I’ll use it. Does /dev/null support sharding?
  • 22. Backups Lock the database for a cold backup Use filer snapshots Use mongodump -> BSON, mongorestore to restore Use mongoexport -> JSON, mongoimport to restore Spare slaves always help
  • 23. Monitoring MMS Developed by 10gen Munin Plugins available to monitor MongoDB Server Nagios For Machine Health Check
  • 24. Comparison of NoSQL Solutions Source: http://perfectmarket.com/blog/not_only_nosql_review_solution_evaluation_guide_chart
  • 25. We’re hiring!corp.ign.com/careers, and @ignjobs Scala Java PHP/Zend Rails ElasticSearch MongoDB MySQL HTML5 Jquery Mobile Sencha Touch Phonegap Wordpress ActionScript/Flash Redis/Memcached CI/CD
  • 26. About Manish Pandit Sr. Engineering Manager IGN Entertainment http://linkedin.com/in/mpandit @lobster1234