How To Achieve High Availability With DynamoDB Global Tables
Uriel Bitton
AWS Cloud Consultant | The DynamoDB guy | AWS Certified | I help you supercharge your DynamoDB database ????
?? Welcome to the 6th edition of Excelling With DynamoDB!
I'm Uriel Bitton, a solutions architect on AWS and I teach you how to master DynamoDB to build scalable, resilient, and high-performing databases.
I have built and designed 8+ projects with DynamoDB and I have 12 years of experience in software development and cloud technologies.
Being highly available at a global scale is often very important when running large-scale operations online.
High availability allows you to be fault-tolerant and offers your application lower latency for users who use it in different regions of the world.
If you run a website that is used by both users in the U.S. and in Europe but your database resides on a server near you in the U.S., your users in Europe will experience higher latency (slower website loading & processing) which will affect their experience on your website.
To solve this problem, cloud providers offer a service that replicates your database tables to other regions across the world and stores those copies of your data in servers located in these regions.
This lets you host your data on servers anywhere in the world without actually owning them — you’re just renting them, often for a very low price.
AWS DynamoDB
AWS is one such provider that lets you replicate your data across the world.
DynamoDB manages the entire data replication for you, ensuring your data is well-synchronized across all regions so you can remain highly available with no manual intervention.
Global Tables
DynamoDB Global Tables is a fully serverless service that provides you with 99.999% availability, increased application resiliency, and improved business continuity.
By replicating your database tables anywhere across the world, your data remains close to your users, offering better user experiences.
Let’s take a look at implementing Global Tables in DynamoDB by using the AWS console.
Global Tables Demo
Let’s head over to the DynamoDB dashboard in the AWS console.
From there you can click the orange button Create table, to create a new DynamoDB table.
On this page, add a name for your table and select the partition and sort keys.
Scrolling down you’ll see the section Table Settings. Select the Customize settings option and the DynamoDB Standard option.
Next in Read/write capacity settings, you can choose provisioned and leave the Read capacity auto scaling to On (Global tables can only be created with auto scaling capacity or on-demand mode).
You can leave the rest of the defaults as they are and scroll towards the bottom of the page to create the table by clicking the orange button Create table.
You will now be redirected to the list of tables, click the table you just created and you should see the table details page:
Here you will see some tabs — click on the Global tables tab.
You should see a section called Replicas. Let’s create a new replica by clicking the Create replica button in white.
You’ll be redirected to the create replica page:
In the Available replication regions dropdown, select the region you’d like to replicate your database table to.
My base table is in the us-east-1 region, so I’ll replicate my table to eu-europe-2 (Europe London).
You can then create the replica by clicking the Create replica button below.
It might take some time for DynamoDB to create the replica. Once the replica is created you will be redirected to the previous page with the replicas section.
领英推荐
If you still see 0 replicas, you can hit the refresh button or refresh the page.
You’ll now be able to see your active replica:
Testing Our Replica Table
To test our replica table to make sure it works as intended, we can perform 3 types of tests:
The first test is easy to perform, the last 2 tests are a little more complex to perform, so we’ll stick to the first one in this article.
Data Consistency Testing
Let’s add data to our primary region table and see if the data is replicated to the replica table.
Go ahead and open each table in a new tab. In each table click the orange button Explore table items at the top.
Now in the primary region table (mine is us-east-1), let’s create an item to that table.
At the bottom of the primary table details page click on the Create item button.
In the create item page I created an item with some basic fields.
I can create the item by clicking the Create item button below.
This will add the item to my primary table.
Note the region in the top right corner denoted with a red box. That’s the us-east-1 region table — my primary table. Below you can see the item added to the primary table.
Now let’s check the replica table to see if the item has been copied there.
Switching to the other tab with our replica table, let’s refresh the page (or click the refresh items button).
This time you can see the region is London and the item has been successfully replicated to that table.
We can now allow users to read and write data to and from our DynamoDB table from both the U.S. and London regions, maintaining low latency data access as well as a fault-tolerant database.
Conclusion
DynamoDB Global Tables allow the data in our database to remain highly available and close to end users around the world by replicating the data across multiple regions.
This lets our users experience low latency of reading and writing to our database and allows us to remain fault tolerant. The data replication is automatically and fully managed by DynamoDB, benefitting us with business continuity with ease.
If you enjoyed this post, please consider subscribing and sharing the newsletter with your connections: https://www.dhirubhai.net/newsletters/7181386750357893121/
?? My name is Uriel Bitton and I hope you learned something in this edition of Excelling With DynamoDB.
?? Please consider sharing it with your network to help others learn as well.
?? You can also explore my social media links here:
?? *my blog website is coming soon, so stay tuned for that.
?? I hope to see you in the next week's edition!
Uriel