Priority-based queue with automatic timeout promotion

Published: (December 27, 2025 at 11:19 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

cover

Core Features

Bounded Concurrency

  • Configurable worker pool size (default: CPU cores × 2).
  • Tasks beyond worker capacity queue up to avoid system overload while maximizing hardware utilization.

Priority Queue and Promotion

  • Five‑level priority system implemented with a min‑heap: Immediate > High > Retry > Normal > Low.
  • Higher‑priority tasks execute first; tasks with the same priority are processed FIFO.
  • Tasks that wait for a long time are automatically promoted to a higher priority to prevent starvation.
  • Promotion thresholds are calculated based on configured timeouts.

Error Retry

  • When a task fails, it can be automatically retried.
  • Retry tasks are re‑enqueued with Retry priority, which sits between High and Normal, providing a delayed retry effect.
Back to Blog

Related posts

Read more »

High-Throughput IoT Log Aggregator

!Cover image for High-Throughput IoT Log Aggregatorhttps://media2.dev.to/dynamic/image/width=1000,height=420,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fde...