Kennisbank

DynamoDB On Demand Capacity Mode

Amazon DynamoDB is a fully managed, highly available NoSQL database service designed to provide low-latency data access for a variety of applications. One of the key features that makes DynamoDB so powerful is its On Demand Capacity Mode, which offers flexible scalability and cost-efficiency by automatically adjusting throughput capacity based on your application's needs.

This knowledge base will explore everything you need to know about DynamoDB On-Demand Capacity Mode, including how it works, when to use it, its benefits, and best practices.

Overview of DynamoDB On Demand Capacity Mode

DynamoDB On-Demand Capacity Mode is a pricing model for Amazon DynamoDB that automatically allocates read and write capacity to your tables based on real-time traffic patterns. Unlike Provisioned Capacity Mode, where you manually define the read and write capacity units (RCUs and WCUs), On-Demand Mode dynamically scales up or down to meet your application's requirements.

This mode eliminates the need to manually predict or manage throughput capacity, making it ideal for unpredictable workloads or new applications with unknown traffic patterns.

How DynamoDB On Demand Capacity Mode Works

In DynamoDB On-Demand Capacity Mode, the service automatically scales capacity to accommodate the request traffic. DynamoDB continuously monitors the number of read and write requests and adjusts resources in real-time. This automatic scaling ensures that your application remains performant without the need for manual intervention.

Key operational aspects of On-Demand Mode:

  • Auto Scaling: DynamoDB seamlessly allocates capacity based on the workload's current requirements.
  • No Provisioning Required: You do not have to set read or write capacity units in advance.
  • Pay per Request: You are charged only for the read and write requests your application performs, removing the need for capacity planning.
  • Instantaneous Scaling: The capacity instantly scales based on demand, ensuring low-latency performance even during traffic spikes.

Key Features and Benefits

DynamoDB On-Demand Capacity Mode provides several powerful features and advantages:

Automatic Scaling

This mode automatically adjusts the database’s throughput capacity in response to application demand, making it perfect for applications with sudden and unpredictable traffic changes.

Simplicity

On-Demand Mode removes the need to configure capacity settings manually. It is ideal for teams that want to focus on building applications without worrying about performance tuning.

Pay as You Go Pricing

With On-Demand Mode, you are billed only for the resources you actually use. This pricing model reduces costs for applications with infrequent or unpredictable workloads.

Elastic Performance

DynamoDB instantly allocates additional capacity to handle sudden workload spikes, ensuring consistent low-latency performance without downtime or throttling.

No Throttling

One of the biggest advantages of On-Demand Mode is that it mitigates the risk of throttling during periods of high demand, ensuring your application remains available and responsive.

Optimized for New Applications

When launching a new application or feature where traffic patterns are unknown, On-Demand Mode provides an easy way to ensure scalability without needing precise capacity predictions.

Difference Between On Demand and Provisioned Modes

To understand when to use DynamoDB On-Demand Mode, it's essential to compare it with DynamoDB's Provisioned Capacity Mode.

Feature On Demand Capacity Mode Provisioned Capacity Mode
Scaling Automatic, based on real-time traffic Manual scaling, or auto-scaling with predefined rules
Cost Model Pay-per-request Pay for reserved throughput capacity (RCUs and WCUs)
Use Case Unpredictable or variable workloads Predictable and stable workloads
Throttling Rare, only at extremely high traffic levels Can occur if capacity exceeds provisioned units
Best For New applications or those with fluctuating demand Applications with steady, predictable workloads

In essence, On-Demand Mode is ideal for workloads that have unpredictable traffic patterns or spikes, whereas Provisioned Mode is more suitable for predictable workloads where capacity usage is known ahead of time.

When to Use DynamoDB On Demand Mode

DynamoDB On-Demand Mode is beneficial in specific scenarios where workload patterns are hard to predict. Here are a few situations when On-Demand Mode might be the best option:

New Applications

When launching a new application or feature, estimating traffic patterns accurately can be challenging. On-Demand Mode is a great fit for such cases as it allows your application to scale automatically without upfront capacity planning.

Unpredictable or Variable Workloads

If your application's traffic spikes or drops unexpectedly, On-Demand Mode ensures that your database scales to meet demand without manual intervention. For example, e-commerce platforms during flash sales or marketing campaigns may see large bursts of traffic.

Low Traffic Applications with Occasional Spikes

For applications that typically receive low traffic but occasionally see large spikes (e.g., seasonal applications or those with infrequent usage), On-Demand Mode ensures you only pay for what you use, keeping costs down during idle times.

Non Constant Workloads

Some workloads may see traffic variations throughout the day or week. With On-Demand Mode, capacity adjusts in real-time to meet these fluctuations, ensuring performance is optimized regardless of traffic surges.

Step by Step Setup of DynamoDB On Demand Mode

Configuring a DynamoDB table to use On-Demand Capacity Mode is straightforward and can be done via the AWS Management Console, AWS CLI, or SDKs.

Setting Up a New Table with On Demand Mode

  1. Navigate to DynamoDB in the AWS Console:

    • Sign in to your AWS account and open the DynamoDB console.
  2. Create a New Table:

    • Click on Create Table.
    • Specify the Table Name and Primary Key for your table.
  3. Choose On Demand Capacity Mode:

    • In the Table Settings section, select On Demand under Capacity Mode.
  4. Configure Additional Settings:

    • Configure optional settings like encryption, stream settings, and auto-scaling.
    • Choose the default security settings (VPC, IAM roles).
  5. Create the Table:

    • Once all settings are configured, click Create. Your DynamoDB table will be created using On-Demand Capacity Mode.

Converting an Existing Table to On Demand Mode

  1. Select an Existing Table:

    • In the DynamoDB console, choose the table you want to switch to On-Demand Mode.
  2. Modify Capacity Mode:

    • Click on Actions > Manage Capacity Mode.
    • Select On Demand Mode from the options.
  3. Save Changes:

    • Click Save to apply the changes. The table will now operate in On-Demand Mode.

Note: Converting a table from On-Demand to Provisioned Mode and vice versa is instantaneous and does not cause downtime.

Pricing Model for On Demand Mode

DynamoDB On-Demand Mode charges you based on the number of read and write requests your application performs. Here’s how the pricing works:

Read and Write Request Units

  • Writes: A write request unit (WRU) is defined as one write operation of up to 1 KB of data.
  • Reads: A read request unit (RRU) is defined as one strongly consistent read operation of up to 4 KB of data. For eventually consistent reads, the same request consumes half an RRU.

Cost Calculation

You are billed for the number of read and write requests your application makes. AWS provides pricing details per million read/write requests in each AWS region.

For example:

  • A million write request units might cost $1.25, while a million read request units might cost $0.25.
  • Other costs such as storage costs, DynamoDB Streams, backup and restore, and data transfer costs will also apply.

Free Tier

If you're within the AWS Free Tier, you can use a certain

  • 0 gebruikers vonden dit artikel nuttig
Was dit antwoord nuttig?