Migrating Your Self-Managed MongoDB Databases to AWS with Amazon DocumentDB

Set up, secure, and scale MongoDB-compatible databases in the cloud without worrying about management

What is MongoDB?

MongoDB is a NoSQL database that provides support for JSON-styled, document-oriented storage systems. The flexible document model enables you to store semi-structured data, and it provides rich and intuitive APIs for query, full indexing support, aggregations, sharding, and replication.

What is Amazon DocumentDB (with MongoDB compatibility)?

Amazon DocumentDB (with MongoDB compatibility) is a fast, scalable, highly available, and fully managed document database service that supports MongoDB workloads. Amazon DocumentDB is a cloud-native non-relational database service architected from the ground-up to give you the performance, scalability, and availability you need when operating mission-critical MongoDB workloads at scale.

Learn how to perform a live migration from MongoDB to Amazon DocumentDB

Why should you migrate your self-managed MongoDB databases to Amazon DocumentDB (with MongoDB compatibility)?

Self-managing MongoDB databases is difficult, time-consuming, and expensive. With Amazon DocumentDB, you can set up, secure, and scale MongoDB-compatible databases in the cloud without worrying about manually setting up and securing database clusters, running cluster management software, configuring backups, configuring high availability, configuring durability, and monitoring production workloads. Amazon DocumentDB is MongoDB-compatible, allowing you to use your existing MongoDB drivers and tools.

As a fully-managed database service, Amazon DocumentDB removes the undifferentiated heavy lifting of operating a database so that you can focus your time on delivering value for your customers. Amazon DocumentDB is secure by default with TLS, encryption-at-rest, and VPC support. Backup is enabled by default and all clusters have one day of point-in-time restore capability provided at no cost. Amazon DocumentDB continuously backs up your data to Amazon S3, enabling point-in-time recovery (up to the second for the last 35 days). Amazon DocumentDB is durable by default and replicates your data six ways across three availability zones. The Amazon DocumentDB architecture separates storage and compute, allowing storage and compute to scale independently, and enabling you to easily scale read capacity to millions of requests per second in minutes, regardless of your data size. Amazon DocumentDB uses a distributed, fault-tolerant, self-healing storage system that auto-scales from 10 GB up to 64 TB per database cluster.

Learn about additional benefits on the Amazon DocumentDB product page.

How can you migrate your MongoDB databases to Amazon DocumentDB (with MongoDB compatibility)?

Two common tools for migrating from MongoDB to Amazon DocumentDB are the AWS Database Migration Service (AWS DMS) and command line utilities like mongodump and mongorestore. As a best practice, and for either of these options, we recommend that you first create indexes in Amazon DocumentDB before beginning your migration as it can reduce the overall time and increase the speed of the migration. To do this, you can use the Amazon DocumentDB Index Tool.

There are three primary approaches for migrating your data to Amazon DocumentDB: Offline, Online, and Hybrid.

  • Offline Migration Approach
  • Offline Migration Approach

    The offline approach uses the mongodump and mongorestore tools to migrate your data from your source MongoDB deployment to your Amazon DocumentDB cluster. The offline method is the simplest migration approach, but it incurs the most downtime for your cluster. This approach is a good choice for proofs of concepts, development and test workloads, and production workloads for which downtime is not of primary concern.

  • Online Migration Approach
  • Online Migration Approach

    The online approach uses AWS Database Migration Service (AWS DMS). It performs a full load of data from your source MongoDB deployment to your Amazon DocumentDB cluster and then switches to change data capture (CDC) mode to replicate changes. The online approach minimizes downtime for your cluster, because DMS continually reads from the source MongoDB oplog and applies those changes in near-real time on the source Amazon DocumentDB cluster. While it is the slowest of the three methods, it is the best option if you want to minimize downtime and your source dataset is small (less than 1 TB). If your dataset is larger than 1 TB, you should use the hybrid or offline approach to take advantage of parallelization and the speed that you can achieve with mongorestore.

  • Hybrid Migration Approach
  • Hybrid Migration Approach

    The hybrid approach uses the mongodump and mongorestore tools to migrate your data from your source MongoDB deployment to your Amazon DocumentDB cluster. It then uses AWS Database Migration Service (DMS) in change data capture (CDC) mode to replicate changes. The hybrid approach combines the speed of the offline approach and the ability to minimize downtime with the online approach, but it is the most complex of the three approaches. The hybrid method is the best option if you want to minimize downtime and your source dataset is greater than 1 TB.

Customers migrating from MongoDB to Amazon DocumentDB

“At Habby, we use Amazon DocumentDB to store, query, and analyze both game player data and game operational data as well as data for promotional activities. Amazon DocumentDB is a natural and convenient choice for Habby as all of our game data is JSON and Amazon DocumentDB makes it easy to read and write that JSON data to the database. We chose Amazon DocumentDB because of the ease-of-management and its compatibility with MongoDB. We had initially planned to self-manage MongoDB on EC2 but found through testing that it was not convenient and required more work than we were willing to invest. With Amazon DocumentDB, our development team can scale, iterate, and upgrade games quickly, the marketing team can carry out high pertinence promotion activities, and our customer service team can troubleshoot problems from game players efficiently.”

Shuxiang Zhao, Chief Technology Officer - HABBY PTE.LTD.

"Adopting Amazon DocumentDB is a game-changer because we offload management, security, and backup of our MongoDB databases to AWS. With Amazon DocumentDB, we can add or scale instances in minutes, regardless of data size. Further, we get automatic backups and point-in-time restore capabilities, which far exceed other managed DB services at less cost. If you multiply those productivity gains across the organization, it’s huge. By moving much of the operational overhead to AWS, and eliminating the need to manage our MongoDB databases, Amazon DocumentDB frees up funds for innovation.“

Dylan Stamat, CEO - Iron.io

“Woot! replaced our aging, self-managed, and operational nightmare product catalog database running on MongoDB 2.2 with Amazon DocumentDB. With only minimal changes, we were able to able to upgrade our driver and complete our full production migration in three weeks. In doing so, we cut our infrastructure costs for the database by 82%, including licensing costs. With Amazon DocumentDB, we’ve seen improved latency and scalability, and now have a safer backup solution and can perform point-in-time recovery to any second during a 35-day window. With AWS service integrations and improved scaling, we’re now able to stand up new features faster which enables us to innovate faster on behalf of our customers. We are thrilled to be out of the business of managing our own MongoDB database.”

Sam Giagtzoglou, Software Development Engineer – Woot!

“Here at Monkey Exchange we use Amazon DocumentDB to store hundreds of thousands of push notifications and webhooks events every day for customer invoices exchange, digital signatures, auction results, and more. In the beginning, we used a self-hosted MongoDB cluster, which consumed a lot of time from our infrastructure team, and now we saved at least 30 hours per month and the engineers can be focus on our business. When we decided to migrate to Amazon DocumentDB, the process was simple and in less than 4 hours we migrated all our data and changed the applications to the new DocumentDB cluster. The compatibility with the MongoDB API is awesome and makes work easier. Today we can take advantage of all the benefits and guarantees of an AWS managed service.”

Felipe Adorno, CTO - Monkey Exchange

Getting started

Learn more

Learn more about Amazon DocumentDB on the product overview page.

Read the overview 
Read the migration guide

Check out the migration guide in the Amazon DocumentDB documentation.

Check out the guide 
Try the tutorial

Get started with the tutorial, "Migrating from MongoDB to Amazon DocumentDB"

Get started