Scaling MongoDB

Book description

Create a MongoDB cluster that will to grow to meet the needs of your application. With this short and concise book, you'll get guidelines for setting up and using clusters to store a large volume of data, and learn how to access the data efficiently. In the process, you'll understand how to make your application work with a distributed database system.

Scaling MongoDB will help you:

  • Set up a MongoDB cluster through sharding
  • Work with a cluster to query and update data
  • Operate, monitor, and backup your cluster
  • Plan your application to deal with outages

By following the advice in this book, you'll be well on your way to building and running an efficient, predictable distributed system using MongoDB.

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. Safari® Books Online
    4. How to Contact Us
  2. 1. Welcome to Distributed Computing!
    1. What Is Sharding?
  3. 2. Understanding Sharding
    1. Splitting Up Data
      1. Distributing Data
        1. One range per shard
        2. Multi-range shards
      2. How Chunks Are Created
        1. Example
        2. Sharding collections
    2. Balancing
      1. The Psychopathology of Everyday Balancing
        1. On changing chunk size
    3. mongos
    4. The Config Servers
    5. The Anatomy of a Cluster
  4. 3. Setting Up a Cluster
    1. Choosing a Shard Key
      1. Low-Cardinality Shard Key
        1. Keys that this rule applies to
        2. Exceptions to the rule
        3. Data center awareness
      2. Ascending Shard Key
        1. Keys that this rule applies to
        2. Exceptions to the rule
      3. Random Shard Key
      4. Good Shard Keys
        1. Coarsely ascending key + search key
        2. FAQ
        3. The general case
        4. What shard key should I use?
    2. Sharding a New Collection
      1. Quick Start
      2. Config Servers
      3. mongos
      4. Shards
        1. Limiting shard size
      5. Databases and Collections
    3. Sharding an Existing Collection
      1. Preparing Your Collection for Sharding
      2. Running shardcollection
        1. For Large Data Sets
    4. Adding and Removing Capacity
      1. Removing Shards
      2. Changing Servers in a Shard
  5. 4. Working With a Cluster
    1. Querying
    2. “Why Am I Getting This?”
      1. Counting
      2. Unique Indexes
      3. Updating
    3. MapReduce
      1. Temporary Collections
  6. 5. Administration
    1. Using the Shell
      1. Getting a Summary
      2. The config Collections
      3. “I Want to Do X, Who Do I Connect To?”
    2. Monitoring
      1. mongostat
      2. The Web Admin Interface
    3. Backups
      1. Config Server Backups
    4. Suggestions on Architecture
      1. Create an Emergency Site
      2. Create a Moat
    5. What to Do When Things Go Wrong
      1. A Shard Goes Down
      2. Most of a Shard Is Down
      3. Config Servers Going Down
      4. Mongos Processes Going Down
      5. Other Considerations
  7. 6. Further Reading
  8. About the Author
  9. Copyright

Product information

  • Title: Scaling MongoDB
  • Author(s): Kristina Chodorow
  • Release date: February 2011
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449303211