Files
Priceflow/app
Claude 10cdfcef5a fix: Add concurrency limits to prevent Browserless timeout saturation
**Problem:**
Search was launching ALL sites in parallel without any limit, causing Browserless
to be overwhelmed with simultaneous connections and timeout:
- 7 active sites = 7 parallel Browserless connections
- Each site scraping multiple products in parallel
- Result: "Timeout 60000ms exceeded" errors
- Most searches failed with 0 results

**Root Cause:**
```python
# search_service.py:489 (before fix)
for gen in generators:
    asyncio.create_task(producer(gen))  # ❌ ALL sites at once
```

With 7 sites × 3 products each = up to 21 concurrent Browserless connections.

**Solution: Two-Level Concurrency Control**

1. **Global Site Limit** (search_service.py:476)
   - Added `site_semaphore = asyncio.Semaphore(2)`
   - Max 2 sites can search in parallel
   - Others wait for a slot to free up
   - Example: 7 sites → only 2 active at a time

2. **Per-Site Product Limit** (search_service.py:306)
   - Reduced from `Semaphore(3)` to `Semaphore(2)`
   - Max 2 products scraped in parallel per site
   - Less pressure on Browserless

**Impact:**
- Before: 7 sites × 3 products = 21 concurrent connections ❌
- After: 2 sites × 2 products = 4 concurrent connections ✅
- 80% reduction in concurrent load on Browserless

**Flow:**
```
7 sites requested
  ↓
2 start searching (sites 1, 2)
5 wait in queue (sites 3-7)
  ↓
Site 1 completes → Site 3 starts
Site 2 completes → Site 4 starts
  ↓
Process continues until all sites done
```

**Expected Results:**
✅ No more Browserless timeout errors
✅ All sites complete successfully
✅ Sequential processing prevents saturation
✅ Search returns results from all sites

Fixes issue where search returned "Found 0 results" for most sites
due to Browserless connection timeouts.
2025-11-29 23:31:43 +00:00
..
2025-11-22 10:01:25 +01:00
2025-11-22 10:01:25 +01:00
2025-11-22 10:01:25 +01:00
2025-11-22 10:01:25 +01:00