How to Run MongoDB on AWS

MongoDB can be installed and self-managed on-premise, in a cloud, or used, through MongoDB Atlas, in the database-as-a-service mode in all three major public clouds (AWS, Microsoft Azure, Google Cloud Platform).

This article will explain the two options for running MongoDB on AWS, so you can determine which is best to meet your needs.

Two Main Ways to Use MongoDB on AWS

There are two ways to run MongoDB on AWS:

  1. Use MongoDB Atlas, a fully managed, database-as-a-service (DBaaS) platform managed and administered by MongoDB

  2. Install and self-manage MongoDB yourself using the community or enterprise edition

The following sections explain the basics of how to get started, answer common questions, and present the pros and cons of each choice.

Using MongoDB Atlas on AWS

The fastest way to get started building with MongoDB on AWS is to use MongoDB Atlas, MongoDB’s database-as-a-service offering.

In some clouds, a virtual machine is called an instance. MongoDB Atlas uses the word cluster to refer to a database deployed by a user.

MongoDB Atlas is a fully managed version of MongoDB in the cloud. This means that developers and operations teams don't have to spend their time on manual database administration work. Developers can use it without having to worry about time-consuming details.

Further, MongoDB Atlas is not only a productized version of MongoDB running on a cloud platform, but it also offers a much larger set of services and capabilities that are all integrated, operated, and maintained by MongoDB engineers and operational staff.

MongoDB Atlas provides a quick way to get started (using the M0 cluster that is free forever), but also provides Atlas Search, Global Replication, multi-cloud support, continuous backup with snapshot support, data encryption, charts, Realm for building mobile applications, and a wide range of features needed by modern applications.

So, to understand whether MongoDB Atlas is right for you, we will explain the basics as well as the layers of capabilities that have been added to MongoDB Atlas so you can see which ones are relevant to your needs.

Benefits of the Database-as-a-Service Model

Self-Managed Model

In the self-managed model, to run a database you must manage and maintain administrative tasks yourself, which often involves investing a lot of time and resources.

In the self-managed model, to run a database you must:

  • Obtain access to a physical or virtual server to run the software
  • Make sure the operating system is working properly.
  • Install the database.
  • Configure the database to perform optimally.

Then you can get started on programming.

Using the self-managed database, will then require:

  • Back up the database.
  • Maintain the hardware as needed.
  • Update the operating system and database software with patches and upgrades as needed.
  • Solve operational problems.

In the DBaaS model, the vendor can take care of these repetitive, mundane tasks.

Database-as-a-Service (Fully Managed) Model

The DBaaS model transfers responsibility from the users of the database to the company that runs the service.

The user of a DBaaS will only have to handle:

  • Configuring the database to meet the needs of your particular application.
  • Loading data into the database.
  • Writing the application that will use the database.

The subscription fees for a DBaaS pay for your usage and for all the tasks related to running and administering the database.

The vendor performs these services at scale (and of course knows the database inside and out) so the vendor usually can do it all far cheaper than it would cost most companies to do them by themselves.

The economics and convenience of the DBaaS model have made it a popular choice among developers, who want to focus on coding and not on the details of running a database.

In the self-managed model, to run a database you must:

  • Obtain access to a physical or virtual server to run the software
  • Make sure the operating system is working properly.
  • Install the database.
  • Configure the database to perform optimally.

Then you can get started on programming.

Using the self-managed database, will then require:

  • Back up the database.
  • Maintain the hardware as needed.
  • Update the operating system and database software with patches and upgrades as needed.
  • Solve operational problems.

In the DBaaS model, the vendor can take care of these repetitive, mundane tasks.

How to Get Started with MongoDB Atlas on AWS: Choosing a Cluster

M0 Free Tier or M2/M5 Clusters

