AWS DynamoDB Global Tables - Multi-Region, Multi-Active Replication
Tags: aws, s3, replication, dr
Published: 2023-06-27 15:33:46


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tk9b7mch9f70f5n1hkt0.PNG)[Above image is extracted from Amazon Web Services Blog]

# 👋 Global Tables

Global Tables for Amazon DynamoDB provides replication with multi-region tables that are replicated to and active in all regions that you select. **Every region's replica is Active**, Hence, there are no read replicas in Global Tables.

Your applications are communicating with the local replica, but all your data is replicated by DynamoDB to all of the regions you have selected for that global table.

You can convert your existing single-region table to a global table with no downtime. You can easily add a remove table as a global table and **all your data is encrypted at rest**.

**The table must use on-demand capacity mode or if you are using provisioned capacity mode then auto-scaling must be enabled.**

* **DynamoDB Global table replicas are inter-connected, but not interdependent** - Tables replicas are connected and do exchange data, but their functioning and maintenance are not dependent on each other. In case, If something happens to a global table in region-A it does not affect the other global table replicas in other regions.

* **Writes in one replica are replicated in all other replicas**.
Usually, the data is propagated to other regions within one second.

* **Eventually consistent** across all tables.
* Uses the **Last Writer Wins** reconciliation to reconcile the conflicts (**Last Writer Wins reconciliation** ? Whichever replica that writes the latest version wins and will be propagated to all other replicas)

### What do DynamoDB Global Tables offer

- 
**High Availability.**

- 
**More Durability.**

- 
**Better Fault Tolerance.**

- 
**In Disaster Recovery (DR) Planning Terms (RTO/RPO)**: your database would meet a **recovery time objective of near zero** and a **recovery point objective of about one second**.

- 
**Uptime SLA of 99.999%**


### Setup & Operation

**You can use any of the below to operate everything related to DynamoDB global table.**
- AWS Console.
- CDK.
- API/SDK.
- CLI.
- Cloud Formation.

### How to Create a Global Table in AWS Console & See the Data Getting Replicated.

1. Create a DynamoDB Table. In my case, I have created a table named **BookCatalog** with 3 attributes.

- **BookName**
- **Author**
- **Genre**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/da7sodkizj6llu3r5bl0.PNG)

**Make sure to enable either on-demand capacity mode or provision capacity mode with auto-scaling**. Also, since the Global tables use DynamoDB Streams to facilitate replication, make sure to **enable DynamoDB streams**.

Once you are done with the above setup, Navigate to the **Global Tables** tab and click on the **Create Replica** button to create a replicate of your DynamoDB Table.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cbrrl94by4avp9n30sgd.PNG)

**Select the region** you want the replica to be created and **Click Create**. This will now create a replica of your DynamoDB table in the specified region along with any data in there are data also in the table. Otherwise, the table only will get replicated.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nuel8wmaq7vnkadolflt.PNG)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12obznoqspmhoajmwhp4.PNG)

**Alright! Now it's time to test the replication process.😃**

Navigate to the **us-east-1** region where you had your DynamoDB table and then create a new item.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jrkyrrz7vj0nqeexv8ma.PNG)

Now, navigate to DynamoDB table in the **us-wast-2** region to see your replicated data. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ijvrzqhsyxba9lcwu5xo.PNG)



**DynamoDB Global tables are a definitely good option to consider in your multi-region setup if that suits your business use cases.**