Cross-region replication (Global Tables) in DynamoDB - Time & Space Complexity
When using DynamoDB Global Tables, data is copied across regions automatically.
We want to understand how the time to replicate data grows as more data changes.
Analyze the time complexity of replicating write operations across regions.
// Pseudocode for replication event
for each write in region A {
send change to region B;
apply change in region B;
}
This code shows how each write in one region is sent and applied to another region.
Look for repeated actions that affect time.
- Primary operation: Sending and applying each write change to other regions.
- How many times: Once per write operation made in the source region.
As the number of writes increases, the replication work grows too.
| Input Size (writes) | Approx. Operations (replications) |
|---|---|
| 10 | 10 |
| 100 | 100 |
| 1000 | 1000 |
Pattern observation: The replication work grows directly with the number of writes.
Time Complexity: O(n)
This means the time to replicate grows in a straight line as more writes happen.
[X] Wrong: "Replication time stays the same no matter how many writes happen."
[OK] Correct: Each write must be sent and applied, so more writes mean more replication work.
Understanding how replication time grows helps you design systems that stay fast as they grow.
"What if replication was done in batches instead of one write at a time? How would the time complexity change?"