12 months with MongoDB

Source: Internet
Author: User
12 months with MongoDB

Happy Monday everyone!

As previusly blogged, wordnik is a heavy user of 10gen's MongoDB. one year ago today we started the investigation to find an alternative to MySQL to store, find, and retrieve our corpus data. after months of experimentation in the non-relational landscape (and running a scary number of nightly builds), we settled on MongoDB. to mark the one-year anniversary of what ended up being a great move for wordnik, I'll describe a summary of how the migration has worked out for us.

Performance. The primary driver for migrating to MongoDB was for performance. We had issues with MySQL for both storage and retrieval, and both were alleviated by MongoDB. Some statistics:

  • Mongo serves an average of 500 k requests/hour for US (that does include nights and weekends). We typically see 4x that during peak hours
  • We have> 12 billion documents in Mongo
  • Our storage is ~ 3 TB per node
  • We easily sustain an insert speed of 8 K sort ents/second, often burst to 50 K/sec
  • A single Java client can sustain 10 MB/sec read over the backend (Gigabit) network to one transaction D. Four readers from the same client pull 40 MB/sec over the same Pipe
  • Every type of retrieval has become significantly faster than our MySQL implementation:

-Example fetch time CED from 400 ms to 60 ms
-Dictionary entries from 20 ms to 1 ms
-Document metadata from 30 ms to. 1 ms
-Spelling suggestions from 10 ms to 1.2 ms

One wonderful benefit to the built-in caching from Mongo is that taking our memcached layer out actually sped up cballs by 1-2 ms/call under load. this also frees up memory GB of RAM. we clearly cannot fit all our corpus data in Ram so the 60 ms average for examples between des disk access.

Flexibility. We 've been able to add a lot of flexibility to our system since we can now efficiently execute queries against attributes deep in the object graph. you 'd need to design a really uugly schema to do this in MySQL (although it can be done ). best of all, by essential building indexes on Object Attributes, these queries are blazingly fast.

Other benefits:

  • We now store our audio files in MongoDB's gridfs. previusly we used a clustered file system so files cocould be read and written from multiple servers. this created a huge amount of complexity from the IT operations point of view, and it meant that system backups (database + audio data) cocould get out of sync. now that they're in Mongo, we can reach them anywhere in the data center with the same Mongo driver, and backups are consistent guest ss the system.
  • Capped collections. We keep trend data inside capped collections, which have been wonderful for keeping datasets from unbounded growth.

Reliability. Of course, storing all your critical data in a relatively new technology has its risks. so far, we 've done well from a reliability standpoint. since else l, we 've had to restart Mongo twice. the first restart was to apply a patch on 1.4.2 (we're currently running 1.4.4) to address some replication issues. the second was due to an outage in our data center. more on that in a bit.

Maintainability. This is one challenge for a new player like MongoDB. the administrative tools are pretty immature when compared with a product like MySQL. there is a blurry hand-off between engineering and IT operations for this product, which is something worth noting. luckily for all of us, there are plenty of hooks in Mongo to allow for good tools to be built, and without a doubt there will be a number of great applications to help manage Mongo.

The size of our database has required us to build some tools for helping to maintain Mongo, which I'll be talking about at least Sv in December. the bottom line is yes-you can run and maintain MongoDB, but it is important to understand the relationship between your server and your data.

The outage we had in our data center caused a major panic. we lost our das device during heavy writes to the server-this caused resume uption on both master and slave nodes. the master was busy flushing data to disk while the slave was applying operations via oplog. when the DAS came back online, we had to run a repair on our master node which took over 24 hours. the slave was compromised yet operable-we were able to promote that to being the master while repairing the other system.

Restoring from tape was an option but keep in mind, even a fast tape drive will take a chunk of time to recover 3 TB data, let alone lose the data between the last backup and the outage. luckily we didn't have to go down this path. we also had an in-house Incremental backup + point-in-time recovery tool which we'll be making open-source before sans Sv.

Of course, there have been a few surprises in this process, and some good learnings to share.

Data size. At the maximum SF conference in limit L, I whined about the 4x disk space requirements of MongoDB. later, the 10gen folks pointed out how collection-level padding works in Mongo and for our scenario-hundreds of collections with an average of 1 GB padding/collection-we were wasting a ton of disk in this alone. we also were able to embed a number of objects in subdocuments and drop indexes-This got our storage costs under control-now only about 1.5-2x that of our former MySQL deployment.

Locking. There are operations that will lock MongoDB at the database level. when you're serving hundreds of requests a second, this can cause requests to pile up and create lots of problems. we 've done the following Optimizations to avoid locking:

  • If updating a record, we always query the record before issuing the update. that gets the object in Ram and the update will operate as fast as possible. the same logic has been added for Master/Slave deployments where the slave can be run with "-pretouch" which causes a query on the object before issuing the update
  • Multiple mongod processes. We have split up our database to run in multiple processes based on access patterns.

In summary, life with MongoDB has been good for wordnik. Our code is faster, more flexible and dramatically smaller. We can code up tools to help out the administrative side until other options surface.

Hope this has been informative and entertaining-you can always see MongoDB in action via our public API.

Tony

Orgional Source: http://blog.wordnik.com/12-months-with-mongodb

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.