dhiaayachi / temporal

Temporal service
https://docs.temporal.io
MIT License
0 stars 0 forks source link

Do not consume rate limit token on invalid tasks #20

Open dhiaayachi opened 2 months ago

dhiaayachi commented 2 months ago

When setting maxTaskQueueActivitiesPerSecond to enable rate limit on task queue, the token is consumed when task is attempted to be delivered. However, the task could be invalid (expired or workflow already closed), which lead to waste of rate limit token.

We should change this to only consume token when task is delivered.

dhiaayachi commented 2 months ago

Thank you for reporting this issue.

Currently, the rate limiter consumes a token when a task is attempted to be delivered, even if the task is invalid (expired or workflow already closed). This can lead to wasted tokens.

We are looking into a potential fix for this issue. As a workaround, you can consider adjusting the maxTaskQueueActivitiesPerSecond setting to account for the potential wasted tokens.

Please let us know if you have any other questions.

dhiaayachi commented 2 months ago

Thank you for reporting this issue.

Currently, the rate limiter consumes a token when a task is attempted to be delivered, even if the task is invalid (expired or workflow already closed). This can lead to wasted rate limit tokens.

We are considering changing this behavior to only consume a token when the task is successfully delivered.

Until then, you can work around this issue by implementing a custom workflow that checks for task validity before attempting to deliver the task. If the task is invalid, the workflow can avoid attempting to deliver it, thus conserving rate limit tokens.

dhiaayachi commented 2 months ago

Thank you for reporting this issue! I understand that the rate limit token is currently consumed when a task is attempted to be delivered, even if the task is invalid. This can lead to wasted tokens.

We are aware of this issue and are actively working on a solution to only consume the token when the task is successfully delivered. In the meantime, you can work around this by:

We will update the documentation once a fix is available.

For more information on task queue rate limiting, please refer to the documentation: https://docs.temporal.io/docs/concepts/task-queue-rate-limiting/

dhiaayachi commented 2 months ago

Thank you for reporting this issue. We understand that currently, the rate limit token is consumed when a task is attempted to be delivered, even if the task is invalid. This can lead to a waste of rate limit tokens.

We are actively working on improving this behavior. In the meantime, you can consider using a workflow cancellation mechanism to mitigate this issue. When a workflow is canceled, the associated tasks are also canceled, and the rate limit token is not consumed for these canceled tasks.

For more information on workflow cancellation, please refer to Workflow Cancellation.

dhiaayachi commented 1 month ago

Thanks for reporting this issue! We understand that the current behavior of consuming rate limit tokens when tasks are attempted to be delivered, even if they are invalid, can be wasteful.

We are currently working on a solution to only consume tokens when tasks are successfully delivered. In the meantime, you can work around this issue by:

We will update the documentation once this feature is available.