-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #795 from RizaFarheen/riz-update
Update rate-limit-workflow.md
- Loading branch information
Showing
1 changed file
with
40 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,57 @@ | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
|
||
# Rate Limit Workflow | ||
|
||
The **workflow rate limit** limits the number of workflow executions at any given time. | ||
Workflow triggered after exceeding the rate limit will get queued based on the trigger time. | ||
RateLimit config is a part of the workflow definition. The key can be parameterized. | ||
The workflow rate limit controls the number of workflow executions allowed concurrently. Workflows triggered beyond this limit are queued based on their trigger time. | ||
|
||
## Input Parameters | ||
|
||
| Parameter | Description | | ||
| --------- | ----------- | | ||
| rateLimitConfig | The rate limit settings for workflows. This is part of the workflow definition. | | ||
| rateLimitKey | A unique identifier used to group workflow executions for rate limiting. Accepts [variables from workflow input](https://orkes.io/content/developer-guides/passing-inputs-to-task-in-conductor#sample-expressions), e.g., `${workflow.input.correlationId}`. | | ||
| concurrentExecLimit | The number of workflow executions that can run concurrently for a given key. | | ||
|
||
**Sample JSON configuration** | ||
|
||
```json | ||
// Workflow definition | ||
|
||
"rateLimitConfig": { | ||
"rateLimitKey": "someKey", | ||
"concurrentExecLimit": X | ||
} | ||
``` | ||
For example, if `concurrentExecLimit` is set to 3, a maximum of three workflows can be executed at any given time. | ||
|
||
## Client SDK Method | ||
|
||
<Tabs> | ||
<TabItem value="Java" label="Java"> | ||
|
||
## Java Example | ||
```shell | ||
RateLimitConfig rateLimitConfig = new RateLimitConfig(); | ||
rateLimitConfig.setRateLimitKey("http"); | ||
rateLimitConfig.setConcurrentExecLimit(3); | ||
workflowDef.setRateLimitConfig(rateLimitConfig); | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
|
||
## Examples | ||
|
||
Here the execution limit is set as 3, which means that no more than 3 workflows will be allowed to execute at any given time. | ||
<details><summary>Using dynamic rate limits</summary> | ||
|
||
For use cases requiring dynamic rate limits, consider the following example: | ||
|
||
## Dynamic rate limit. | ||
For a use cases where the rate limit is to be configured dynamically, we can use below example, | ||
```shell | ||
RateLimitConfig rateLimitConfig = new RateLimitConfig(); | ||
rateLimitConfig.setRateLimitKey("${workflow.correlationId}"); | ||
rateLimitConfig.setConcurrentExecLimit(3); | ||
workflowDef.setRateLimitConfig(rateLimitConfig); | ||
``` | ||
So for each correlationId separate rate limiting will be applied. | ||
For example, the workflow is triggered with correlationids 1 and 2, there will be two rate limiting queues for the workflow. | ||
We can create a dynamic rate limit based on input, workflowType, correlationid and version. | ||
|
||
In this case, a separate rate limit is applied for each correlation ID. For example, workflows triggered with correlation IDs 1 and 2 will each have their own rate-limiting queues. This approach allows dynamic rate limits based on inputs such as `workflowType`,` correlationId`, or `version`. | ||
|
||
</details> |