5. About StudyBlue
• Bottom-up attempt to improve student
outcomes
• Online service for storing, studying, sharing
and ultimately mastering course material
• Digital backpack for students
StudyBlue, Inc.
6. StudyBlue Usage
• Many simultaneous users
• Rapid growth
• Cyclical usage
StudyBlue, Inc.
15. Document Oriented
• System holds databases
• A database holds collections
• A collection holds documents
• A document is a set of fields written in JSON
• A field is key-value pair
• A key is a string
• A value is a basic type, an array or another document
StudyBlue, Inc.
17. Flexible Schemas
• Different documents in one collection can have different fields:
{
“author” : “sean”,
“title” : “Intro to MongoDB”
}
{
“author” : “sean”,
“title” : “Databases At Scale”,
“tags” : [ “mongodb”, “scaling” ]
}
StudyBlue, Inc.
18. Query Features
• No joins
• No transactions across documents or collections
• Atomic updates
• Simple query syntax
StudyBlue, Inc.
26. Replication
• Replica sets
• Asynchronous master/slave replication
• Consists of two or more nodes that are copies of each other
• Eventual consistency
• Automatic failover
• Automatically elects a primary (aka master)
• Automatic recovery
StudyBlue, Inc.
27. Replica Set Benefits
• Redundancy / Disaster Recovery
• Automated failover
• Read scaling
• Maintenance
StudyBlue, Inc.
29. Replica Set Elections
• Consensus Vote
• Arbiters
• Priorities
• By default, all nodes have equal priority
• Assign custom priorities for more powerful machines or specific datacenters
• Highest priority amongst the most up-to-date nodes will be elected
StudyBlue, Inc.
30. Sharding
• Horizontal scaling (write scaling)
• Automatic data partitioning & balancing
• Automatic query routing
• Each shard is typically a replica set
• Sharding is enabled per collection
StudyBlue, Inc.
31. Shards
• Shard keys define partitions
• Names one or more fields that determine how the data is distributed
• Order preserving - adjacent data (by key) tend to be stored on the same server
• Chunks
• Contiguous range of data from a particular collection
• Chunks grow to a maximum size, then split into two new chunks
• Automatically migrates chunks when chunk count is sufficiently imbalanced between
different shards
StudyBlue, Inc.
33. Sharding Pieces
• Config servers (mongoc)
• Stores cluster metadata
• Data about each shard and the chunks on that shard
• Two-phased commits
• Routing servers (mongos)
• Receives client requests and routes to appropriate server(s)
• Pulls state from config servers
• Lightweight - run anywhere (including application servers)
StudyBlue, Inc.
35. Useful Tools
• mongo shell
• mongostat
• mongotop
• Mongo Monitoring Service (MMS)
StudyBlue, Inc.
36. mongo shell
• Interactive Javascript shell
• Part of the MongoDB installation
• Issue commands & queries:
./bin/mongo mydatabase
type “help” for help
> db
mydatabase
> person = db.people.findOne( { name : "sara" } );
> person.city = "New York";
> db.people.save( person );
StudyBlue, Inc.
37. mongostat
• View statistics on a running mongod instance
StudyBlue, Inc.
38. mongotop
• Track the amount of time a MongoDB instance spends reading and
writing data on a per collection basis
StudyBlue, Inc.
39. MMS
• Free, cloud-based monitoring service
• Charts
• Dashboards
• Automated alerting
• http://mms.10gen.com
StudyBlue, Inc.
41. Good At
• Horizontal scaling
• High availability
• Rapidly evolving schemas
StudyBlue, Inc.
42. Less Good At
• Drop-in replacement for existing SQL RDBMS
• Highly transactional operations (e.g. OLTP)
• Ad-hoc business intelligence
• Durability without replica sets
• Automatic sharding != perfect data distribution
StudyBlue, Inc.
- Developer at heart\n- 15 years experience\n- Responsible for selecting Mongo\n\n
\n
- Bottom-up attempt to improve student outcomes through disruptive change outside of the education system. \n- Allows students to create and store lecture notes and flashcards and access them online and via mobile apps (iOS and Android)\n
- No public numbers\n- Thousands of simultaneous users at peak\n
\n
\n
Also called “non-relational databases”\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
update() defaults to updating ~only~ the first matching document unless “multi” is set to true.\n