AWS recently launched Amazon DocumentDB supporting MongoDB 3.6 API feature set. This can be a viable alternative to running self managed MongoDB in AWS. This service provides features like multi az backups, read replicas, etc. that can help users run world class, secure and high availability systems without requiring changes to the applications already working with MongoDB.
Setting up a DocumentDB cluster
Setting up a new cluster is pretty straight forward
- Navigate to Amazon DocumentDB from the services section in console
- Click on Launch Amazon DcoumentDB, which will take you to the next screen to configure the cluster
- Here, you can select the class of instance you would want in your cluster (one of the r4 instances)
- Number of instance in a cluster (upto 15 replicas for read). This can help you improve the reads if your application is read heavy
The primary instance and read replicas are priced as on demand. To discuss the monthly pricing, we will consider a small sized application that has 1,000 daily active users, making about 100 requests each. That is 100,000 requests daily and a 30 day month, number of monthly requests 3,000,0000. Assuming 100,000 total users of the application and 100kB stored per user, total storage is at approximately 100 GB
For this use case, picking a 1 instance cluster may be enough. Though, I would recommend pick more than 1 for have higher uptime. When 1 instance goes down, it may take more time to get it back up compared to when there is another instance which can be promoted to be the primary.
Price for 1 instance cluster - $199.44/mo and for 2 instance cluster $398.88 /month
|Memory Optimized Instances Current Generation||Pricing (hourly)||Pricing (monthly)|
Storage and IO
Storage consumed by the cluster is billed in per GB-month increments at $0.10 per GB-month and IOs consumed are billed in per million request increments at $0.20 per 1 million requests.
Which puts our application at 100 Gb X $0.10/GB-month =
$10 /month for storage and $0.20 X 3M =
$0.6 / Month for IO
The backups are free for up to 100% of your total Amazon DocumentDB cluster storage for a region, after that its $0.021 per GB-month. Which is great because the backup should be smaller in size than this limit. So, for our example, the backup cost would be
The Data transfers between Amazon DocumentDB and Amazon EC2 Instances in the same Availability Zone is free and so is the transfers between Availability Zones for replication of Multi-AZ deployments. Which puts the cost of any application using EC2 instances at $0.00 for data transfers.
The Data transfer cost from the internet is free and to the internet is also free till 1 Gb, and has tiered costing after that. Transfers to CloudFront is free and to all regions its $0.02 per GB. For the Amazon DocumentDB instances inside VPC, if EC2 instance and DocumentDB is in different AZ the EC2 Regional Data Transfer charges apply on both sides of transfer.
For our example, I am assuming that the application runs on EC2 instances that puts us at $0 for data transfer costs.
The total monthly cost comes out to be: 1 instance cluster - $199.44 + $10 + $0.6 + $0 + $0 = $210.04 2 instance cluster - $388.88 + $10 + $0.6 + $0 + $0 = $399.48
The majority of the cost of using the service comes from the instances. So, if your application is already using MongoDB on r4s in AWS it might be worth it to take a look at this offering and take advantage of the features like multi az replicas, automated promotions in failures, backups, etc.
- A full list of supported MongoDB features - https://docs.aws.amazon.com/documentdb/latest/developerguide/mongo-apis.html
- Pricing - https://aws.amazon.com/documentdb/pricing/
- AWS Developer Documentation - https://docs.aws.amazon.com/documentdb/latest/developerguide/getting-started.html