dynobase-icon
Dynobase

DynamoDB vs Google Cloud Spanner - The Ultimate Comparison

Madhumitha Baskaran

Written by Madhumitha Baskaran

Published on November 24th, 2022

    Still using AWS console to work with DynamoDB? 🙈

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

    DynamoDB and Google Cloud Spanner are two different database solutions offered by AWS and Google, respectively. Though both services have some fantastic features, sometimes developers may need help choosing one for their projects. So, in this article, I will discuss these two services' similarities and differences.

    DynamoDB and Google Cloud Spanner: An Overview

    DynamoDB

    AWS DynamoDB is a NoSQL database solution fully managed by AWS. It guarantees millisecond-range latencies at any scale and supports key-value and document data. Many developers choose DynamoDB for NoSQL database requirements since it has exciting features like high security, backups, caching (with DAX), and high scalability.

    Google Cloud Spanner

    Google Cloud Spanner is a fully managed relational database solution offered by Google. Although it is not widely used as other relational database solutions, it provides some fantastic features like transactional consistency at a global scale, strongly consistent reads, automatic multi-site replication, synchronous replication for high availability, and more.

    However, when comparing DynamoDB and Cloud Spanner, it's essential to consider the specific needs of your application. For example, if you need a highly available and scalable database, DynamoDB is a good choice. On the other hand, Cloud Spanner is a better option if you need a strong consistency and transactional database.

    Shared Attributes of DynamoDB and Google Cloud Spanner

    As mentioned, DynamoDB and Google Cloud Spanner are fully managed by large corporations in the tech industry. Hence, you don't need to worry about continuous support when choosing these two services.

    DynamoDB and Google Cloud Spanner offer similar features, but different data management approaches. For example, both use horizontal scaling for performance, but DynamoDB uses eventual consistency, while Google Cloud Spanner uses strong consistency.

    On the other hand, they have some significant differences since DynamoDB is a NoSQL-based database, whereas Google Cloud Spanner is a relational database.

    So, let's discuss these two services more to understand their differences and similarities clearly.

    Performance

    DynamoDB

    DynamoDB is a high-performing non-relational, serverless database that serves over 20 million requests per second and over 10 trillion daily requests. It can deliver single-digit millisecond latency responses for all requests, despite the data size making it a high-performing database. However, if single-digit millisecond latency isn't enough, DynamoDB allows you to use the DynamoDB Accelerator (DAX), which can offer single-digit microsecond latencies.

    Google Cloud Spanner

    Google Cloud Spanner is a distributed database service that is high performing by default and offers an approximate request rate of 10,000 read/write requests per second on a single node. Additionally, Cloud Spanner provides caching, which can improve performance by up to 10x.

    Availability and Durability

    DynamoDB

    By default, DynamoDB automatically replicates your data across multiple Availability Zones within one region. Hence, it makes your data highly available as the AZs will automatically failover in case one fails and continue serving your requests.

    DynamoDB contains an internal hash function with an O(1) time complexity (constant time). This ensures that DynamoDB can withstand rapid surges of requests and deliver responses at the same rate at low and high data volumes, making the service highly scalable and durable.

    Google Cloud Spanner

    Google Cloud Spanner is a clustered database system. It is composed of multiple clustered database servers which offer automated replication. If one of the servers in a cluster fails, the other servers in the set will continue to operate and service requests.

    Security

    DynamoDB

    DynamoDB offers encryption at rest by default. The implementation of encryption at rest is managed via the use of KMS Encryption keys. DynamoDB allows you to select the type of key that is used. For instance, developers can choose an AWS Owned Key, AWS Managed Key, or Customer Managed Key for data encryption.

    Additionally, all AWS Services that access DynamoDB needs to have the appropriate permissions to do so. For example, if a Lambda function access DynamoDB, it requires an IAM policy to provide access to the table.

    Google Cloud Spanner

    Google Cloud Spanner offers security at three levels.

    • Authentication: Ensures only authorized users can access data
    • Encryption: Protects data from unauthorized access by encrypting it
    • Audit Logs: Keeps track of all user activity for auditing and compliance purposes.

    Backups

    DynamoDB

    DynamoDB offers two kinds of backup mechanisms.

    1. Point-in-time recovery: DynamoDB can be configured to use Point-in-time recovery. This allows you to restore your data to a state within the past 35 days and is helpful in cases of accidental record deletion.
    2. Full backup: Developers can use AWS Backup to perform full database backups, which is helpful in cases of database migrations.

    Google Cloud Spanner

    Google Cloud Spanner offers the "Cloud Spanner Backup" service to create on-demand data backups. Additionally, Cloud Spanner supports Point-in-time recovery to restore the data to a state within the past seven days.

    Scalability

    DynamoDB

    DynamoDB is a highly scalable service. It is mainly due to its foundational workings under the hood. DynamoDB uses a request router that uses a hash function that has a time complexity of O(1) (constant time). Therefore, DynamoDB is able to scale up and serve high workloads with no performance loss.

    Google Cloud Spanner

    Google Cloud Spanner uses the service - "Autoscaler" to automatically scale up its nodes whenever there is an unpredictable load, making the service highly scalable for demanding workloads.

    Pricing

    DynamoDB

    DynamoDB provides two pricing models:

    On-Demand: The on-demand pricing model allows you to pay for only the throughput that you consume. Hence, this is a good model for applications with unpredictable workloads.

    Provisioned: The provisioned model allows you to provision a defined throughput (WCU and RCU). However, you will have to pay for the entire provisioned throughput, whether you consume it or not. Therefore, use a provisioned model when your application has a predictable workload.

    Use Cases

    DynamoDB

    DynamoDB is capable of responding with a single-digit millisecond to microsecond latency. Hence, it is best to use it when:

    1. Building applications that receive over 100 million per day.
    2. Building content management platforms with the help of the flexible schema-less data structure and a suitable partition approach.

    Google Cloud Spanner

    Since Google Cloud Spanner is a transactional database, it is best to use it when:

    1. You wish to maintain a relational data model
    2. You want to provide online transaction processing applications.

    Conclusion

    This article extensively compared the two popular database services - Amazon DynamoDB and Google Cloud Spanner. Though both services are exceptional, there is no good or bad database. Its application depends on your use case. Hence, it's essential to understand your application requirement before determining the proper database.

    Hence, the content presented above should provide the required information to help you decide on the database for your next big project!

    I hope you found this article helpful.

    Thank you for reading.

    Login to the AWS Console less. Use Dynobase.

    Try 7-day free trial. No strings attached.

    Product Features

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