Tech Pontificator
Ramblings for technology Nerds
MongoDB and Hardware Profiles
Posted by on September 11, 2012
I have attempted to put together some guidance that can help in determining what sort of hardware makes sense for MongoDB in varying situations. This is really an elaboration on publicly available information and an abbreviated version dashed off at 2:00 am by Dwight Merriman (who is far smarter than I, one of the original authors of MongoDB, and CEO of 10gen).
Philosophy
“The philosophy of MongoDB is to use commodity componentry to build clusters and to build them assuming that any single server can fail at any time. This is to say, a cloud-computing style of hardware is acceptable.” – Dwight Merriman
It seems almost too obvious to say, but the exact ratio of resources ideal for MongoDB will vary based upon the use case and performance requirements. Some applications, for example, which require the utmost read performance will wish to keep their entire data sets resident in memory. Other applications have high write loads and IOPS (Input Output Operations per Second) become more important. In general, however, total RAM and random disk IOPS are important considerations. Below, we shall examine in more detail the importance of the essential computing resources of CPU, RAM, Storage, Network, and IOPS.
General Rule on Server Size
While ratios of resources will vary, it is usually best to go with a server that is reasonably large so that there are not too many servers to administer, yet not so expensive that it is uneconomic from diminishing returns. Commodity servers costing about $10,000 are common in mongo deployments.
CPU
MongoDB is optimized for 64 bit architecture at both the hardware and OS level. One should use a 64 bit Intel or AMD processor with a corresponding 64 bit OS. NUMA is not very helpful in database applications, thus non-NUMA is fine. NUMA machines work but NUMA should be disabled (interleaved) when used with MongoDB for best results. For more information on NUMA see http://www.mongodb.org/display/DOCS/NUMA
CPU is not a common limiting resource for MongoDB. One usage profile that can be the exception is where heavy usage of MongoDB’s map-reduce or aggregation framework will be taking place. This usage profile also raises an additional consideration for CPU of boxes running the mongos process. The mongos process is responsible for coordinating client requests across sharded configurations. Performance concerns for the mongos process are rarely considered since typically they are lightweight processes that are installed on application servers running the MongoDB client code. Aggregation, whether from map-reduce, the aggregation framework, or the hadoop connector against a sharded MongoDB collection will drive CPU cycles to the boxes running the mongos instances. Latency requirements and testing should be done to determine how much CPU should be allocated for mongos processes under these circumstances.
RAM
Since MongoDB makes extensive use of memory mapping the more you have the merrier you will be! MongoDB will make much better use of memory for accelerating operations than a typical RDBMS. It is very common to run MongoDB on servers configured with 64GB, 128GB, or even 256GB of memory. Many customers, requiring the utmost query and read performance, will have enough memory across the cluster to keep their indexes and full data set in memory. The beauty of MongoDB is that it allows you to scale this out across a cluster of machines by simply adding more shards as your dataset grows. At a minimum you will want enough memory in each box to store indexes and in many use cases additional memory beyond this to store commonly accessed documents.
Network
Commodity gigabit ethernet usually works fine in practice. Be sure to have switches that can handle a high backplane load from the cluster if the cluster is large. A very common mistake is to use gigabit ethernet but have a 100 mbps switch somewhere in the cluster throttling throughput. It is generally recommend that one uses only one ethernet port per server, with that port servicing both client requests as well as intra-cluster communications.
Storage
In the intensive read/query usage profile, system memory outweighs storage as the most important resource. Where the importance of storage and IOPS becomes more significant is in cases where you have heavy insert-update-delete (IUD) workloads. Within this broad category there are many specific usage patterns that will have still further implications on the storage technology used. So in talking about storage below, we are very much thinking in general terms.
While MongoDB will work well with SANs, internal storage works just fine. Often the best solution is simply whatever is most economic — i.e. commodity internal storage. The one caveat would be that if you are using conventional spinning disks (not SSDs), you may need a lot of them and/or fast drives to get to a decent random I/O capacity, as a single SATA drive might support only 100 random I/O’s per second. The flip side is that using local storage can avoid common problems with over subscribed SANs. Often times a SAN will have plenty of disk but not enough IO throughput. With local storage every time you add a shard to the cluster you are augmenting all your essential computing resources including disk and IO throughput.
For cases where the cost is acceptable, solid state disks (SSDs) are highly recommended. Even though SSDs are fast, RAM is still faster. Thus for the highest read performance possible, having enough RAM to contain the working set of data from the database is optimal. However, it is common to have a request rate that is easily met by the speed of random IO’s with SSDs, and SSD cost per byte is lower than RAM (and persistent too).
Let us consider the case where the economics or use case dictates just enough memory to contain the indexes and some subset of the working data set. A system with less RAM and SSDs will often outperform a system with more RAM and spinning disks. For example a system with SSD drives and 64GB RAM will often outperform a system with 128GB RAM and spinning disks. (Results will vary by use case of course.)
One helpful characteristic of SSDs is they can facilitate fast “preheat” of RAM on a hardware restart. On a restart a system’s RAM file system cache must be repopulated. On a box with 64GB RAM or more, this can take a considerable amount of time – for example six minutes at 100MB/sec, and much longer when the requests are random IO to spinning disks. More information on SSDs and MongoDB can be found here
A final consideration here is the usage of Fusion-IO which is yet another tier of performance above SSD. One way to help balance all these choices is to examine performance metrics on a per dollar basis where one assumes a sharded configuration that will allow one to incrementally add capacity as required. For some Fusion IO MongoDB use cases go here: Pairing MongoDB with Fusion IO Flash Memory Solutions
Specific Configurations
Here are some usage profiles, corresponding use cases, and plausible hardware scenarios.
- Low transaction rates, high query and read.
- Example application: Product catalog or personnel database.
- 2 quad core CPUs, 128GB memory, RAID 10 spinning disk.
- High ingest rate, low read query
- Example application: Auditing store
- 2 dual core CPUs, 32GB memory, RAID 10 spinning disk
- High ingest rate, low read query, regular aggregation
- Example application: User behavior analysis, system log management
- 2 hex-core CPUs, 64GB memory, SSD
- Balanced mixed workload, high transaction rate, high query, high read, occasional aggregation
- Example application: Social media applications, e-commerce,
- 2 hex-core CPUs, 128GB memory, SSD
State of the art NoSQL?
Posted by on May 8, 2012
Pizza and Databases
So I was eating dinner with Chris Biow, an old colleague of mine and the Federal CTO for MarkLogic, and we were having a stimulating conversation on database indexing theory. If you folks are worrying over our social life never fear, this topic was squeezed in between outrageous drinking anecdotes. During this conversation we moved on to the difficulties of using distributed hash based databases to support typical queries and access patterns of your normal operational data stores (topic of next blog entry). Some databases that fall into this category would be HBase, Cassandra, Riak, Redis, and Accumulo.
Chris asked a funny but excellent question. If you are starting from scratch now-a-days and writing your own NoSQL database why would you just reimplement BigTable with tweaks yet again? In particular he was thinking of Accumulo.
A Little History
As a background, Google began development of BigTable in 2004, started production usage of it around February 2005, and then published its public paper on the database in 2006. As we all know, the engineers over at Google are no dummies. It was created to allow for horizontally scaling data storage into the pedabytes. Access patterns ranged from massive batch jobs (Map/Reduce) to user oriented low latency data serving.
At this point other web oriented companies, who were grappling with the same problems, said “This sounds much better than the crazy Frankenbase solutions we have expensively been cooking up with RDBMSs.” Yes, thats a direct quote from web companies.
Although Google generously published a white paper on BigTable they weren’t ready to just give away a technical competitive advantage. At the end of the 2006 Powerset, a company who hoped to take a chunk of the web search market with superior natural language technology, began development of an open source clone called HBase. The first “working release” was part of Hadoop 0.15.0 in October 2007. Around the same time period we see the emergence of another database, Amazon Dynamo, influenced by Bigtable. While proprietary and unreleased outside of Amazon, they published a white paper in October 2007 and claimed usage to be “in the past year”. Before I put the reader to sleep with a long list of dates I’ll just add that we see a progression of other very similar databases such as Cassandra, Voldemort, Riak, Hypertable, and Accumulo.
Reinventing the Wheel
Back to Chris’s question, why re-implement Bigtable again and again? I’m sure in each instance it was felt that the existing implementations didn’t satisfy a given set of requirements. The most clear cut example of this is Accumulo which the NSA created so that they could have a Bigtable implementation with additional security features (primarily cell level security). If you are going through all the trouble and expense of creating a whole new technology one needs to think beyond fixing an implementation to solving a problem. This means not always following the assumptive standard approach. Google knew this 8 years ago when they abandoned the relational model to successfully create Bigtable. Sparse multi-dimensional distributed maps with hash indexing is so 2004!
References
- Early notes from a BigTable lecture
- Google’s Bigtable white paper, Bigtable: A Distributed Storage System for Structured Data.
- HBase History
- Powereset blog First Release of Hbase in Hadoop
- Dynamo white paper
Open Source vs Commerical
Posted by on March 26, 2012
When I was at my previous company, which was a commercial software vendor, I had a colleague tell me that he just didn’t understand open source software. I found myself defending the concept of open source software, the people who spend time on it, and the businesses built around them. It felt kind of weird since I was on the way to try and convince someone to spend beau coup bucks on our excellent commercial software. 6 months later I’m at 10gen the makers of the super awesome MongoDB. I don’t think I convinced him but I certainly convinced myself.
I’m not here to say that commercial software is bad. In many cases there isn’t a comparable open source alternative. In other cases there is a substantial difference in features that would lead the consumer to have a lower TCO with the commercial offering. For a long time I was successful in convincing people to use my very expensive commercial software because there was massive savings on TCO; there wasn’t commercial or open source competitors which came close for functionality.
If you are a government related reader and get board of my pontifications around the advantages of OSS and commercial, skip to the bottom.
Removing functionality from the discussion here here is a break down of advantages.
Open Source Software
Reduced risk of security holes and flaws in general
Rather than a modest number of individuals on a specific engineering team reviewing the code (hopefully) you have the eyes of the public examining, reviewing, finding flaws, and in many cases providing fixes. Availability of the code also means that organizations can use static code analysis tools like Coverity to get a report on possible flaws in the software. The Department of Homeland Security realized the value of this. They helped initiate the Scan Project along with Coverity to scan open source projects and publish the high level results as well as making the scan details available to the developers.
Low Barrier of Entry
Do you have a new project your starting and need to figure out of if a piece of software is what you need? With OSS one can download the software and working with a full set of features at no cost. If the software isn’t what you needed or you decide to go a different direction the only thing its costs you is the time you have put into its evaluation. The experience with commercial software can be quite the opposite. Some commercial software has evaluation versions but they are often crippled, or have a very limited evaluation period, or require frequent interaction with a sales person who is a gatekeeper to extending the period of time.
Agility
No doubt when evaluating software one takes into account system requirements to ensure they can be met. Requirements can change quickly and no sooner have you made a software decision than a new set of requirements can pop up. Lets suppose that the new requirements mean your require functionality not in the selected software. If you are using OSS you could make the necessary adjustments to the software yourself, pay someone to make the changes, request the community or a supporting company (the 10gens and Red Hats of the world) make it, or walk away from the software and chose something else that has the functionality you need. If you are using commercial software your only recourse is to request the vendor make the enhancements. There is no guarantee that they will do it. One certainly doesn’t want to walk away from a large investment. If a system is already fielded and in use then the effects of new requirements can be even more acute. In this situation, ripping software out and replacing it could very well not be an option.
Commercial Software
Neck to Strangle
One of the traditional benefits of commercial software is that there is an entity to which you can turn when something goes wrong. If there is a serious flaw in the software a reputable software company will make haste to try and fix it. This assumes that the software company agrees that its a serious flaw. Nevertheless, I think we can agree its nice to have a company whose fortune is tied to making customers happy.
Support
Commercial software is produced by companies and companies provide support. It typically works by paying the company some support money on top of the licensing costs. This give you the right to get help in tracking down problems or expediting bug fixes.
Focused Engineering Team
With commercial software produced by a company you typically have a core team of engineers whose sole job is to develop and maintain the software you are using. This typically means more efficiency in developing new functionality and quicker turn around on bug fixes.
Modern OSS
Things have greatly changed in the OSS world though. In the old days most of the OSS was written with contributions from a large number of developers with no intention of trying to make a business out of it. Now-a-days very few OSS projects don’t have a commercial entity whose bread and butter is providing paid support. In some cases, applications are built by companies in the same fashion as a commercial software vendors but are then made open source (like MongoDB). This give you the best of both worlds as you get the benefits of both open source and commercial software.
OSS in the Federal Government
Open Source Software is Commerical Software
huh? There are many misconceptions about using OSS in the Federal Government. The bottom line is that from the perspective of rules and regulations around the acquisition and use of software, OSS is no different then commercial software. This is because what people in industry consider to be open source software is actually just commercial software in the eyes of the Federal government. This wisdom was bestowed upon me by the folks over at MIL-OSS. There is lots of great content about the value of OSS at this site beyond how it relates to its usage in the government and military. To quote some of this content:
OSS Is Allowed and Preferred
As it relates to both Federal Government and Department of Defense (DoD) acquisitions, Open Source Software(OSS) is considered “commercial computer software” products. The United States Code (41 USC 403), Federal Acquisition Regulations (FAR 2.101, 12), and Defense Federal Acquisition Supplement (DFARS 212, 252) all concur in the classification of OSS as a commercial software product because OSS is commonly licensed to the general public for purposes not uniquely governmental and can be modified to meet various requirements. In many cases, OSS products can also be considered “commercial off-the-shelf items” (COTS), a specific subset of commercial items (41 USC 403). COTS items are ready to use and require little if any customization.
To ensure efficiency and reduce the potential for waste, the Federal Government has enacted legislation (10 USC 2377) directing its agencies exercise a preference for commercial and nondevelopmental items (NDI) “to the maximum extent practicable”. The law’s intent to prefer COTS and NDI products is echoed in both the FAR and the DFARS. As a commercial item, an OSS product that is found to viably meet an agency’s requirements must be considered alongside other commercial products being evaluated.
JSON vs XML, its an issue of access
Posted by on January 31, 2012
I have spent some time lately pondering JSON vs XML. For full disclosure, in my past I spent 6 years working for a company which makes an XML database. Hundreds of terabytes of XML and hundred’s of thousands of lines in XQuery/XPath its pretty safe to say that I’m no dummy when it comes to data modeling content and unstructured data in XML (although I am a dummy in many other subjects).
There are plenty of articles that contrast XML and JSON as format. One I like is http://bit.ly/vZqZgj
Of the various issues with JSON the main one that causes heartburn is the combination of no ordering and no redundant keys. The way to get around these issues is with an array like so
{ "content" :
{ "children :
[
"This is an ",
{"bold": "awesome"},
"book about ",
{"bold": "Manchester United"},
"."
]
}
}
Note that in this case we have ordering and mixed content to boot. So where is the heartburn? Well in actuality its not really JSON at all but its the access method. In the excellent IBM paper, Experiences with JSON and XML Transformations, they talk about the different mapping approaches and touch upon this. One of the main things they point out is that you can get XML-JSON-XML round-tripping if you sacrifice convenience with the JSON access patterns.
Unlike XML, which has XPath, JavaScript has only direct named child access and ordinal array access. So if I wanted to get the bold children something like content.children.bold[1] wouldn’t work. The equivalent in XPath, which would work in XML, would be content/children/bold. This is why the preferred JSON mode for mapping multiple children with the same name seems to be
{ "content" :
{ "bold": ["awesome", "Manchester United"]
"text": ["This is an ", "book about", "."]
}
}
Now content.bold[1] will work fine but we have lost the ordering. JSON was clearly designed more for data than content.
I’m certainly not the first person to realize that JSON access is the limitation and thats why libraries like JSONPath and JSONQuery were invented.
I care about this issues a lot because
- People are gravitating towards JSON as a preferred data exchange format
- I like the simplicity and compactness of JSON
- Many data standards in the Federal space (and other spaces as well) are specified in XML
- MongoDB is a document oriented database that stores JSON (well actually BSON)
More to follow when I catch up on my several week deficit of sleep!
MongoDB now powering Santa’s NON database
Posted by on December 25, 2011
We have a real humdinger for the first post on this new blog!
I have it on good authority from a contact at the North Pole that this year Santa has begun the use of a new gift distribution system based on the NoSQL database MongoDB. Larry K., lead Systems Elf on the system, told me that the previous system relied upon an unnamed relational database.
“It simply wasn’t scaling anymore”, says Larry of the previous system.
Santa currently has to track behavioral aspects of more than 550 million children across the globe in a system coined the NON (Naughty or Nice) database. Just imagine how many nose picking incidents there are in that dataset! The goal of the NON database is to bring more precision in determining what and how much children should receive from Santa in celebration of Christmas.
“Nick used to just wing it from memory. Now we accumulate around 1 trillion actions per year that are deemed either naughty or nice. We are talking close to 5 petabytes!”
Given MongoDBs geospatial capabilities, the elves have already begun plans to overhaul the enterprise location services which are used to determine delivery locations and routes for Santa.
With numerous years of coal in my stocking, this author certainly wishes they were using MongoDB when he was a kid.