Introduction
As systems grow in complexity, services begin receiving thousands to millions of commands from APIs, background jobs, integrations, and event-driven workflows. Handling all commands equally leads to queue congestion, slow responses, and system-wide delays.
This article explains how to design a scalable command routing and prioritization model where each command is routed to an appropriate execution channel and processed with system-wide fairness, SLAs, isolation, and predictable load behavior.
Understanding Commands at Scale
A command is an instruction to perform an operation, for example:
CreateInvoice
ReserveStockLine
ApproveRepairOrder
ProcessPayment
GeneratePickTicket
When scale increases, challenges appear:
Commands arriving faster than they can be processed
Certain commands needing higher priority (e.g., user-facing actions)
Heavy commands blocking small lightweight commands
Retry storms causing overload
No isolation between domains
A structured routing model solves these challenges.
High-Level Architecture
+---------------------------+
| API Gateways / Services |
+---------------------------+
|
v
+--------------------+
| Command Router |
+--------------------+
| | |
v v v
+-----------+ +-----------+ +-----------+
| High-Pri | | Medium | | Low-Pri |
| Channel | | Channel | | Channel |
+-----------+ +-----------+ +-----------+
| | |
v v v
+-------------+ +-------------+ +-------------+
| Executors | | Executors | | Executors |
+-------------+ +-------------+ +-------------+
The command router determines:
Which queue/channel the command should go into
What priority level the command should hold
Whether the command should load-balance or go to a sticky executor
Command Routing Patterns
1. Header-Based Routing
Routing based on:
CommandName
TenantId
UserType (Admin vs Customer)
SLA requirement
Metadata
Example rule
IF command == "GenerateInvoice" AND tenantTier == "Gold"
ROUTE TO HighPriorityChannel
2. Domain-Based Routing
Each domain owns its own executor pool:
Inventory Commands → Inventory Executor
Repair Commands → Repair Executor
Invoice Commands → Billing Executor
Benefits
Isolation
Independent scaling
Fault containment
3. Cost-Based Routing
Compute cost based on CPU/RAM/IO:
Lightweight commands → FastLane Channel
Medium commands → General Channel
Heavy commands → Batch Channel
Example
ReserveStockLine → Lightweight
GenerateMonthlyReport → Heavy
Prioritization Patterns
1. Static Priority Tiering
Levels

Join the conversation! Your thoughts help the community grow.