Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#927 Redis clustering, unify retry policy
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Aug 24, 2023
1 parent d8d20fd commit 13206db
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from kombu import Queue, Exchange
from redis.backoff import ExponentialBackoff
from redis.retry import Retry
from redis.exceptions import ConnectionError

from core import __version__

Expand Down Expand Up @@ -325,8 +326,8 @@
'CONNECTION_POOL_KWARGS': {
'max_connections': 100,
'retry': Retry(ExponentialBackoff(cap=10, base=0.5), 10),
'socket_connect_timeout': 5,
'socket_timeout': 5,
'retry_on_error': [ConnectionError],
'retry_on_timeout': True,
'health_check_interval': 0 # Handled by Redis TCP keepalive
}
}
Expand All @@ -351,6 +352,13 @@
}

# Celery
RETRY_POLICY = {
'max_retries': 10,
'interval_start': 0,
'interval_step': 1,
'interval_max': 10
}

CELERY_ENABLE_UTC = True
CELERY_TIMEZONE = "UTC"
CELERY_ALWAYS_EAGER = False
Expand All @@ -377,17 +385,17 @@
CELERY_RESULT_BACKEND_MAX_SLEEP_BETWEEN_RETRIES_MS = 10000
CELERY_RESULT_BACKEND_BASE_SLEEP_BETWEEN_RETRIES_MS = 100
CELERY_RESULT_BACKEND_MAX_RETRIES = 10
CELERY_RESULT_BACKEND_TRANSPORT_OPTIONS = {}
CELERY_RESULT_BACKEND_TRANSPORT_OPTIONS = {
'retry_policy': {
'timeout': 5.0,
}.update(RETRY_POLICY)
}
CELERY_RESULT_EXTENDED = True
CELERY_RESULT_EXPIRES = 259200 # 72 hours

CELERY_BROKER_TRANSPORT_OPTIONS = {
'visibility_timeout': 259200, # 72 hours, the longest ETA
'max_retries': 10,
'interval_start': 0,
'interval_step': 1,
'interval_max': 10
}
}.update(RETRY_POLICY)

if REDIS_SENTINELS:
CELERY_RESULT_BACKEND = ''
Expand All @@ -410,12 +418,8 @@

CELERY_TASK_PUBLISH_RETRY = True
CELERY_TASK_PUBLISH_RETRY_POLICY = {
'max_retries': 10,
'interval_start': 0,
'interval_step': 1,
'interval_max': 10,
'retry_errors': None,
}
}.update(RETRY_POLICY)

CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_ONCE = {
Expand Down

0 comments on commit 13206db

Please sign in to comment.