Sub topic 15
Data residency and compliance constraints
This chapter assumes you know cross-region replication and write ownership from earlier chapters, and that you can configure DNS-based routing.
Why residency changes the design
Data residency is a rule that certain data must be stored, and sometimes processed, in a specific country or region. Examples include the GDPR's limits on moving personal data out of the European Economic Area and national laws that require local storage for health or financial records.
A basic active-active design replicates everything to every region. Residency rules forbid that for regulated data. You replace full replication with selective replication. Legal interpretation belongs to your compliance team. Your job is to make the rules enforceable in the architecture.
Terms to keep apart
| Term | Meaning |
|---|---|
| Data residency | Where data is physically stored |
| Data sovereignty | Which country's laws apply to the data |
| Data transfer | Any movement of data across a border, including reads and support access |
Design patterns
- Tag each record with a home jurisdiction. This extends write ownership. The tag decides which regions may hold a copy.
- Split regulated from global data. Product catalogs and configuration replicate everywhere. Personal data stays inside its jurisdiction.
- Route by location, not only latency. A latency-based record can send an EU user to a US region. Use geolocation routing, or an application check, so users reach their home jurisdiction.
- Run at least two regions per jurisdiction. Failover then stays inside the border.
The replication layer should enforce the tag, not rely on each service to remember it:
ALLOWED = {
"EU": {"eu-west-1", "eu-central-1"},
"US": {"us-east-1", "us-west-2"},
}
def can_replicate(residency, target_region):
"""GLOBAL data may go anywhere. Other data only to its jurisdiction.
Unknown labels fail closed."""
if residency == "GLOBAL":
return True
return target_region in ALLOWED.get(residency, set())
print(can_replicate("EU", "eu-central-1")) # True
print(can_replicate("EU", "us-east-1")) # False
print(can_replicate("GLOBAL", "us-east-1")) # True
print(can_replicate("APAC", "us-east-1")) # FalseWhere data leaks
Replication is the obvious path. These are the ones teams miss:
- Backups and snapshots copied to a disaster recovery region.
- Logs, traces and metrics that contain user identifiers.
- Search indexes, caches and analytics replicas.
- Message queues and event streams that carry personal fields.
- Encryption keys. Keep keys for regulated data in the same jurisdiction.
Trade-offs
Residency reduces the benefit of active-active. Users in a jurisdiction get availability only from that jurisdiction's regions. Capacity planning must cover the loss of one region per jurisdiction, not per planet. Global queries, such as a worldwide report, must aggregate anonymized or permitted data instead of reading raw records. Audit evidence matters too, so log which region stored and accessed each class of data.
Exercise
A team runs three regions: eu-west-1, us-east-1 and ap-southeast-1. EU personal data must stay in the EU. Name two problems with this setup and one fix for each.
Show answer
First, only one EU region exists, so a regional outage leaves EU users with no compliant failover target. Add a second EU region, such as eu-central-1. Second, a nightly backup job may copy EU data to another region, which breaks residency. Restrict backups to EU regions and add a policy check, such as the replication check shown above, to the backup job.