dynobase-icon
Dynobase

DynamoDB vs S3 - The Ultimate Comparison

Chameera Dulanga

Written by Chameera Dulanga

Published on May 18th, 2022

    Still using AWS console to work with DynamoDB? 🙈

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

    Amazon DynamoDB and AWS S3 are 2 of the most popular AWS services. As developers, it is essential to understand the similarities and differences before choosing one for your project.

    In this article, I will compare and contrast AWS DynamoDB and AWS S3 to give you a better understanding.

    DynamoDB and S3: An Overview

    DynamoDB

    AWS DynamoDB is a fully managed NoSQL database solution offered by AWS. It guarantees millisecond range latency at any scale and supports key-value and document data. It also has some great features like security, backups, caching(with DAX), and scalability to help developers build reliable applications.

    S3

    AWS S3 (Simple Storage Service) is an object storage service offered by AWS. In fact, it is the most widely used storage service in AWS and comes with some fantastic features like high security, data availability, scalability, and static hosting. Most importantly, it is very cost-effective, and you can easily access data from anywhere using the AWS management console.

    Shared Attributes for DynamoDB and S3

    As mentioned, both these services provide valuable features such as high performance, scalability, backups, security, and high availability. So, the developers can focus on other aspects of the application without worrying about the database or the storage they choose.

    On the other hand, DynamoDB is used as a database to store the document or key-value pair data, whereas S3 is used to save objects like images, videos, files, etc. So, if we discuss a bit more about these attributes, we can find some significant differences between DynamoDB and S3.

    Availability and Durability

    DynamoDB

    DynamoDB ensures high availability by replicating data among multiple availability zones. For example, you need to select a region when creating a table, and AWS will automatically replicate that table in 3 availability zones within that region. This process maintains the high durability and availability of data stored in DynamoDB tables even in physical disasters like fires, earthquakes, and fire outages.

    Furthermore, you can use DynamoDB global tables to replicate your DynamoDB tables across multiple regions of your choice to ensure high availability and durability.

    Learn more about DynamoDB Disaster Recovery.

    S3

    Although AWS S3 is a global service, it also uses the availability zones to ensure the high availability of the data. Like DynamoDB, S3 replicates data across 3 availability zones in a region and makes sure your data is available even in a physical disaster. In addition, all the S3 classes are designed to retain the data even if a complete availability zone is lost.

    Most importantly, AWS S3 is designed to provide 99.999999999% durability and 99.99% availability of objects over a given year. Apart from that, you can use object versioning to recover in case of intentional or unintentional deletion of the data.

    Scalability

    DynamoDB

    DynamoDB tables are highly scalable. There are 2 capacity modes available, and you can select one based on the requirements.

    • On-Demand - In this mode, DynamoDB tables are automatically scaled up and down based on the workload. This model is cost-effective if you have ad-hoc traffic.
    • Provisioned capacity mode - Here, developers need to define the auto-scaling configurations, including the minimum and the maximum number of capacity units. This model is cost-effective when you have predictable traffic.

    S3

    AWS S3 is a highly scalable object storage service. It supports parallel requests and performance scales per prefix. For example, if your application can perform 5000 GET requests per second/prefix, you can quickly scale it 10 times by creating 10 prefixes within the bucket.

    Latency and Performance

    DynamoDB

    DynamoDB is well-known for its high performance. Regardless of the table size, it ensures millisecond latency at any scale and can handle more than 20 million requests per second and up to 10 trillion requests per day.

    It utilizes the power of SSDs to minimize the latency and improve the response time when reading and writing data at any scale. You can also use the in-memory caching support and DynamoDB Accelerator (DAX) to minimize the data reading time to microseconds.

    Also, as developers, maintaining a good table design, streamlining the database workload, and using proper keys and indexes can improve the DynamoDB performance.

    S3

    As mentioned in the scalability section, AWS S3 is highly scalable. However, regardless of the scale, S3 ensures high performance for your application's needs with a latency of around 100-200 milliseconds.

    You can also follow best practices such as using Amazon S3 Transfer Acceleration, using the latest version of AWS SDKs, and retrying requests for latency-sensitive applications to improve performance further.

    Security

    DynamoDB

    DynamoDB works well with AWS IAM service. Developers can easily use IAM policies and rules to control access to DynamoDB tables. Apart from that, AWS KMS encryptions can also be used to improve the security of DynamoDB tables. Developers can create, manage and sort encryption keys using AWS KMS, and there are 3 options to encrypt DynamoDB tables with AWS KMS.

    • AWS-owned key - This method is free, and the key of the DynamoDB will be encrypted by default.
    • AWS-managed key - This method will secure all the keys stored in the users' accounts. Users will be charged based on their usage.
    • Customer-managed key - In this method, users have complete control over the keys. Users will be charged based on their usage.

    Learn more about DynamoDB Security.

    S3

    Similar to DynamoDB, AWS S3 provides maximum security for the data stored within S3 buckets. By default, only the resource creator can access the resource. Apart from that, you can use the below options to increase the security.

    • AWS Identity and Access Management (IAM) - Create new users and assign different access to them.
    • Access Control Lists (ACLs) - Make individual objects accessible to authorized users.
    • Bucket Policies - Configure access policies to all objects within a bucket.
    • Block Public Access - Block public access to all objects at bucket level or account level.
    • Object Lock - Blocks object version deletion for a defined retention period.
    • Audit Logs - Lists all the requests made for S3 resources.
    • Query String Authentication - Limited access using temporary URLs.

    In addition to all these, S3 follows programs like PCI-DSS, HIPAA/HITECH, FedRAMP, EU Data Protection Directive, and FISMA to ensure data security.

    Learn more about S3 Security.

    Backups & Restore

    DynamoDB

    DynamoDB has 2 backup and restore mechanisms: On-demand backup and Point-in-time backups (PITR).

    In on-demand backups, you need to schedule backups manually. This approach is widely used for long-term retentions and archiving purposes. Regardless of the table size, on-demand backups will quickly complete the backup process, and it will not affect application performance or latency in any manner.

    Point-in-time recovery is the automatic backup mechanism in DynamoDB. When enabled, you do not need to worry about scheduling backups. Instead, it will continuously create backups, and you can use them to restore data for up to 35 days by selecting the exact date and time up to seconds of precision.

    S3

    Similar to DynamoDB, AWS S3 also provides 2 backup options: Continuous backups and Periodic backups.

    Continuous backups are pretty similar to DynamoDB PITR, and it allows you to restore data for up to 35 days. In periodic backups, you need to schedule backups manually, and these backups can be retained for a specific time, including indefinitely.

    However, backup support for AWS S3 is relatively new, and there are some limitations. You can find more details on S3 backups here.

    Pricing

    DynamoDB

    The core features of DynamoDB are billed based on usage. This does not include optional features like backups, and the DynamoDB pricing modal is a bit different from other AWS services. For example, DynamoDB considers 1 KB as a single write unit for strongly consistent writes, and for strongly consistent reads requests, it considers 4KBs as a single read.

    There are 2 pricing models available based on the capacity model you choose:

    • On-demand capacity mode — The traffic will decide the total price for the read and write units. Capacities can either go up or down based on the workload.
    • Provisioned capacity mode — The total price will be calculated based on the users' read and write capacity units.

    Apart from that, DynamoDB provides 25 GB of data storage, 2.5 million streams read requests, and 100 GB of data transfer out to the internet under the free tier.

    S3

    AWS S3 only requires you to pay for what you use. However, there are 6 components to consider when calculating the cost for S3.

    • Storage - There are multiple storage classes available with different capacities. For example, the S3 Standard class will cost 0.023 USD for the first 50TB/Month, 0.022 USD for the next 450 TB/Month, and 0.021 USD for usage over 500 TB/Month.
    • Requests and Data Retrievals - The same storage classes apply here as well. S# Standard class will cost 0.005 USD per 1000 PUT, COPY, POST, LIST requests, and 0.0004 USD per 1000 GET, SELECT, and all other requests.
    • Data transfer - You need to pay for the data transfers in and out from S3. There are a few exceptions, and you can find more details here.
    • Management and Analytics - All the storage management and analytics features enabled by the user will be billed under this component.
    • Replication - S3 data replication ost is calculated under this component.
    • S3 Object Lambda - S3 Object Lambda allows to add your own code to S3 GET requests. Cost is calculated based on the amount of data returned to an application, and it will cost 0.005 USD per GB.

    In addition to all these, AWS S3 also provides a free tier of 5 GB storage, 20000 GET Requests, 2000 PUT, COPY, POST, or LIST Requests, and 100 GB of data transfer out.

    When and Where to Pick Which Service

    As you understand, both DynamoDB and S3 provide some amazing features to users. Although these features seem identical, DynamoDB and S3 are designed to serve different purposes.

    DynamoDB

    DynamoDB is a great option if you are looking for a fully managed NoSQL database solution. Also, it is cost-effective compared to most relational database services.

    Due to its high performance and scalability, DynamoDB is perfect for applications requiring high-speed data reading and writing. Here are some of the most common use cases of DynamoDB:

    • Building scalable web and mobile applications.
    • Applications with high I/O needs.
    • Content management.
    • Shopping carts.
    • Gaming platforms.
    • Real-time streaming.

    Find more about the use cases for DynamoDB here.

    S3

    The main purpose of AWS S3 is to store files. It allows you to read files using HTTP, and you can upload individual files up to 5 TB. It is not bound to EC2 like other storage services provided by AWS and ensures high performance, availability, security, and scalability. So, AWS S3 is a perfect choice for any file storage need in web and mobile applications.

    Here are some of the most highlighted use cases of S3:

    • Static site hosting.
    • As storage for web and mobile applications.
    • Data archiving.
    • Disaster recovery.
    • Data analytics.

    Conclusion

    In this article, I discussed the similarities and differences between DynamoDB and S3. I hope now you have a good understanding of their features and when you should choose them.

    Thank you for reading!

    Tired of switching accounts and regions? Use Dynobase.

    First 7 days are on us. No strings attached.

    Product Features

    © 2022 Dynobase