ProxyTee
Scrapy 429Scraper FrameworkSeverity: Medium

Fix Scrapy 429 & AutoThrottle Stalls

Prevent Scrapy spiders from dropping items after RETRY_TIMES=2 on HTTP 429 by pairing round-robin port middleware, AutoThrottle tuning, and retry HTTP codes.

Debug Scrapy 429 with AI:

1. Quick Wire-Level Diagnostic Probe

Confirm Scrapy picks up request.meta['proxy'] cleanly before running full multi-port spider crawls.

scrapy shell -s HTTPPROXY_ENABLED=True "https://api.ipify.org?format=json"
Failure Signatures

Common Symptoms

  • Scrapy logs 'Gave up retrying ... (failed 3 times): 429 Too Many Requests'
  • AUTOTHROTTLE_ENABLED drops crawl speed from 30 req/s down to 0.2 req/s permanently
  • Spider completes early with 40–70% missing items

2. Primary Root Causes

Default RETRY_TIMES=2 Exhaustion

When a single proxy port hits a brief rate limit, 2 immediate retries reuse the same IP and drop the request.

Single Proxy Middleware Bottleneck

Setting one static request.meta['proxy'] routes all CONCURRENT_REQUESTS through a single exit IP.

Unadjusted DOWNLOAD_DELAY & AutoThrottle

Bursting 16–32 concurrent requests per domain triggers target WAF rate limits before AutoThrottle stabilizes.

3. Step-by-Step Remediation Checklist

1

Rotate Across Multiple ProxyTee Ports in Middleware

Load your list of 5–25 ProxyTee port URIs into a custom downloader middleware and assign random.choice(PROXIES) per request.

2

Tune RETRY_HTTP_CODES & RETRY_TIMES

Ensure 429, 502, and 503 are in RETRY_HTTP_CODES and increase RETRY_TIMES = 6 so retries rotate onto fresh ports.

3

Calibrate CONCURRENT_REQUESTS_PER_DOMAIN

Keep per-domain concurrency aligned with your port count (e.g., 2–3 concurrent requests per port) for steady throughput.

4. Production Fix Code (Scrapy Rotating Multi-Port Middleware & Settings)

python
# settings.py
RETRY_ENABLED = True
RETRY_TIMES = 6
RETRY_HTTP_CODES = [429, 500, 502, 503, 504, 408]
CONCURRENT_REQUESTS = 16
AUTOTHROTTLE_ENABLED = True
AUTOTHROTTLE_START_DELAY = 0.5
AUTOTHROTTLE_TARGET_CONCURRENCY = 4.0

# middlewares.py
import random

class ProxyTeePoolMiddleware:
    PORTS = [
        "http://user:pass@gate.proxytee.com:8081",
        "http://user:pass@gate.proxytee.com:8082",
        "http://user:pass@gate.proxytee.com:8083",
    ]
    def process_request(self, request, spider):
        request.meta["proxy"] = random.choice(self.PORTS)

Other Network & Proxy Error Runbooks

Scrapy 429 Troubleshooting FAQs

Scrapy's built-in HttpProxyMiddleware handles http:// and https:// proxies natively. For SOCKS5, use an HTTP ProxyTee port endpoint or install scrapy-socks / Twisted SOCKS5 support.