dynobase-icon
Dynobase

DynamoDB vs Amazon ElastiCache - The Ultimate Comparison

Mahesh Samarasinghe

Written by Mahesh Samarasinghe

Published on September 14th, 2022

    Still using AWS console to work with DynamoDB? 🙈

    Time to 10x your DynamoDB productivity with Dynobase [learn more]

    DynamoDB and ElastiCache are two of the most popular database services provided by AWS. This article discusses these two services with their differences, pros, and cons to help you identify the best for your requirements.

    DynamoDB and Amazon ElastiCache: An Overview

    DynamoDB is a fully managed NoSQL database service that is reliable, scalable, and highly available. As DynamoDB is a serverless service, AWS takes care of all the server administration, and you only have to pay for what you use. It supports both document and key-value store models, making it versatile for various applications.

    On the other hand, ElastiCache is a fully managed cache service offered by Amazon Web Services (AWS) capable of deploying, managing, and scaling a distributed in-memory cache environment in the cloud. It supports two different cache engines: Memcached and Redis, each with its own set of features and use cases.

    Latency and Performance

    DynamoDB

    DynamoDB uses SSDs for storage, and the high I/O performance provided by these SSDs allows DynamoDB to handle more than 10 trillion requests per day with peaks greater than 20 million per second. Regardless of the table size, DynamoDB can maintain low latency, and you need to use optimized table layouts, indexes, and queries to get the maximum from it.

    In addition, DynamoDB Accelerator (DAX) can be used to increase DynamoDB performance margins by tenfold, reducing response times from milliseconds to microseconds. DAX is particularly useful for read-heavy workloads that require microsecond response times.

    ElastiCache

    ElastiCache offers a variety of node types varying in in-memory capacity, network support, and performance based on the node instance type. These nodes can serve up to a million requests per second.

    The latency for ElastiCache requests is around 300 - 500 microseconds. Identifying the correct node size and the instance type can further improve the performance of the ElastiCache node. Compared to traditional databases, which usually have double-digit millisecond latencies, ElastiCache is much faster and serves the purpose of an in-memory data store.

    Security

    DynamoDB

    All data stored in DynamoDB is fully encrypted using encryption keys managed by AWS Key Management Service (KMS). This provides an additional layer of security by protecting data in a table, including its primary keys, secondary indexes, streams, global tables backup, etc.

    When creating a new table, the user can choose from the following options to encrypt the table:

    • AWS-owned key - Default encryption type. The key is owned by DynamoDB (no additional charge).
    • AWS managed key - The key is stored in your account and is managed by AWS KMS (AWS KMS charges apply).
    • Customer-managed key - The key is stored in your account and is created, owned, and managed by you. You have full control over the KMS key (AWS KMS charges apply).

    In addition, you can use the AWS IAM service to provide fine-grained access control to DynamoDB tables based on users, user groups, or policies. DynamoDB also supports VPC endpoints, which allow you to connect to DynamoDB from your VPC without going through the public internet.

    ElastiCache

    ElastiCache provides both encryption at rest and encryption in transit features. However, some conditions need to be satisfied by the cache engine (Redis and Memcached) to enable encryption. These conditions can be satisfied at the cluster designing level.

    It is important to note that in-transit encryption can reduce the cluster's performance. Therefore, benchmarking performance with and without encryption in transit can help understand the impact on the application. ElastiCache also supports VPCs, security groups, and IAM roles to enhance security.

    Pricing

    DynamoDB

    DynamoDB charges users for its core features based on usage and extra for additional services like backups. Furthermore, DynamoDB pricing is presented in two modes based on capacity:

    • On-demand capacity mode: This option enables users to pay based on the application traffic. The price will be calculated based on how the workload is scaling up and down. Therefore users do not have to specify a throughput value which makes this option ideal for unpredictable workloads.
    • Provisioned capacity mode: This option allows the user to define the number of reads and writes per second, and the pricing will be decided based on that. This is an ideal option for predictable workloads.

    ElastiCache

    Pricing for ElastiCache is calculated based on the hours of usage, backup storage, and data transfer within or across regions. ElastiCache supports on-demand nodes as well as reserved nodes which have different pricing models.

    • On-demand nodes: This model allows users to pay by the hour without any long-term commitments. The user is charged from when a node is started to when a node is terminated. Also, a partial hour is billed as a full hour. Per-hour price will vary based on the node type.
    • Reserved nodes: Reserved nodes provide a significant discount in hourly pay for the node type. The user needs to make a long-term commitment of either one year or three years. And based on whether the payment is made upfront or not, a user can get even lower hourly charges.

    Comparing Other Features of DynamoDB and Amazon ElastiCache

    Availability

    DynamoDB automatically spreads the data and the traffic to ensure the throughput and storage requirements are met without affecting the performance of the database. All of the data are stored in SSDs and replicated across multiple availability zones and regions. In addition, global tables can be used to keep tables in sync across different regions.

    ElastiCache also supports multi-AZ for higher availability. In a scenario where the primary node is down for either maintenance or availability zone failure, a read replica in a different AZ is automatically promoted as the primary node minimizing the downtime. ElastiCache propagates the DNS names to the promoted read replica to ensure higher availability.

    Scalability

    DynamoDB tables are highly scalable. It provides two capacity modes named on-demand and provisioned to select. DynamoDB tables are automatically scaled up and down in the on-demand mode based on the workload. In provisioned capacity mode, the user must define the auto-scaling configurations, including the minimum and the maximum number of capacity units.

    ElastiCache also provides the user with the auto-scaling capability to ensure they are paying only for what they use. Both cache engines of Redis and Memcached in ElastiCache support auto-scaling with few differences in the implementation in each engine.

    Find more on ElastiCache cluster scaling here.

    When to Use Which

    When comparing the above-discussed attributes, each service has its pros and cons, making them a very good solution in some scenarios and not so much in others. Therefore it is very important to understand which scenarios each service is suitable for.

    DynamoDB

    When a NoSQL database system is required and if the user is already using AWS, DynamoDB can be a good NoSQL solution. In addition, you can use DynamoDB for projects with requirements like high availability, constant performance, and scale of mission-critical workloads with no manual intervention.

    However, it is important to look at the workload to ensure that the correct decision is made when selecting DynamoDB. You can read more about suitable workloads for DynamoDB and get a better understanding here.

    ElastiCache

    Caching is one of the best options to reduce latency. Therefore if a user is looking for an in-memory data store to save the most frequently fetched data items, ElastiCache might be a good solution since it stores non-durable datasets in the memory and provides data with microseconds latency.

    For a scenario where a user wants to ease the load on the backend, ElastiCache can come in handy as it can ease the pressure on the backend with high scalability and microsecond latency. ElastiCache is also ideal for use cases like session storage, leaderboards, and real-time analytics.

    Conclusion

    In this article, I have discussed DynamoDB and ElastiCache, two popular AWS data storage services. It is important to understand their pros and cons to understand which service suits your use case better. Both services offer unique features and capabilities that can significantly enhance the performance and scalability of your applications.

    Hope this article helps you make a better decision on your use case. Thank you for reading.

    Spend less time in the AWS console, use Dynobase.

    Try 7-day free trial. No credit card needed.

    Product Features

    Download
    /
    Changelog
    /
    Pricing
    /
    Member Portal
    /
    Privacy
    /
    EULA
    /
    Twitter
    /
    Affiliates & Influencers
    © 2024 Dynobase