Skip to main content
Version: 1.0.x

Priority Queue Flow

Flow Diagram

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

  1. Critical Request Prioritization: Ensure that high-priority requests, such as production traffic, are processed first in environments with mixed priorities.
  2. 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.
  3. Handling High-Traffic APIs: Manage APIs with mixed-priority requests, balancing both staging and production traffic efficiently.
  4. Fair Resource Allocation: Assign priority levels to different requests to balance resource usage and prevent low-priority traffic from impacting high-priority operations.
  5. Custom Error Handling: Configure responses for exceeding limits to ensure users are informed of delays or retries in a controlled manner.