dynobase-icon
Dynobase

DynamoDB Global Tables - The Ultimate Guide

Rafal Wilinski

Written by Rafal Wilinski

Published on May 27th, 2020

    Still using AWS console to work with DynamoDB? 🙈

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

    DynamoDB Global Tables

    What are DynamoDB Global Tables?

    DynamoDB Global Tables are globally available, fully-managed, multi-master, multi-region DynamoDB tables with eventual cross-region replication. With global tables, you get a replica of your table in each of the desired regions. Once you write data to one of the replicas, it will be eventually replicated to the rest of the tables. This ensures high availability and low-latency access to data across different geographical locations.

    How to Create Global Tables in DynamoDB? (Step by Step)

    Create DynamoDB Global Tables using AWS Console

    1. Create a table as you would do that regularly. You can do that using AWS Console, Dynobase, CloudFormation, Serverless Framework, or whatever you like.
    2. Enable DynamoDB Streams on that table. They are required to create Global DynamoDB Table.
    3. Go to AWS DynamoDB Console, select your table, and head to the "Global Tables" section. Click "Add Region".

    Creating global dynamodb tables in aws console

    1. Select the region and confirm the selection by clicking "Create Replica".

    Creating global dynamodb tables in aws console, selecting region

    After a few seconds, your table in another region should be ready.

    Create DynamoDB Global Tables using CloudFormation

    If you want to create your Global DynamoDB Table using CloudFormation, you have to do that using custom resources and use their createGlobalTable API in your custom resource. This approach allows for more complex and automated deployments, especially in large-scale environments.

    Create DynamoDB Global Tables using CDK

    Creating DynamoDB Global Tables with CDK is fortunately much easier. The Table construct accepts the replicationRegions property, which is an array of regions where replica tables will be created. In TypeScript, you can use it like this:

    Using DynamoDB Global Tables

    Using DynamoDB Global Tables is quite similar to using standard DynamoDB tables. The key difference is the region you set when using the DynamoDB/DocumentClient SDK. Make sure you're using the region where your compute resources are deployed. If your Lambda functions or EC2 instances are deployed in a region where you don't have a DynamoDB Global Table replica, you might use a fallback to a base region. In Node.js, it might look like this:

    Frequently Asked Questions

    What is the DynamoDB Global Table replication latency?

    Replication latency is often less than one second. It's also worth mentioning that it's measurable via CloudWatch; the ReplicationLatency metric is what you're looking for. This low latency ensures that your data is quickly available across all regions, providing a seamless experience for global applications.

    How much do DynamoDB Global Tables cost?

    DynamoDB Global Tables cost can be calculated by summing up the individual cost of all the replicated tables and adding Replicated Write Request Units to all that. You can use our pricing calculator to estimate rough costs of your setup. Keep in mind that costs can vary significantly based on the amount of data written and read across regions.

    What are the DynamoDB Global Tables supported regions?

    DynamoDB Global tables are now available in the following regions:

    • US East (Ohio)
    • US East (N. Virginia)
    • US West (N. California)
    • US West (Oregon)
    • Asia Pacific (Mumbai)
    • Asia Pacific (Seoul)
    • Asia Pacific (Singapore)
    • Asia Pacific (Sydney)
    • Asia Pacific (Tokyo)
    • Canada (Central)
    • EU (Frankfurt)
    • EU (Ireland)
    • EU (London)
    • EU (Paris)
    • South America (Sao Paulo)
    • AWS GovCloud (US-East)
    • AWS GovCloud (US-West)

    How does encryption work in DynamoDB Global Tables?

    Encryption in DynamoDB Global Tables works exactly the same as in traditional, single-region tables. It's encrypted both at rest and in transit. AWS Key Management Service (KMS) is used to manage the encryption keys, ensuring that your data is secure across all regions.

    How are conflicts managed in DynamoDB Global Tables?

    Because DynamoDB Global Tables don't support partial updates, race conditions might occur and data integrity may be compromised. In such cases, DynamoDB uses a last writer wins approach, so when one write operation is committed, other ones in transit might be rejected. This is something to keep in mind while designing your application. To mitigate conflicts, consider implementing application-level conflict resolution strategies.

    What are some use cases for DynamoDB Global Tables?

    DynamoDB Global Tables are ideal for applications that require low-latency data access across multiple regions. Common use cases include gaming applications, financial services, and e-commerce platforms where users are distributed globally. By replicating data across regions, you can ensure high availability and disaster recovery, making your application more resilient.

    Better DynamoDB experience.

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

    Product Features

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