Task Selection Strategies
Task selection controls the order in which tasks are dequeued for processing. This is a global setting that applies to all task types.
Available Strategies
FIFO (Default)
First-In-First-Out. Tasks are processed in the order they were queued.
DAEMON_TASK_SELECTION=fifo
Best for: General workloads, fairness guarantees, predictable ordering.
LIFO
Last-In-First-Out. Most recently queued tasks are processed first.
DAEMON_TASK_SELECTION=lifo
Best for: Cache-hot data, reducing latency for recent requests, stack-like workloads.
Priority
Tasks with higher priority values are processed first. Tasks at the same priority level use FIFO ordering.
DAEMON_TASK_SELECTION=priority
Best for: Mixed workloads with urgent vs background tasks, SLA-based processing.
Configuration
Environment Variable
CLI Flag
Docker
DAEMON_TASK_SELECTION=priority
./task-daemon --task-selection priority
services:
taskdaemon:
image: mshelia/taskdaemon:latest
environment:
- DAEMON_TASK_SELECTION=priority
Using Priority
When using the priority strategy, queue tasks with a priority value (0-100):
# High priority task (processed first)
curl -X POST http://localhost:8080/queue \
-H "Content-Type: application/json" \
-d '{"type": "urgent", "data": {...}, "priority": 100}'
# Normal priority (default is 50)
curl -X POST http://localhost:8080/queue \
-H "Content-Type: application/json" \
-d '{"type": "normal", "data": {...}}'
# Low priority task (processed last)
curl -X POST http://localhost:8080/queue \
-H "Content-Type: application/json" \
-d '{"type": "background", "data": {...}, "priority": 0}'
Priority range is 0 (lowest) to 100 (highest). Default priority is 50 if not specified.
Comparison
| Strategy | Order | Use Case |
|---|
| FIFO | Oldest first | Fair processing, predictable |
| LIFO | Newest first | Cache locality, recent data |
| Priority | Highest priority first | Urgent tasks, SLAs |