File size: 1,198 Bytes
bdaeeeb
 
 
 
 
 
27cbb3d
 
 
 
 
 
 
 
bdaeeeb
 
 
 
a0f1a88
bdaeeeb
 
 
 
 
 
 
 
27cbb3d
 
 
 
 
 
 
 
 
 
 
 
 
bdaeeeb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
from celery import Celery
from ..config import get_settings

settings = get_settings()

# Connection pool options
_REDIS_TRANSPORT_OPTS = {
    "max_connections": 10,
    "socket_keepalive": True,
    "socket_connect_timeout": 10,
    "retry_on_timeout": True,
}

celery_app = Celery(
    "talentpulse",
    broker=settings.redis_url,
    backend=settings.redis_url,
    include=["src.workers.ingest", "src.workers.explain"],
)

celery_app.conf.update(
    task_serializer="json",
    accept_content=["json"],
    result_serializer="json",
    timezone="UTC",
    enable_utc=True,
    
    # ----------------------------------------------------
    # FREE TIER REDIS OPTIMIZATIONS (Max 30 Connections)
    # ----------------------------------------------------
    worker_send_task_events=False,        # Disable task events (saves connections)
    worker_enable_remote_control=False,   # Disable mingle/broadcast (saves 2 conns per worker)
    task_track_started=False,             # Disable state tracking noise
    result_expires=1800,
    
    # Limit broker & backend pool
    broker_transport_options=_REDIS_TRANSPORT_OPTS,
    redis_max_connections=10,
    broker_pool_limit=10,
)