A migration from DocumentDB to Graviton2 secures an immediate opportunity in cost reduction and performance improvement. In fact, Graviton2 instances are more performant and less expensive than x86 instances in general. In the case of DocumentDB, Graviton2 instances provide up to 30% performance improvement while being 5% cheaper than the current generation instances.
Amazon’s DocumentDB is a type of NoSQL database that facilitates inserting, querying, indexing and performing aggregations via JSON. Most importantly, DocumentDB can scale MongoDB-compatible databases while handling cluster management, backups and monitoring workloads. In short, DocumentDB operates MongoDB workloads while maintaining scalability and high durability.
Graviton2 is the successor of the Graviton processors and it is considered one of AWS’s best cost optimization and performance enhancements. Graviton2 use cases span a range of general purpose, scalable, and generally optimized instances (memory, storage, compute, and others).
Compared to their first-generation predecessors, Graviton2 chips are 7x more performant and have:
- 4x compute cores
- 2x larger caches
- 5x memory size
- 2x faster floating-point per core
This means that DocumentDB users can now achieve up to 30% better general performance with Amazon DocumentDB. You will only be able to migrate t4 and r6 Graviton2 instance types.
These optimizations make the Graviton2 instance a great option for database-related activities. Amazon Web Services is always pushing for performance optimizations where possible, and in this case, AWS ensured that DocumentDB Graviton2 is available in sizes ranging from medium to 16xlarge.
To understand how Graviton2 gives you improved cost optimization, let’s first go through the understanding of how DocumentDB is billed and priced.
DocumentDB is billed per-second with a 10-minute minimum billing period.
With DocumentDB, you generally pay for what you consume, and the consumption can be translated into the on-demand instance itself (/second), the I/Os when reading and writing (million I/Os), the database storage (GB/month) and the backup storage (GB/month).
With on-demand instances you have no long-term commitments or prepaid bills. The per-second bills are calculated in the following fashion: You start paying from the time the instance is launched until it is stopped or deleted. This is based on instance-hour consumption, essentially by adding the one-second increments with a fixed 10-minute minimum charge on the modifications on instances.
Since DocumentDB ensures high availability by spanning multiple Availability Zones, pricing includes the primary and replica instances. However, there will be a price for extra storage ($0.10 per GB\month) alongside $0.20 per million replicated write I/Os.
The lists below show the basic memory and vCPU prices for memory optimized and general purpose instances, price per extra storage, and price per replicated I\O.
|Memory Optimized Instances Current Generation||Memory||vCPU||Pricing|
|General Purpose Instances Current Generation||Memory||vCPU||Pricing|
|Storage Rate||$0.10 per GB-month|
|I/O Rate||$0.20 per 1 million requests|
How does Graviton2 contribute to the optimization of DocumentDB?
Graviton2 instances are generally 5% cheaper than their counterparts.
Comparing the cost of db.r6g.large which contributes a memory of 16GiB, 2 vCPU with db.r5.large which provides the same memory and core, there is a 5% discount with Graviton2 processors with a reduced cost of $0.26315 compared to the original $0.277.
The same comparison is valid for all memory and vCPUs count on memory optimized instances, where the price is 5% cheaper using Graviton2 processors.
When it comes to general purpose instances, Graviton2 yields a margin of 3% cost optimization given the same memory and core count.
Note that T4g medium instances run in unlimited mode, meaning that cost is further optimized above the expected costing optimization. When in unlimited mode, charging will happen of the average CPU utilization consumed within 24-hours beats the baseline of the instance itself, with the CPU Credits being priced at $0.09 per vCPU-hour. For further details on the pricing method of DocumentDB refer to Amazon DocumentDB (with MongoDB compatibility) pricing.
With that being said, it’s important to understand that AWS already provides built-in optimization opportunities in the form of features for DocumentDB, including:
- Per-second billing
- Pausing instances
- Single-instance durability
- Cheap backup
- Replicas (high durability and availability: paying for 1 and getting 6)
- Free encryption and monitoring
- Premium Support
- No-cost data transfer across AZs.
How to apply this fix
By following these simple steps, you can upgrade your existing Amazon DocumentDB instances to Graviton2 with a risk-free zero downtime process. Applications will continue to work as normal, and you will not have to port the application code.
- In the DocumentDB Console, select your cluster:
- Select an instance, go to the “Configuration” tab, and click on “Modify:”
- The “Apply Modifications” page appears. Note that DocumentDb instances can be t3, t4g, r4, r5 and r6g. The “g” instances are Graviton2 instances.
If this is the only modification you are making, select “Apply Immediately:”
Your cluster will remain available, but the specific instance may take a few minutes to modify:
- Wait until the instance modification is complete before modifying another instance:
For additional AWS cost optimization opportunities, check out CloudFix, an easy and automated way to keep up with AWS recommendations and best practices.