Technologies/Dramatiq/dramatiq.worker.threads
DramatiqDramatiqMetric

dramatiq.worker.threads

Total active worker threads
Dimensions:None
Available on:PrometheusPrometheus (1)
Interface Metrics (1)
PrometheusPrometheus
Number of worker threads currently active
Dimensions:None

Technical Annotations (24)

Configuration Parameters (5)
--threadsrecommended: Reduce from high values like 40; single thread (--threads=1) works reliably
Controls worker thread count; high values cause consumer thread starvation with CPU-intensive tasks
rabbitmq.heartbeat_timeoutrecommended: Increase from default
Allows longer intervals between heartbeat communication before connection closure
queue_namerecommended: high-priority, default, low-priority, bulk
Separate queues by priority to prevent head-of-line blocking
worker_threadsrecommended: 8
default per-process limit on concurrent message processing
time_limitrecommended: Use with gevent, not threads
Threading mode time limits cause worker crashes due to async exception race condition
Error Signatures (3)
pika.exceptions.ConnectionWrongStateError: BlockingConnection.add_callback_threadsafe() called on closed or closing connection.exception
Failed to wait for all callbacks to complete. This can happen when the RabbitMQ server is suddenly restarted.log pattern
dramatiq.middleware.time_limit.TimeLimitExceededexception
CLI Commands (4)
dramatiq example --threads=40 --processes=1diagnostic
dramatiq example --threads=1 --processes=1remediation
dramatiq tasks --queues high-priority --threads 8remediation
dramatiq tasks --queues default low-priority --threads 4remediation
Technical References (12)
consumer threadscomponentsys.setswitchintervalcomponentheartbeat intervalconceptdelayed queuecomponentsys.getswitchintervalcomponentkernel thread schedulingconceptAsyncIO middlewarecomponentevent loopconceptgeventcomponentPyThreadState_SetAsyncExccomponentbroker.emit_aftercomponentBaseExceptionconcept
Related Insights (6)
Concurrent actor execution overwhelms database and external serviceswarning
Message duplication from RabbitMQ connection closure under CPU-intensive loadcritical
Single-thread CPU pinning causes RabbitMQ connection timeoutwarning
Worker thread pool exhaustion delays high-priority taskswarning
AsyncIO actors limited by worker thread count causing blockingwarning
TimeLimitExceeded exception during error handling causes worker thread deathcritical