Priority Queue Flow
📄️ Flow Configuration Template
Flow Configuration
📄️ Flow Example
In this configuration:
The Priority Queue Flow manages API requests based on their priority, ensuring high-priority traffic is handled first while maintaining smooth processing for lower-priority requests. Using the Queue
processor, it controls the number of requests in the queue and assigns priorities via the x-lunar-consumer-tag
header. Requests are delayed until their turn arrives or the time-to-live (TTL) expires. If the queue is full, or limits are exceeded, a 429 "Too Many Requests" response is generated.
This flow optimizes traffic load, prioritizes critical requests, and ensures efficient resource utilization.
Scenarios
- Critical Request Prioritization: Ensure that high-priority requests, such as production traffic, are processed first in environments with mixed priorities.
- Preventing Overload with Queuing: Delay lower-priority requests in a queue to manage traffic without immediately generating "Too Many Requests" responses, unless the queue is full or TTL expires.
- Handling High-Traffic APIs: Manage APIs with mixed-priority requests, balancing both staging and production traffic efficiently.
- Fair Resource Allocation: Assign priority levels to different requests to balance resource usage and prevent low-priority traffic from impacting high-priority operations.
- Custom Error Handling: Configure responses for exceeding limits to ensure users are informed of delays or retries in a controlled manner.