Taboola campaign sync parallelism (AISD-120)¶
Problem¶
SyncCampaigns enriches each campaign (creatives, audiences, postal targeting) via
a ThreadPoolExecutor. Before AISD-120, Taboola used max_workers=1, so large
accounts processed campaigns one at a time. Those runs often exceeded the
90-minute worker_timeout and were killed every cycle without finishing.
Cost numbers and campaign settings were already optimized elsewhere:
- Cost —
SyncCostuses a single batched Taboola report per account. - Settings — spapi bulk-fetches campaign detail via
campaign_idsbatches.
The remaining bottleneck was serial per-campaign enrichment on cache miss.
Fix¶
In pipes/tasks/campaign_sync.py, Taboola now uses the same per-account
enrichment concurrency as Outbrain (_CAMPAIGN_ENRICHMENT_WORKERS = 10, matching
chunk_size). Up to 10 campaigns per batch are enriched in parallel inside one
account task.
Timeouts¶
Large Taboola accounts (e.g. 635 / reportingly.com) can still exceed 90 minutes on 429-heavy hourly runs even with parallel enrichment. Taboola-only wall clocks:
| Task | Timeout | Purpose |
|---|---|---|
SyncCampaigns |
3 hours (10800s) |
Per-account backstop under API throttle |
CampaignSyncWrapper |
8 hours (28800s) |
Full batch budget; beyond this the run is stuck |
The harvester watchdog still flags idle workers (~45 min at 0% CPU) separately from these wall clocks.
429 risk¶
Higher concurrency means more simultaneous Taboola API calls. spapi retries 429s with capped backoff and a per-account circuit breaker (deployed 2026-06-24). The Redis metadata cache also reduces call volume on warm runs.
If 429 rate spikes and throughput regresses after deploy, lower
_CAMPAIGN_ENRICHMENT_WORKERS (e.g. to 5) in campaign_sync.py rather than
reverting the change.
Verification¶
On prd-harvest-08-taboola-campaign, after deploy:
- Large accounts should reach
DONEwithouttimed out after 10800 secondsinluigi-interface.logon normal 429 days. - Watch
root.logfor 429 / circuit-breaker activity. SyncCostand other providers are unchanged.