Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,27 +334,31 @@
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-task_send_sent_event
CELERY_TASK_SEND_SENT_EVENT = True

# Health checking and retries, specific to Redis
CELERY_REDIS_MAX_CONNECTIONS = 50 # Total connection pool limit for results backend
CELERY_REDIS_SOCKET_TIMEOUT = 120 # Match Redis timeout
CELERY_REDIS_SOCKET_KEEPALIVE = True
CELERY_REDIS_BACKEND_HEALTH_CHECK_INTERVAL = 30 # Check health every 30s
# Health checking and retries, specific to Redis (not needed for RabbitMQ)
# CELERY_REDIS_MAX_CONNECTIONS = 50 # Total connection pool limit for results backend
# CELERY_REDIS_SOCKET_TIMEOUT = 120 # Match Redis timeout
# CELERY_REDIS_SOCKET_KEEPALIVE = True
# CELERY_REDIS_BACKEND_HEALTH_CHECK_INTERVAL = 30 # Check health every 30s
Comment thread
mihow marked this conversation as resolved.
Outdated

# Help distribute long-running tasks
# https://docs.celeryq.dev/en/stable/userguide/configuration.html#worker-prefetch-multiplier
# @TODO Review and test this setting
CELERY_WORKER_PREFETCH_MULTIPLIER = 1
CELERY_WORKER_ENABLE_PREFETCH_COUNT_REDUCTION = True

# Cancel & return to queue if connection is lost
# https://docs.celeryq.dev/en/latest/userguide/configuration.html#worker-cancel-long-running-tasks-on-connection-loss
CELERY_WORKER_CANCEL_LONG_RUNNING_TASKS_ON_CONNECTION_LOSS = True

# RabbitMQ broker connection settings
# These settings improve reliability for long-running workers with intermittent network issues
CELERY_BROKER_TRANSPORT_OPTIONS = {
"socket_timeout": 120, # Socket read/write timeout (seconds)
"socket_connect_timeout": 30, # Max time to establish connection (seconds)
"socket_connect_timeout": 40, # Max time to establish connection (seconds)
"socket_keepalive": True, # Enable TCP keepalive probes
"retry_on_timeout": True, # Retry operations on timeout
"max_connections": 20, # Per-process connection pool limit
"heartbeat": 60, # RabbitMQ heartbeat interval (seconds) - detects broken connections
"heartbeat": 30, # RabbitMQ heartbeat interval (seconds) - detects broken connections
}

# Broker connection retry settings
Expand Down