AWS Made Easy
Search
Close this search box.

Optimize AWS DocumentDB Cost and Performance with AWS Graviton2

Migrate your AWS DocumentDB instances to AWS Graviton2 for better performance and cost savings with no risks

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). 

Performance optimization

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. 

Cost optimization

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 GenerationMemoryvCPUPricing
db.r6g.large16 GiB2$0.26315
db.r6g.xlarge32 GiB4$0.5263
db.r6g.2xlarge64 GiB8$1.0526
db.r6g.4xlarge128 GiB16$2.1052
db.r6g.8xlarge256 GiB32$4.20964
db.r6g.12xlarge384 GiB48$6.3156
db.r6g.16xlarge512 GiB64$8.41928
db.r5.large16 GiB2$0.277
db.r5.xlarge32 GiB4$0.554
db.r5.2xlarge64 GiB8$1.108
db.r5.4xlarge128 GiB16$2.216
db.r5.8xlarge256 GiB32$4.4312
db.r5.12xlarge384 GiB48$6.648
db.r5.16xlarge512 GiB64$8.8624
db.r5.24xlarge768 GiB96$13.296
db.r4.large15.25 GiB2$0.277
db.r4.xlarge30.5 GiB4$0.554
db.r4.2xlarge61 GiB8$1.108
db.r4.4xlarge122 GiB16$2.216
db.r4.8xlarge244 GiB32$4.432
db.r4.16xlarge488 GiB64$8.864
General Purpose Instances Current GenerationMemoryvCPUPricing
db.t4g.medium4 GiB2$0.07566
db.t3.medium4 GiB2$0.078
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
  • Auto-scaling
  • 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.

Steps:

  1. In the DocumentDB Console, select your cluster:
    AWS DocumentDB
  2. Select an instance, go to the “Configuration” tab, and click on “Modify:”
  3. 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:
  4. 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.

Kevin Duconge

Email
Twitter
Facebook
LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *