DynamoDB vs Amazon Timestream - The Ultimate Comparison
Written by Mapitigama Samaranayake
Published on November 13th, 2022
Time to 10x your DynamoDB productivity with Dynobase [learn more]
Amazon DynamoDB and Amazon Timestream are both serverless databases offered by AWS. However, DynamoDB is widely used as a cloud-based serverless NoSQL database service, while Amazon Timestream is a serverless time-series database solution that enables trillions of events to be analyzed and stored at a thousand times faster rate than relational databases and a fraction of the cost.
However, both serve the purpose of storing two-dimensional data while offering unique features.
Hence this article will compare and contrast Amazon DynamoDB and Amazon Timestream while providing user cases to help choose the right database service for your next project.
An Overview of Amazon DynamoDB and Amazon Timestream
DynamoDB is a fully managed, highly available, NoSQL database service provided by AWS. It ensures single-digit millisecond range latency at any scale and supports key-value and document data structures. Apart from the core features of a database, DynamoDB provides some amazing additional features like backups, high availability, and scalability to make the developer's work easier.
Amazon Timestream is a fully managed database service provided by AWS as a time series data store with an adaptive query processing engine. It is a serverless service that automatically takes care of your hardware and software deployment and maintenance.
Automated data compression, tiering, retention, and rollups are aspects of Timestream. Additionally, it has built-in analytics for data interpolation, smoothing, and approximation.
DynamoDB is a high-performance database service, and it can handle more than 10 trillion requests per day and 20 million requests per second at its peak.
DynamoDB utilizes the high IO rates of the SSDs to minimize the latency and reaction time when reading and writing data. Additionally, the performance can be significantly boosted to micro-second latency via the use of DynamoDB Accelerator (DAX).
Regardless of the table size, DynamoDB ensures high performance and maintains the latency within the millisecond range. You can further improve these numbers with efficient indexes and partitioning.
When it comes to performance, Timestream delivers latencies that are near real-time for data ingestion. This is because the magnetic store in Timestream is optimized to facilitate quick analytical queries. In contrast, the built-in memory store is optimized for fast point-in-time queries. So, for example, you could use Timestream to conduct analytical queries that examine terabytes of time-series data from the magnetic store in a matter of seconds and queries that analyze tens of gigabytes of time-series data from the memory store in milliseconds.
Amazon Timestream employs its distributed architecture and extensive parallelism to analyze increasing volumes of data while maintaining nearly constant query latencies as your data expands over time.
With query performance up to 1,000 times faster and costs as little as one-tenth the price of relational databases, it is meant to provide interactive and inexpensive real-time analytics.
One of the primary reasons people prefer AWS for their databases is its high security. DynamoDB support user-based authentication through AWS IAM and encryption at rest using AWS KMS.
Encryption at Rest: All user data stored in tables, indexes, streams, and backups are encrypted at rest by DynamoDB using encryption keys stored in AWS Key Management Service (AWS KMS). This adds an extra layer of data security by preventing unauthorized access to the underlying storage.
IAM user roles authentication: You can create separate users, user roles, and policies using AWS IAM and assign them to users based on the requirements. With proper configurations, you can easily allow different users to access different tables.
Amazon Timestream uses encryption at rest or in transit when it comes to data security. Timestream requires the use of AWS KMS to encrypt your data.
Encryption at Rest: provides increased security by employing encryption keys stored in AWS KMS to encrypt all data at rest. The complexity and operational burden of securing sensitive data are both decreased by this functionality. As a result, you can create security-sensitive applications that adhere to solid encryption compliance and regulatory standards.
Encryption in Transit: all of your Timestream data is encrypted. The Transport Layer Security (TLS) protocol is used by default to encrypt all communications to and from Timestream.
DynamoDB tables are highly scalable, and it provides two capacity models to choose from when creating a table.
Provisioned capacity mode - Users need to define the minimum and the maximum number of capacity units in this mode. Tables will only operate between those limits. And, users are billed for the throughput they provision, regardless of its usage.
On-Demand - In this mode, DynamoDB will automatically increase and decrease read and write capacity units based on the traffic. This mode is well suited for applications with ad hoc traffic.
With a fully decoupled design, which enables data ingestion, storage, and query to scale independently, Amazon Timestream can provide practically limitless scaling for an application's requirements. You don't need to manage infrastructure or provision capacity using Amazon Timestream. Ingestion and query scaling are automated based on workload.
There is no need to configure, monitor, and manage a complex data archival process with Amazon Timestream. Data retention policies can be easily configured to automatically move data from the memory store to the magnetic store and discard it from the memory store once it reaches a specific date.
DynamoDB has 2 backup options: on-demand backups and PITR (Point-in-Time Recovery).
On-demand backup - Allows you to create full backups of your tables for long-term storage and archiving for regulatory compliance purposes. With a simple click on the AWS management console or a single API call, you can backup and restore your table data at any time. Table performance and availability are unaffected by backup and restore operations.
Point-in-time - PITR safeguards your DynamoDB tables against unintentional writes or deletes operations. When enabled, point-in-time backups will be created automatically, and it allows you to restore tables up to any point in the last 35 days with a precision of seconds.
Physically isolated and physically separated multiple Availability Zones that are connected by low-latency, high-throughput, and highly redundant networking are offered by AWS Regions. Using availability zones, you can design and run databases and applications that automatically switch between zones with no downtime.
Since Timestream is multi-AZ, it does not support backup to other regions or availability zones. However, the Timestream SDK allows you to create applications that can query data and save it where you want.
Similar to other Amazon services, DynamoDB core features are billed based on usage. However, an additional cost will be included if you have enabled services like backups. The pricing of your table is decided based on the capacity mode you choose.
If you choose the on-demand capacity mode, the total cost will be decided based on the application traffic. But, if you choose provisioned capacity mode, the cost will be calculated based on the number of read and write units you define.
In addition, 25 GB of data storage, 2.5 million streams read requests, and 100 GB of data transfer outs will be allocated under AWS free tier. You can find more details on AWS DynamoDB pricing in the documentation.
There are no upfront payments or minimum charges when using Amazon Timestream; you only pay for the services you utilize. Two questions arise when it comes to pricing for Timestream: 1 - Do we need a memory store for a longer retention period? 2 - Do we have many reads on the DB frequently?
You can see in the table below the cost per each storage type calculated for hourly, daily, and monthly-based pricing. In the right-most column, the relative cost compared to the memory store is given.
The usage charges are based on writes, queries, the amount of data stored in the memory, and magnetic stores. Timestream offers a set of cost optimizations, including the following.
- Multi-measure time series records
- Data batching
- Automatic detection of repeated data
- Magnetic store writes
- Data retention
- Effective query authoring
- Scheduled queries
When and Where to Pick Which Database
DynamoDB is a perfect solution if you are looking for a cloud-based NoSQL database service. It is cost-effective and provides a variety of additional features.
Here are some of the most common use cases of DynamoDB:
- If your application already uses other AWS services.
- Applications that require uninterrupted performance at scaling.
- Real-time streaming applications.
- For scalable applications.
- Shopping carts and gaming platforms.
Timestream is more useful when users must collect and analyze operational metrics such as CPU/memory utilization, network data, and IOPS(Input/Output Operations per second) to monitor health and optimize instance utilization. And large amounts of data may be easily stored and analyzed thanks to Amazon Timestream.
Some of the use cases where Timestream is used:
- Analytical applications
- IoT based applications
- DevOps applications
This article explores critical aspects of DynamoDB and Amazon Timestream while expressing key information about each service to help you select the right database service for your project.
I hope that you have found this article helpful.
Thank you for reading.