Skip to content

Commit ae1754a

Browse files
committed
address feedback
1 parent 4ba304b commit ae1754a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/content/docs/reference-architecture/diagrams/storage/durable-object-control-data-plane-pattern.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ updated: 2024-11-20
1515
Each Durable Object instance has its own durable storage persisted across requests, in-memory state, single-threaded execution, and can be placed in a specific region.
1616

1717
A single Durable Object instance has certain [performance and storage capabilities](/durable-objects/platform/limits/).
18-
Therefore, in order to scale an application without being restricted by a single instance's limits we need to shard our application data as much as possible, and take advantage of the [Cloudflare infrastructure](https://www.cloudflare.com/en-gb/network/) by spreading our Durable Object instances across the world, moving both the data and compute as close to users as possible.
18+
Therefore, to scale an application without being restricted by the limits of a single instance we need to shard our application data as much as possible, and take advantage of the [Cloudflare infrastructure](https://www.cloudflare.com/en-gb/network/) by spreading our Durable Object instances across the world, moving both the data and compute as close to the users as possible.
1919

2020
This document describes a useful architectural pattern to separate the control plane from the data plane of your application to achieve great performance and reliability without compromising on functionality.
2121

2222
- The **control plane** provides the administrative APIs used to manage resource metadata. For example, a user creating and deleting a wiki, or listing all wikis of a user.
2323
- The **data plane** provides the primary function of the application and handles the operations on the resources data directly. For example, fetching and updating the content of a wiki, or updating the content of a collaborative document. Data planes are intentionally less complicated and usually handle a much larger volume of requests.
24-
- The **management plane** is an optional component of a system providing a higher level of interaction than the control plane to simplify configuration and operations. In this document, we won't focus on this as the same principles apply as to the control plane.
24+
- The **management plane** is an optional component of a system providing a higher level of interaction than the control plane to simplify configuration and operations. In this document, we will not focus on this as the same principles apply as to the control plane.
2525

2626
## Control and data plane separation pattern
2727

@@ -32,37 +32,37 @@ You can scale to millions of Durable Object instances, one for each of your reso
3232
The main advantage of this architectural pattern is that our data plane operations, usually with larger volume of requests than control plane operations, are handled directly by the Durable Object instances holding the resource data without going through the control plane Durable Object instance.
3333
Therefore, the application's performance and availability is not limited by a single Durable Object instance, but is shared across thousands or millions of Durable Objects.
3434

35-
Let's dive into an example for a generic resource type `XYZ`, where `XYZ` could in-practice be a wiki, a collaborative document, a database for each user, or any other resource type in your application.
35+
Consider an example for a generic resource type `XYZ`, where `XYZ` could in-practice be a wiki, a collaborative document, a database for each user, or any other resource type in your application.
3636

3737
![Figure 1: Control and data plane architectural pattern for Durable Objects](~/assets/images/reference-architecture/durable-objects-control-data-plane-pattern/diagram.svg "Figure 1: Control and data plane architectural pattern for Durable Objects")
3838

3939
1. A user in London (LHR) initiates a resource `XYZ` creation request. The request is routed to the nearest Cloudflare datacenter and received by the Workers fleet which serves the application API.
4040
2. The Worker code will route the request to the appropriate control plane Durable Object instance managing the resources of type `XYZ`. We will use the `idFromName` approach to reference the Durable Object instance by name (`control-plane-xyz`). This allows immediate access to the control plane Durable Object instances without needing to maintain a mapping.
4141
- The location of the control plane Durable Object will be close to the first request accessing it, or to the explicit region we provide using [Location Hints](/durable-objects/reference/data-location/#provide-a-location-hint).
4242
3. The control plane Durable Object instance (`control-plane-xyz`) receives the request, and immediately creates another Durable Object instance (`data-plane-xyz-03`) near the user request's location (using Location Hints) so that the actual Durable Object instance holding the resource's content is near the user that created it.
43-
- We call a custom `init(...)` function on the created Durable Object instance (`data-plane-xyz-03`) passing any required metadata info that will be needed in order to start handling user requests.
44-
The Durable Object instance stores this information in its local storage and does any necessary initialisation.
43+
- We call a custom `init(...)` function on the created Durable Object instance (`data-plane-xyz-03`) passing any required metadata info that will be needed to start handling user requests.
44+
The Durable Object instance stores this information in its local storage and performs any necessary initialisation.
4545
This step can be skipped if each subsequent request to the created resource contains all the information needed to handle the request. For example, if the request URL contains all the information as path and query parameters.
4646
- We use the [`idFromName`](/durable-objects/api/namespace/#idfromname) approach to reference the Durable Object (`data-plane-xyz-03`) which allows the use of name-based resource identifiers.
4747
- Alternatively, we can use the [`newUniqueId`](/durable-objects/api/namespace/#newuniqueid) approach to reference the Durable Object which will give us a random resource identifier to use instead of a name-based one. This random identifier will need to be communicated back to the user so that they provide it in their subsequent requests when accessing the resource.
48-
4. The control plane Durable Object instance (`control-plane-xyz`) stores the generated identifier (`data-plane-xyz-03`) to its local storage, in order to be able to list/delete all created resources, and then returns it to the user.
48+
4. The control plane Durable Object instance (`control-plane-xyz`) stores the generated identifier (`data-plane-xyz-03`) to its local storage, in order to be able to list/delete all created resources, and then returns it to the Worker.
4949
5. The user receives a successful response for the creation of the resource and the corresponding identifier, and (optionally) gets redirected to the resource itself.
5050
6. The user sends a write request to the API for the resource identifier returned in the previous step, in order to update the content of the resource.
5151
7. The Worker code uses the resource identifier provided to directly reference the data plane Durable Object instance for that resource (`data-plane-xyz-03`). The Durable Object instance will handle the request appropriately by writing the content to its local durable persistent storage and return a response accordingly.
5252
8. Another user from Portland (PDX) is sending a read request to a previously created resource (`data-plane-xyz-01`).
5353
9. The Worker code directly references the Durable Object instance holding the data for the given resource identifier (`data-plane-xyz-01`), and the Durable Object instance will return its content by reading its local storage.
5454

55-
As long as the application data model allows sharding at the resource level you can scale out as much as you want, while taking advantage of data locality near the user that accesses that resource.
55+
As long as the application data model allows sharding at the resource level, you can scale out as much as you want, while taking advantage of data locality near the user that accesses that resource.
5656

5757
The same pattern can be applied as many times as necessary to achieve the performance required.
5858

59-
For example, depending on our load we could further shard our control plane Durable Object into several.
59+
For example, depending on our load, we could further shard our control plane Durable Object into several Durable Objects.
6060
Instead of having a single Durable Object instance for all resources of type `XYZ`, we could have one for each region.
6161
The name-based approach to reference a Durable Object instance simplifies targeting the appropriate instance accordingly.
6262

6363
In conclusion, as long as you find a way to shard your application's data model in fine-grained resources that are self-contained, you are able to dedicate at least one Durable Object instance to each resource and scale out.
6464

65-
## Related Resources
65+
## Related resources
6666

6767
- [Durable Objects Namespace documentation](/durable-objects/api/namespace/)
6868
- [Durable Objects: Easy, Fast, Correct — Choose three](https://blog.cloudflare.com/durable-objects-easy-fast-correct-choose-three/)

0 commit comments

Comments
 (0)