Skip to content

feat/add-worker-rate-limiting-support - #1

Open
aquiveal wants to merge 19 commits into
mainfrom
feat/add-worker-rate-limiting-support
Open

aquiveal wants to merge 19 commits into
mainfrom
feat/add-worker-rate-limiting-support

Conversation

@aquiveal

@aquiveal aquiveal commented Jun 8, 2026

Copy link
Copy Markdown

Closes http://feedback.trigger.dev/p/rate-limiting-on-v3

✅ Checklist

  • I have followed every step in the contributing guide
  • The PR title follows the convention.
  • I ran and tested the code works

Testing

  • Verified atomic rate limiting logic using Redis Lua scripts to ensure precise execution control.
  • Executed comprehensive unit tests for RateLimitManager to confirm accurate TTL handling and state consistency.
  • Ran integration tests for the Fair Queue to ensure tasks are correctly delayed and re-queued upon limit exhaustion.
  • Validated E2E scenarios for queue rate limit overrides via the dashboard UI, ensuring seamless user interaction and state updates.

Changelog

  • Introduced comprehensive worker-level rate limiting support for tasks and queues, enabling both static and dynamic rate limits.
  • Added RateLimitManager for atomic, Redis-based traffic shaping to strictly enforce execution windows.
  • Integrated RateLimitSystem to manage dynamic configuration and ensure reliable database synchronization.
  • Extended task and queue schemas to support granular rate limit definitions (including limit, window, staticKey, and dynamicKey).
  • Enhanced the dashboard UI to allow real-time management and overriding of queue rate limits directly from the project dashboard.
  • Added comprehensive documentation for the new rate limiting features, including a dedicated guide and updated task configuration references.

Screenshots

image.png

aquiveal added 17 commits June 8, 2026 10:27
Define RateLimitRequest and RateLimitCheckResult interfaces to support pre-processing rate limit checks. Update existing queue and job definitions to include optional rate limit configurations.

This change allows workers to enforce granular concurrency and rate limiting policies by passing request metadata through the task payload and worker queue structures.
Implement the RateLimitManager class to support atomic multi-key rate limiting using Lua scripts. Add support for static configurations and dynamic consumption tracking to ensure consistent rate management across worker processes.
Add a comprehensive test suite for the RateLimitManager
class to ensure correct rate limiting behavior,
atomicity of operations, proper cleanup, and TTL
management for Redis keys.
Integrate RateLimitManager into the FairQueue workflow to allow per-message rate limiting. When a message contains rate limit definitions, the worker checks these limits before processing. If a limit is exceeded, the message is released back to the queue with a delay until the limit resets.
Add integration tests to verify that task processing is correctly delayed when rate limits are exceeded and that rate-limited tasks from one tenant do not block processing for other tenants.
Include rateLimits in the task configuration objects to allow users to define and enforce concurrency or rate limiting constraints on their tasks.
Introduce the RateLimitConfig schema to define rate-limiting 
parameters for tasks. Update the task metadata definition to 
include an optional array of these configurations, enabling 
granular task throttling support.
Add the rateLimits property to the task type definition to allow users to constrain task execution frequency. This supports both static and dynamic keys, providing granular control over resource usage based on specific task payloads.
Expose the rateLimit property in QueueListPresenter, QueueRetrievePresenter, and TaskPresenter to allow frontend components to access and display queue rate limit configurations.
Add the ability to define and override rate limits for task queues in the dashboard. This includes UI components to manage multiple rate limit rules and backend logic to persist these overrides via the rate limit system.
Implement methods to update and remove queue rate limits in Redis. Add a new key producer method to generate the required Redis key for storing rate limit configurations.
Introduce the RateLimitSystem class to handle overriding and resetting queue rate limits. This service updates the database state and synchronizes the changes with the Redis cache to ensure runtime rate limiting policies are enforced correctly.

Include unit tests to verify database interactions and side-effect calls to the queue service.
Initialize the RateLimitSystem as a singleton to ensure a shared instance across the application, preventing redundant database connection handling.
Implement updateQueueRateLimits and removeQueueRateLimits functions to interact with both MARQS and the internal RunQueue engine. These changes allow for dynamic adjustment of rate limiting configurations for specific queues.
Add a test suite to verify that queue concurrency and rate limits can be correctly overridden and removed via the web application interface. This ensures that the queue management actions correctly persist state changes to the database.
Include rate limit configuration in the queue schema to support 
traffic shaping and request throttling. This allows consumers to 
define limits and window sizes for queue processing.
Refactor the queue limit override dialog to use a more intuitive layout with Fieldset and InputGroup components. Add support for managing multiple rate limit entries with add/remove functionality and improve input handling for better user experience.
@aquiveal
aquiveal force-pushed the feat/add-worker-rate-limiting-support branch from fc07a9f to 09fae6a Compare June 8, 2026 04:57
aquiveal added 2 commits June 8, 2026 10:51
Create a new guide explaining how to implement static and dynamic rate limits for tasks. Include examples for configuring limits per task and per queue, and explain how to manage these settings via the dashboard.
Add a new guide for rate limiting tasks and update the introduction, task overview, and sidebar to include the new functionality. This allows users to control run execution frequency using static or dynamic keys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant