MongoDB Atlas
MongoDB Atlas is the DBaaS offering from MongoDB Inc. It allows you to provision a database on the cloud as a service, which can be used for your applications from anywhere. Atlas uses cloud infrastructures from different cloud vendors. You can choose the cloud vendor on which you want to deploy your database. Like any other managed service, you get the benefits of highly available secured environments with low or no maintenance needed.
MongoDB Atlas Benefits
Let us look at some of the benefits of MongoDB Atlas.
- Simple Setup: The database setup on Atlas is easy and can be done in just a few steps. Atlas runs a variety of automated tasks behind the scenes to set up your multi-node cluster.
- Guaranteed Availability: Atlas deploys at least three data nodes or servers per replica set. Each node is deployed in a separate availability zone (Amazon Web Services (AWS)), fault domains (Microsoft Azure), or zones (Google Cloud Platform (GCP)). This allows a highly available setup and continuous uptime in case of outages or routine updates.
- Global Presence: MongoDB Atlas is available across different regions in the AWS, GCP, and Microsoft Azure clouds. The support for different regions allows you to pick a region closer to you for low latency read and write.
- Optimal Performance: The founders of MongoDB manage Atlas, and they utilize their expertise and experience to keep the databases in Atlas running optimally. Also, single-click upgrades are available for upgrading to the latest versions of MongoDB.
- Highly Secured: Security best practices are implemented by default, such as a separate VPC (virtual private cloud), network encryption, access controls, and firewalls to restrict access.
- Automated Backups: You can configure automated backups with customizable schedules and data retention policies. Secure backups and restores are available for switching between different versions of your database.
Cloud Providers
MongoDB Atlas currently supports three cloud providers, namely AWS, GCP, and Microsoft Azure.
Availability Zones
Availability Zones (AZs) are a group of physical data centers within close proximity, equipped with computational, storage, or networking resources.
Regions
A region is a geographical area, for example, Sydney, Mumbai, London, and so on. A region generally consists of two or more AZs. The AZs are generally in different cities/towns away from each other, to provide fault tolerance in case of any natural disasters. Fault tolerance is the ability of a system to keep running when something goes wrong in one portion of the system. In terms of AZs, if one AZ goes down due to some reason, another AZ should still be able to serve the operations.
MongoDB Supported Regions and Availability Zones
MongoDB Atlas allows you to deploy your database in a multi-cloud global infrastructure from AWS, GCP, and Azure. It allows MongoDB to support a vast number of regions and AZs. Also, the number of supported regions and AZs keeps growing as cloud providers keep adding to them. Follow these links from the official MongoDB website about cloud providers' region support:
- AWS: https://docs.atlas.mongodb.com/reference/amazon-aws/#amazon-aws.
- GCP: https://docs.atlas.mongodb.com/reference/google-gcp/#google-gcp.
- Azure: https://docs.atlas.mongodb.com/reference/microsoft-azure/#microsoft-azure.
Atlas Tiers
To build a database cluster in MongoDB Atlas, you need to select a tier. A tier is a level of database power that you get from your cluster. When you provision your database in Atlas, you are given two parameters: RAM and storage. Depending on your selection of these parameters, an appropriate amount of database power is provisioned. The cost of your cluster is linked to the selection of RAM and storage; a higher selection means a higher cost and a lower selection means a lower cost.
M0 is the free tier available in MongoDB Atlas, which gives you shared RAM with storage of 512 MB. It is the tier that we will be using for our learning purposes. The free tier is not available in all regions, so if you do not find it in your region, select the closest free tier region. The proximity of your database determines the latency for your operations.
Selecting a tier requires an understanding of your database usage and how much you would like to spend. Under provisioned databases can exhaust your application's capacity at peak usage and can lead to application errors. Overprovisioned databases can help your application perform well but are more expensive. One of the advantages of using a cloud database is that you can always modify your cluster size as per your needs. But you still need to find what is the optimal capacity for your day-to-day database use. Determining the maximum number of concurrent connections is a critical decision factor that can help you choose the appropriate MongoDB Atlas tier for your use case. Let us look at the different tiers available:
MongoDB Atlas Pricing
Capacity planning is essential but estimating the cost of your database cluster is important too. We learned that an M0 cluster is free, with minimal resources, making it ideal for prototyping and learning purposes. For the paid cluster tiers, Atlas charges you on an hourly basis. The total cost is comprised of multiple factors, such as the type and number of servers. Let us look at an example to understand the cost estimation of an M30 type replica set (three servers) on Atlas.
Cluster Cost Estimation
Let us try to understand how to estimate the cost of your MongoDB Atlas cluster. Identify the cluster requirements as follows:
- Machine type: M30
- Number of servers: 3 (replica set)
- Running time: 24 hours a day
- Estimation time period: 1 month
Once we have identified our requirements, the estimated cost can be calculated as follows:
- Cost of running a single M30 server per hour: $0.54
- Number of hours a server will run: 24 (hours) x 30 (days) = 720
- Cost of a single server for a month: 720 x 0.54 = $388.8
- Cost of running the three-server cluster: 388.8 x 3 = $1166.4
So, the total cost should come down to $1166.4.
Note
Apart from the running cost of your cluster, you should consider the cost of additional services such as backups, data transfer, and support contracts.
Let us implement our learning in an example scenario through the following exercise.
Exercise 1.01: Setting Up a MongoDB Atlas Account
MongoDB Atlas offers you free registration to set up a free cluster. In this exercise, you will create an account by executing the following steps:
- Go to https://www.mongodb.com and click
Start free
. The following window appears: - You can sign up using your Google account or by providing your details manually as can be seen from the following screen. Provide your usage,
Your Work Email
,First Name
,Last Name
, andPassword
details in the respective fields, select the checkbox to agree to the terms of service and clickGet started free
.
The following window appears in which you can enter your organization and project details:
Next, you should see the following page, which means your account has been successfully created:
In this exercise, you successfully created your MongoDB account.