Skip to content

Commit 3df6220

Browse files
committed
[cloudflare] add docs for the durable objects Queue
1 parent dae34d3 commit 3df6220

1 file changed

Lines changed: 38 additions & 9 deletions

File tree

pages/cloudflare/caching.mdx

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,57 @@ The binding name used in your app's worker is `NEXT_CACHE_WORKERS_KV`. The servi
5353

5454
In your project's OpenNext config, enable the KV cache and set up a queue.
5555

56-
The memory queue will send revalidation requests to a page when needed, and offers support for de-duplicating requests on a per-isolate basis. There might still be duplicate requests under high traffic or across regions.
57-
58-
<Callout type="warning">
59-
The memory queue provided by `@opennextjs/cloudflare` is not fully suitable for production deployments, you
60-
can use it at your own risk!
61-
</Callout>
56+
The Durable Object Queue will send revalidation requests to a page when needed, and offers support for de-duplicating requests.
57+
By default there will be a maximum of 10 instance of the Durables Object Queue and they can each process up to 5 requests in parallel.(For up to 50 ISR revalidations in parallel)
6258

6359
```ts
6460
// open-next.config.ts
6561
import { defineCloudflareConfig } from "@opennextjs/cloudflare";
6662
import kvIncrementalCache from "@opennextjs/cloudflare/kv-cache";
67-
import memoryQueue from "@opennextjs/cloudflare/memory-queue";
63+
import doQueue from "@opennextjs/cloudflare/durable-queue";
6864

6965
export default defineCloudflareConfig({
7066
incrementalCache: kvIncrementalCache,
71-
queue: memoryQueue,
67+
queue: doQueue,
7268
});
7369
```
7470

71+
You will also need to add some binding to your `wrangler.jsonc` file.
72+
73+
```jsonc
74+
"durable_objects": {
75+
"bindings": [
76+
{
77+
"name": "NEXT_CACHE_REVALIDATION_DURABLE_OBJECT",
78+
"class_name": "DurableObjectQueueHandler"
79+
}
80+
]
81+
},
82+
"migrations": [
83+
{
84+
"tag": "v1",
85+
"new_sqlite_classes": ["DurableObjectQueueHandler"]
86+
}
87+
],
88+
```
89+
90+
You can customize the behaviors of the queue with environment variables:
91+
- The max number of durable workers that can be created (MAX_REVALIDATE_CONCURRENCY)
92+
- The max number of revalidations that can be processed by an instance of durable worker at the same time (MAX_REVALIDATION_BY_DURABLE_OBJECT)
93+
- The max time in milliseconds that a revalidation can take before being considered as failed (REVALIDATION_TIMEOUT_MS)
94+
- The amount of time after which a revalidation will be attempted again if it failed. If it fails again it will exponentially back off until it reaches the max retry interval (REVALIDATION_RETRY_INTERVAL_MS)
95+
- The maximum number of attempts that can be made to revalidate a path (MAX_REVALIDATION_ATTEMPTS)
96+
97+
7598
<Callout>
76-
The `direct` mode for the queue is intended for debugging purposes and is not recommended for use in
99+
There is 2 additional modes that you can use for the queue `direct` and the memory queue
100+
101+
- The memory queue will dedupe request but only on a per isolate basis. It is not fully suitable for production deployments, you
102+
can use it at your own risk!
103+
104+
- The `direct` mode for the queue is intended for debugging purposes and is not recommended for use in
77105
production. We are actively working on a solution that will be suitable for production.
106+
78107
</Callout>
79108

80109
#### On-Demand Revalidation

0 commit comments

Comments
 (0)