If you want to quickly get started as an individual or a team, MongoDB Atlas starter clusters are the way to go.

  • The M0 clusters (Free Tier): Starter clusters for teams learning MongoDB or developing small applications. This type of cluster is free for anyone to use.

  • The M2 and M5 clusters: Shared clusters for applications that need more storage capacity (2 GB and 5GB respectively).

Higher Performance Dedicated Clusters

For applications that need even higher performance, Atlas is available in dedicated MongoDB clusters. These clusters have increasing amounts of storage, memory, and CPU power:

  • The M10 and M20 are dedicated clusters for low traffic applications.

  • The M30 through M700 tiers are dedicated clusters for high traffic applications and large datasets.

The Cluster Tier page provides a summary of all cluster types for MongoDB Atlas, including pricing.

The Create a New Cluster page provides step by step instructions.

Additional MongoDB Atlas Features

Advanced Functions of MongoDB Atlas

While the MongoDB database that powers MongoDB Atlas is the same database that is at the foundation of MongoDB Community Edition and MongoDB Enterprise Server, new advanced capabilities have been added, including:

  • MongoDB Atlas Search: The Lucene full-text search engine has been integrated into Atlas to provide rich search capabilities.

  • MongoDB Charts is a built-in tool to create and share visualizations of your MongoDB data.

  • Encryption at Rest Using Customer Key Management: All data in MongoDB Atlas is encrypted. With Encryption at Rest Using Customer Key Management users can configure an additional layer of encryption on their data using their Atlas-compatible customer key management provider with the MongoDB encrypted storage engine.

  • The Data Explorer is Atlas’s built-in tool to view and interact with your data, supporting the ability to manage databases, collections, documents, indexes, and other functions.

  • Within a public cloud, MongoDB Atlas supports Cross Region Replication which allows a database to have active replicas in data centers in multiple geographies, increasing reliability in the event of catastrophic events or other outages.

    Global Clusters support low-latency reads and writes by storing data at the location nearest to its use. For example, data created on the East Coast of the U.S. may be stored in a data center in Virginia while data created on the West Coast may be stored in California.

Platform Extensions of MongoDB Atlas

Because MongoDB Atlas is a cloud database, it can be used as a platform for new types of development and data management techniques:

  • MongoDB Stitch is a serverless platform that enables developers to quickly build applications without having to set up server infrastructure. Stitch is built on top of MongoDB Atlas, automatically integrating the connection to your database.

  • MongoDB Atlas Triggers allow you to execute server-side logic in response to database events or according to a schedule. Atlas provides two kinds of triggers: database and scheduled triggers.

  • MongoDB Atlas Data Lake (in beta) enables you to query data stored in your AWS S3 buckets using the mongo shell, MongoDB Compass, or any MongoDB driver.

Operational Features of MongoDB Atlas

MongoDB takes advantage of the properties of public clouds to increase automation and reliability:

  • For M10 clusters and above, MongoDB Atlas offers Cluster Autoscaling, automatically scaling a cluster’s tier, storage capacity, or both in response to cluster usage. Cluster auto-scaling removes the need to write scripts or use consulting services to make scaling decisions. To control costs, you can specify a range of cluster tiers to which your cluster can automatically scale.

  • MongoDB Atlas Live Migration allows an existing MongoDB database to be migrated and synchronized to a MongoDB Atlas version of the database. This Guide to MongoDB Live Migration explains the steps for migrating a database installed on AWS to MongoDB Atlas.

  • The Real Time Performance Panel (RTPP), available for M10 and larger clusters, monitors and displays current network traffic, database operations on the machines hosting MongoDB in your clusters, and hardware statistics about the hosts. You use RTPP to visually identify relevant database operations and evaluate metrics like query execution times and the ratio of documents scanned to documents returned. You can also monitor network load and throughput, and discover potential replication lag on secondary members of replica sets.

  • MongoDB Atlas provides methods to back up and restore cluster data, including snapshots that take advantage of cloud provider capabilities as well as point-in-time recovery.

  • MongoDB Atlas has advanced security controls with a full range of features including robust database auditing, integration with Active Directory and LDAP, and the ability to encrypt data using your own key.

