Data location
You can restrict a Durable Object to a jurisdiction, or provide a location hint.
Durable Objects can be created so that they only run and store data within a specific jurisdiction to comply with local regulations such as the GDPR ↗ or FedRAMP ↗.
To use a jurisdiction, first create a jurisidictional subnamespace in your Worker’s code:
A jurisdictional subnamespace works like a normal Durable Object namespace (OBJECT_NAMESPACE
above), except that IDs created within them permanently encode the jurisdiction that was used to create the subnamespace. Additionally, the idFromString()
and get()
methods will throw an exception if the IDs passed into them are not within the subnamespace’s jurisdiction. Once you have a subnamespace, you can use all of the namespace methods documented above.
To create a new Durable Object ID that will only run and persist data within the jurisdiction:
To derive a unique Object ID from the given name string that will only run and persist data within the jurisdiction:
To parse a previously-created ID from a string:
To obtain an Object:
While you cannot use an ID from a different jurisdiction in a subnamespace’s idFromString()
or get()
methods, you can use any valid ID in the top-level namespace’s methods. Object IDs created with a jurisdiction will still only run and persist data within the jurisdiction.
Your Workers may still access Durable Objects constrained to a jurisdiction from anywhere in the world. The jurisdiction constraint only controls where the Durable Object itself runs and persists data. Consider using Regional Services to control the regions from which Cloudflare responds to requests.
The currently supported jurisdictions are eu
(the European Union) and fedramp
(FedRAMP).
Durable Objects, as with any stateful API, will often add response latency as requests must be forwarded to the data center where the Durable Object, or state, is located.
Durable Objects do not currently change locations after they are created1. By default, a Durable Object is instantiated in a data center close to where the initial get()
request is made. This may not be in the same data center that the get()
request is made from, but in most cases, it will be in close proximity.
Location hints are the mechanism provided to specify the location that a Durable Object should be located regardless of where the initial get()
request comes from.
To manually create Durable Objects in another location, provide an optional locationHint
parameter to get()
. Only the first call to get()
for a particular Object will respect the hint.
The following locations are supported:
Location Hint Parameter | Location |
---|---|
wnam | Western North America |
enam | Eastern North America |
sam | South America |
weur | Western Europe |
eeur | Eastern Europe |
apac | Asia-Pacific |
oc | Oceania |
afr | Africa |
me | Middle East |
1 Dynamic relocation of existing Durable Objects is planned for the future.