Database Reference
In-Depth Information
W EB APPLICATIONS
MongoDB is well suited as a primary data store for web applications. Even a simple
web application will require numerous data models for managing users, sessions, app-
specific data, uploads, and permissions, to say nothing of the overarching domain.
Just as this aligns well with the tabular approach provided by relational databases, so
too does it benefit from MongoDB's collection and document model. And because
documents can represent rich data structures, the number of collections needed will
usually be less than the number of tables required to model the same data using a
fully normalized relational model. In addition, dynamic queries and secondary
indexes allow for the easy implementation of most queries familiar to SQL developers.
Finally, as a web application grows, MongoDB provides a clear path for scale.
In production, MongoDB has proven capable of managing all aspects of an app,
from the primary data domain to add-ons such as logging and real-time analytics. This
is the case with The Business Insider ( TBE ) , which has used MongoDB as its primary data
store since January 2008. TBE is a news site, although it gets substantial traffic, serving
more than a million unique page views per day. What's interesting in this case is that
in addition to handling the site's main content (posts, comments, users, and so on),
MongoDB also processes and stores real-time analytics data. These analytics are used
by TBE to generate dynamic heat maps indicating click-through rates for the various
news stories. The site doesn't host enough data to warrant sharding yet, but it does use
replica sets to ensure automatic failover in the event of an outage.
A GILE DEVELOPMENT
Regardless of what you may think about the agile development movement, it's hard to
deny the desirability of building an application quickly. A number of development
teams, including those from Shutterfly and The New York Times, have chosen
MongoDB in part because they can develop applications much more quickly on it than
on relational databases. One obvious reason for this is that MongoDB has no fixed
schema, so all the time spent committing, communicating, and applying schema
changes is saved.
In addition, less time need be spent shoehorning the relational representation of
data into an object-oriented data model or dealing with the vagaries, and optimizing
the SQL produced by, an ORM . Thus, MongoDB often complements projects with
shorter development cycles and agile, mid-sized teams.
A NALYTICS AND LOGGING
I alluded earlier to the idea that MongoDB works well for analytics and logging, and
the number of application using MongoDB for these is growing fast. Often, a well-
established company will begin its forays into the MongoDB world with special apps
dedicated to analytics. Some of these companies include GitHub, Disqus, Justin.tv,
and Gilt Groupe, among others.
MongoDB's relevance to analytics derives from its speed and from two key features:
targeted atomic updates and capped collections. Atomic updates let clients efficiently
increment counters and push values onto arrays. Capped collections, often useful for
logging, feature fixed allocation, which lets them age out automatically. Storing
Search WWH ::




Custom Search