Amazon DynamoDB Global Tables: All You Need to Know

Amazon DynamoDB Global Tables (1)

Amazon DynamoDB Global Tables: All You Need to Know

Imagine you have a very successful application. In other words, let’s say your users are spread across the globe. And, you are using DynamoDB to store and retrieve user information.

Now as you know DynamoDB tables are by default in one region only. If you have your table in one region, your users from another region might face latency. Moreover, if one region goes down, they might not be able to use your application at all.

This doesn’t look…

What do you think you can do?

Let’s discuss that in the next section.

Don’t want to miss any posts from us? join us on our Facebook group, and follow us on Facebook, Twitter, LinkedIn, and Instagram. You can also subscribe to our newsletter below to not miss any updates from us.

The Problem and the Solution

The problem that the DynamoDB single region table poses are-

  • High latency for distant users
  • Risk of a regional outage
  • Disaster recovery compliance

After analysing the situation, you decided to go multi-region. You decided to deploy your same DynamoDB table into multiple regions.

But the problem is, that you need to work on replicating changes across tables or deal with any conflict that occurs. Although it’s not an impossible task. However, it takes time and requires more effort on your side.

This is where the DynamoDB Global table comes into the picture. In this post, we will learn about Amazon DynamoDB global tables and how they can help you solve your problem.

Things We’ll Learn About Amazon DynamoDB Global Tables Today

  • Why should You use DynamoDB Global Tables?
  • What is DynamoDB Global Table?
  • How does DynamoDB Global Table Work?
  • Benefits of DynamoDB Global Tables
  • How to Create DynaboDB Global Table?
  • DynamoDB Global Table Limitation
  • DynamoDB Global Tables Pricing
  • DynamoDB global tables supported Regions
  • AWS DynamoDB global table replication latency

Why should You use DynamoDB Global Tables?

Suppose I tell you, hey I heard you want to go multi-region with DynamoDB. I can do that work for you. You just tell me which all region you want your data in and I will take care of replicating your changes across the table. So that your users can have a better experience.

Will that make you happier?

I am sure, it does 🙂

Alright!

DynamoDB global tables can do exactly this for you.

What is DynamoDB Global Table?

DynamoDB global tables are a fully managed, multi-region and multi-master database.

  • It was launched at AWS re: Invent in 2017.
  • The global table is fully managed and you need not manage your own replication solution.
  • Supports reading and writing data locally in the region closest to the user hence better performance.
  • Your data is automatically replicated to regions of your choice that you call replica regions.
  • Data is replicated across regions hence providing higher availability and durability than a single region table. Therefore, It is great from a disaster recovery perspective
  • There are two versions of DynamoDB global tables available: Version 2019.11.21 (Current) and Version 2017.11.29

How Does DynamoDB Global Table Work?

Amazon DynamoDB global table is nothing but a collection of replica tables in various regions. When your application writes data into a replica table in a region, it automatically gets replicated to all the other regions that make the global table.

For example- If you have three replica tables in x, y and z regions. If you write to x region, it automatically replicates it to y and z.

Even if the region x fails completely or goes down, your user can still work with the table in regions y and z. As a result, your business doesn’t face downtime.

Source: AWS Official Website

Benefits of DynamoDB Global Tables

  • Replication is handled automatically by DynamoDB and you don’t need to deal with the complexity of making your own replication solution.
  • Enables read/write on the table closest to users and access globally hence providing better performance for global applications.
  • Provides single-digit Milli second performance for global applications.
  • It is fully managed and very easy to set up.
  • Provides region-level fault tolerance.

DynamoDB Global Table Prerequisite

  • You need to have stream enabled in all the regions you want your replica to be present
  • If your table is provisioned capacity, autoscaling must be enabled on your table so that databases can scale up and down to meet the user’s needs.
  • The table name must be the same as all of the other replicas.
  • If the GSIs are specified, they must have the same name across replicas.
  • Replica tables and secondary indexes in your global table must have identical write capacity settings to ensure proper replication of data

How to Create DynaboDB Global Table?

As you might already know, there are many ways in which you can create resources in AWS. The same applies to DynamoDB global table as well.

Here are a few ways I have already covered for you-

Please let me know in the comment section if you need me to cover any other way.

DynamoDB Global Table Limitation

  • You need to have your own business logic to detect and respond to region outages.
  • In the case of concurrent write, the last writer wins so you might lose the intermediate data.
  • If the read and write operations happen in a very short duration time in two regions, the read operation might be stale
  • If you write on one record at the same time from two regions- last write wins – earlier writers’ update is ignored or rolled back.
  • No cross region strong consistencies
  • Transactions are not supported across regions in global tables

DynamoDB Global Tables Pricing

There are no upfront costs or commitments for using global tables, and you pay only for the resources provisioned. Learn more about setting up global tables in the DynamoDB Developer Guide.

If normally you pay for 1 table- you would be paying for three tables

  • Storage is billed on all three tables
  • Read cost – depends on access patterns
  • Write to the table – traditional WCU – write capacity unit
  • Replication write to other regions- rWCU(Replicated write capacity unit)

I am not giving any exact figure as it keeps changing. Check the official pricing page for exact pricing details.

DynamoDB global tables supported Regions

Region support for global tables Version 2017.11.29 is limited to US East (N. Virginia), US East (Ohio), US West (N. California), US West (Oregon), Europe (Ireland), Europe (London), Europe (Frankfurt), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), and Asia Pacific (Seoul).

However, the latest version Version 2019.11.21 is present in many more regions and you can see the latest list anytime from your console in the global tables tab.

AWS DynamoDB global table replication latency

Ideally, If you add an item, it’s added. If you remove it’s removed and updated. The time it takes to replicate it to another region is called replication latency.

Depending on the source and destination region, the replication latency varies.

  • Usually, local writes in milliseconds are 3-4 milliseconds.
  • replication latency is 5 to 1.5 seconds on average.

For example, I created a table in the Mumbai region and created a replica of it in Singapore. I inserted a few pieces of data into the table in the Mumbai region and checked the average replication latency in Cloudwatch. This is what it looks like –

DynamoDB Global Table replication latency

Conclusion

In this post, we learnt about Amazon DynamoDB global tables. Global tables solve the problem of replicating your table data across regions to help you go global.

Hope the post was useful to you. Feel free to leave a comment or provide feedback.

Enjoyed the content?

Subscribe to our newsletter below to get awesome AWS learning materials delivered straight to your inbox.

Don’t forget to motivate me by-

Suggested Read:

Leave a Reply

Your email address will not be published. Required fields are marked *