In Kristina Chodorow, software engineer at 10gen, latest post she walks us through several recovery scenarios that could occur while using MongoDB. Of course, a straight list would boring... but choose your own adventure, how could you resist.
Entries in MongoDB (83)
Kristina Chodorow, software engineer at 10gen, will be discussing how to scale with MongoDB this Friday (9/17) at 10am PST.
Full description of the webcast:
MongoDB's architecture features built-in support for horizontal scalability, and high availability through replica sets. Auto-sharding allows users to easily distribute data across many nodes. Replica sets enable automatic failover and recovery of database nodes within or across data centers. This webcast will provide an introduction to scaling with MongoDB by one of the developers working on the project.
For those who need reminders follow us on Twitter or Facebook, we'll send out a reminder on Friday morning 6am PST.
Sign up for the webcast here: Scaling with MongoDB
Kristina Chodorow has a post where she discusses a few tweaks you can make to your code to improve performance in MongoDB.
Some of the recommendations at a high level are basic, such as the recommendation to not waste any connections. However, there are some pretty interesting side effects with the PHP connection code.
$connection = new Mongo();
In the previous code it appears the user wants to create a new connection. However, under the hood the following is happening:
- The constructor connects to the database.
connect()sees that you’re already connected, assumes you want to reset the connection.
- Disconnects from the database.
- Connects again.
The result is that you have doubled your execution time. This is just one example of many that Kristina provides. If you are using MongoDB I'd suggest you check it out.
Read more: Oh, the Mistakes I've Seen
Christina Chodorow, of 10Gen discusses a tool that comes with the binary distribution of MongoDB, mongosniff.
Writing an application on top of a framework on top of a driver on top of the database is a bit like playing telephone: you say “insert foo” and the database says “purple monkey dishwasher.” mongosniff lets you see exactly what the database is hearing and saying.
Read more: A Quick Intro to mongosniff
Version 1.6.2 of MongoDB was release a few days ago. While this release contains primarily bug fixes users of 1.6.0 and 1.6.1 are encouraged to upgrade.
- Database isolation issue with concurrency and deletion of objects
- Concurrency issue when doing in-memory sort
- Current operation tracking could cause segfault while being accessed
- Replica set initialization segfault fixed
- Map reduce sort option working again
- Administrative enhancements for using replica sets as shards
Download the latest release here: MongoDB Downloads
A couple of weeks ago at the MongoDB NY User Group, Brendan W. McAdams, discused using MongoDB with the Scala language. McAdams walks us through some of the basics of both the Scala language and MongoDB. In addition, he dives in to explaining how to integrate the two together in order to start solving your problems.
Greg Shackles has an interesting article about a .NET driver, NoRM, that provides abbreviations to attribute field names automatically. So for instance suppose you had a Person object that had a first and a last name. Normally that would be stored in the database as firstName and lastName. NoRM changes that, it allows for a custom mapping from the property to the field name. So firstName might end up as fn, lastName ln.
There is a free webcast today at 10am PST, Introduction to MongoDB
This talk will provide an introduction to MongoDB from one of the developers working on the project. The webcast will be accessible to those who are completely new to MongoDB and non-relational databases, but will touch on some of the advanced functionality that makes MongoDB a compelling option for all web developers
Here's the link: Introduction to MongoDB
MongoDB recently released version 1.6, one of the key features of that release, replica sets. In this presentation, by Dwight Merriman he discusses replica sets, specifically the basics, design, etc.
What makes a replica set?
- A cluster of N servers
- Any (one) node can be primary
- Consensus election of primary
- Automatic failover
- Automatic recovery
- All writes to primary
- Reads can be to primary (default) or a secondary
Key Design Concepts:
- A write is only truly committed once it has replicated to a majority of servers in the set. Thus, for important writes, the developer waits for confirmation of the cluster-wide commit with the getLastError command.
- Writes which are committed at the master of the set may be visible before the true cluster-wide commit has occurred. This property, which is more relaxed than some traditional products, makes theoretically achievable performance and availability higher.
- On a failover, if there is data which has not replicated form the primary, the data is dropped (see #1).
Check out the entire presentation below:
MongoDB 1.6.1 is now available for users.
- CPU usage with replica sets when a node is down is improved
- Replica sets are handled better by repair
- Fix granular timing system on windows
- Improved regular slave initial sync time with multiple databases
- Make distinct yield
- Improve some cursor interactions when using sharding in combination with replica sets
Get the release here: MongoDB Downloads
After significant time in development, sharding and replica sets have been incorporated into MongoDB with the 1.6.0 release. Why is this important?
Sharding will allow us to let MongoDB handle distribution of data across any number of nodes to maximise use of disk space and dynamically load balance queries. Replica sets provides automated failover and redundancy so you can be sure your data exists on any number of servers across multiple data centres.
This is definitely good news for MongoDB users. However, how do you set up replica sets and sharding? David Mytton, of Boxed Ice, has written a great tutorial, complete with videos on how to set up both replica sets and sharding on a MongoDB cluster.
Derick Rethans has an interesting article in which he attempts to store 64-bit integers in MongoDB using PHP. There are some pretty interesting caveats not only with MongoDB but PHP as well.
The documentation of the MongoDB PHP driver on types says (or used to say, depending on when you're reading this) that only the 32-bit signed integer type is supported because "PHP does not support 8 byte integers". That's not quite true. PHP's integer type supports 64-bit on the platforms where the C-data type long is 64 bits. That is generally on every 64-bit platform (where PHP is compiled for 64 bits); except on Windows, where the C-data type long is always only 32 bits.
In conclusion, Rethans offers some advice for others bravely choosing this path
Getting 64-bit support right with MongoDB can be tricky
Read more: 64-bit integers in MongoDB
Alex Sharp, the Lead Developer at OptimusDev, discusses in his presentation at Ruby Midwest some practical Ruby projects for MongoDB. Things are typically easier when you see a use case and an implementation that solves the use case. That is the approach that Alex has taken in his presentation he presents four use cases:
- Accounting Application
- Capped Collection Logging
- Blogging App
- Reporting App
There are several points that Alex discusses, however, here are a few highlights:
- Instead of JOINs across separate tables you can use embedded documents.
- Embedded documents eliminate many modeling headaches
- MongoDB allows for fast writes (fire and forget)
- In-place updates
- Optimize your reads with indexes
Check it out!
I'd like to thank all of the folks that came out to the first San Diego NoSQL meetup group. Special thanks to both Charles Glommen, for organizing the meeting and TouchCommerce for sponsoring the meeting.
I've included the slides from last night's presentations