Running a Self-managed Version of MongoDB on AWS

While MongoDB Atlas streamlines many mundane tasks of database management, there is an option of manually setting up, and installing a MongoDB environment on AWS.

Installing any software on an operating system requires advanced knowledge of both the operating system and the software itself.

Users are encouraged to try MongoDB Atlas' free tier, available on AWS, but there are some cases where running a self-managed version for an existing cloud database or application may make the most sense.

Some common scenarios are:

  • Developers or companies that are currently set up to run installed, self-managed software and all of the operational tools are oriented to running in that mode.

  • If an application running on an earlier version of MongoDB is heavily customized or deeply integrated with other tools. On the other hand, it’s also worth considering a live migration.

  • Installing and running a database in self-managed mode temporarily helps deepen the understanding of how the database works and what parts of the operating system support it. Keep in mind, you'd want to consider migrating to MongoDB Atlas before your application grows to the point that it becomes more difficult to migrate over. And again, you can easily get started with our free tier of MongoDB Atlas, and deploy a cluster within a few clicks.

Managing a MongoDB Cluster on AWS: Key Responsibilities

Self-Managing MongoDB

Once installed on AWS, both the AWS environment and the MongoDB database must be monitored and adjusted as needed.

The team responsible for the MongoDB cluster must:

  • Configure AWS infrastructure and MongoDB to best fit the needs of the application.
  • Monitor the operation of the self-managed MongoDB cluster and make adjustments as needed to resolve problems.
  • Apply software upgrades to MongoDB as needed.
  • Arrange for backups and any disaster recovery procedures.
  • Configure the security of the underlying AWS infrastructure.

The team responsible for the MongoDB cluster must:

  • Configure AWS infrastructure and MongoDB to best fit the needs of the application.
  • Monitor the operation of the self-managed MongoDB cluster and make adjustments as needed to resolve problems.
  • Apply software upgrades to MongoDB as needed.
  • Arrange for backups and any disaster recovery procedures.
  • Configure the security of the underlying AWS infrastructure.

MongoDB Cloud Manager

Many of the tasks of running one or more MongoDB clusters on AWS can be streamlined and automated using the MongoDB Cloud Manager, which helps:

  • Visualize the health of your MongoDB clusters

  • Monitor your MongoDB deployments

  • Alert you to any issues

  • Manage cloud backups, along with point-in-time recovery

  • Automate deployment and growth in line with your defined best practices

AWS itself has a variety of operational tools and consoles that also help manage the infrastructure needed to support MongoDB.

What is the Best Choice for Running MongoDB on AWS?

Here are a few scenarios to consider: - If you are just getting started and haven’t done anything with MongoDB, the MongoDB Atlas M0 starter cluster is the fastest way to create a database and start coding.

  • If you are planning on adopting MongoDB as a platform and are new to AWS, MongoDB Atlas is a quicker way to get started.

  • If you are building a modern application, MongoDB Atlas provides a lot of advanced capabilities and integrations that make your applications much more powerful and easier to use without additional work from you.

  • If you have an existing self-managed version of MongoDB running on-premise that you want to move to AWS, you must weigh the benefits of running it in the same familiar way on AWS against making whatever changes in coding and operations may be required to use MongoDB Atlas.

  • The issue with such a lift-and-shift approach is that you may be replicating the complexity of your on-premise deployment in the cloud. It’s worth weighing this against the benefits of a live migration

  • If your team is already a master of MongoDB self-managed on AWS, then the costs and time taken to switch to MongoDB Atlas should be weighed against the savings in time achieved (and capabilities gained) by using MongoDB Atlas.

    All of this said, the really important thing is to know what you want to do now and in the future. The more precise that picture is, the easier it will be to make the right choice.

Ready to get started?

Launch a new cluster on AWS for free with MongoDB Atlas, the fully-managed, database-as-a-service.