Lesson 70.4 · 4 of 5 · 4 min read · Reviewed 24 Nov 2026
Data residency
By the end, you can
- Explain data residency for AI systems.
- List the places user data travels.
Data residencyData residency: A requirement that data is stored or processed in a particular country or region. is a promise about where customer data lives and is processed. AI systems make more copies of data than most apps, so the promise is easy to break by accident.
Where data goes
| Place | Often forgotten? |
|---|---|
| Main database | No |
| Model API calls | Sometimes: which region processes them? |
| Traces and logs | Yes: third-party tools in other regions |
| Caches and semantic caches | Yes |
| Vector stores and embeddings | Yes: embeddings are derived from the data |
| Eval sets built from real traffic | Yes |
| Backups and replicas | Sometimes |
| Fallback routes (70.3) | Yes |
Choosing where to process
Cloud platforms that host Claude, such as Amazon Bedrock and Google Cloud Vertex AIGoogle Cloud Vertex AI: Google Cloud’s AI platform, which offers hosted models with Google Cloud identity and billing., let you choose regions, and offer cross-region or global routingRouting: A workflow pattern that classifies an input and sends it to a specialised prompt, model or handler. options for capacity. Routing across regions can conflict with a residency promise, so pick options that stay within your boundary. Check each platform’s docs for current regions and how routing works.
Write it down
Keep a data-flow diagram that shows every hop and region. Review it when you add a tool, a vendor or a fallback route. Legal and security teams will ask for it.
This is general guidance, not legal advice. Your obligations depend on your contracts and the laws that apply to you.
Key points
- Data residency means keeping data, and sometimes processing, inside a chosen geography.
- Map every place data goes: model calls, logs, traces, caches, vector stores, backups, sub-processors.
- Choose regions and platforms that match your commitments, and check fallbacks follow the same rules.
Map where user data travels
List every hop user data takes and find the ones that break a residency promise.
You will have: A data-flow table and a list of violations with a suggested fix for each.
Steps
- Run the starter: it finds no violations.
- Implement violations(): user data outside the promised region.
- Run again and read the fixes.
- Add two hops you often forget, such as backups and embeddings from a separate API, with their regions.
- Keep the table as the start of your data-flow document.
Done when
- violations: 2 is printed.
- The traces tool and the semantic cache are flagged.
- The status page is not flagged because it holds no user data.
Open in the Playground No API key needed.
Starter code (Python)
# Map every place user data travels and check it against an EU residency promise.
PROMISE = "eu"
HOPS = [
{"hop": "web servers", "region": "eu", "user_data": True},
{"hop": "main database", "region": "eu", "user_data": True},
{"hop": "model calls", "region": "eu", "user_data": True},
{"hop": "traces (hosted tool)", "region": "us", "user_data": True},
{"hop": "semantic cache", "region": "us", "user_data": True},
{"hop": "vector store", "region": "eu", "user_data": True},
{"hop": "eval set from traffic", "region": "eu", "user_data": True},
{"hop": "status page", "region": "us", "user_data": False},
{"hop": "fallback platform", "region": "eu", "user_data": True},
]
def violations(hops, promise):
# TODO: a hop breaks the promise if it holds user data and its region is not `promise`
return []
for h in HOPS:
print(f"{h['hop']:<24} {h['region']:<6} {'user data' if h['user_data'] else 'no user data'}")
bad = violations(HOPS, PROMISE)
print(f"violations: {len(bad)}")
for h in bad:
print(f" fix: move {h['hop']} into {PROMISE}, or stop sending it user data")
Show a solution
# Map every place user data travels and check it against an EU residency promise.
PROMISE = "eu"
HOPS = [
{"hop": "web servers", "region": "eu", "user_data": True},
{"hop": "main database", "region": "eu", "user_data": True},
{"hop": "model calls", "region": "eu", "user_data": True},
{"hop": "traces (hosted tool)", "region": "us", "user_data": True},
{"hop": "semantic cache", "region": "us", "user_data": True},
{"hop": "vector store", "region": "eu", "user_data": True},
{"hop": "eval set from traffic", "region": "eu", "user_data": True},
{"hop": "status page", "region": "us", "user_data": False},
{"hop": "fallback platform", "region": "eu", "user_data": True},
]
def violations(hops, promise):
return [h for h in hops if h["user_data"] and h["region"] != promise]
for h in HOPS:
print(f"{h['hop']:<24} {h['region']:<6} {'user data' if h['user_data'] else 'no user data'}")
bad = violations(HOPS, PROMISE)
print(f"violations: {len(bad)}")
for h in bad:
print(f" fix: move {h['hop']} into {PROMISE}, or stop sending it user data")