You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: clarfy concurrency limits and waiting state in workflows (#26273)
* feat: clarfy concurrency limits and `waiting` state in workflows
* Apply suggestions from code review
Co-authored-by: Olga Silva <[email protected]>
* make example smaller
* Apply suggestions from code review
Co-authored-by: Olga Silva <[email protected]>
* fix typo
* PCX Review
---------
Co-authored-by: Olga Silva <[email protected]>
Co-authored-by: Jun Lee <[email protected]>
| Maximum Workflow instance creation rate | 100 per second [^6]| 100 per second [^6]|
29
29
| Maximum number of [queued instances](/workflows/observability/metrics-analytics/#event-types)| 10,000 | 100,000 |
30
30
| Retention limit for completed Workflow state | 3 days | 30 days [^2]|
@@ -42,8 +42,55 @@ Many limits are inherited from those applied to Workers scripts and as documente
42
42
43
43
[^6]: Workflows will return a HTTP 429 rate limited error if you exceed the rate of new Workflow instance creation.
44
44
45
+
[^7]: Only instances with a `running` state count towards the concurrency limits. Instances in the `waiting` state are excluded from these limits.
46
+
45
47
<Renderfile="limits_increase"product="workers" />
46
48
49
+
### `waiting` instances do not count towards instance concurrency limits
50
+
51
+
Instances that are on a `waiting` state - either sleeping, waiting for a retry, or waiting for an event - do **not** count towards concurrency limits. This means that other `queued` instances will be scheduled when an instance goes from a `running` state to a `waiting` one, usually the oldest instance queued, on a best-effort basis. This state transition - `running` to `waiting` - may not occur if the wait duration is too short.
52
+
53
+
For example, consider a Workflow that does some work, waits for 30 days, and then continues with more work:
let resp =awaitfetch('https://api.cloudflare.com/client/v4/ips');
67
+
returnawaitresp.json<any>();
68
+
});
69
+
70
+
awaitstep.sleep('wait 30 days', '30 days');
71
+
72
+
awaitstep.do(
73
+
'make a call to write that could maybe, just might, fail',
74
+
{
75
+
retries: {
76
+
limit: 5,
77
+
delay: '5 second',
78
+
backoff: 'exponential',
79
+
},
80
+
timeout: '15 minutes',
81
+
},
82
+
async () => {
83
+
if (Math.random() >0.5) {
84
+
thrownewError('API call to $STORAGE_SYSTEM failed');
85
+
}
86
+
},
87
+
);
88
+
}
89
+
}
90
+
```
91
+
92
+
While a given Workflow instance is waiting for 30 days, it will transition to the `waiting` state, allowing other `queued` instances to run if concurrency limits are reached.
93
+
47
94
### Increasing Workflow CPU limits
48
95
49
96
Workflows are Worker scripts, and share the same [per invocation CPU limits](/workers/platform/limits/#worker-limits) as any Workers do. Note that CPU time is active processing time: not time spent waiting on network requests, storage calls, or other general I/O, which don't count towards your CPU time or Workflows compute consumption.
0 commit comments