Web scraping
How do I scale a scraping setup?
Separate the parts: a queue holds the work, stateless workers fetch and parse, storage keeps results, and per-domain limits keep the whole thing polite. Then grow whichever part your measurements say is slowest.
The answer
A single script that loops over URLs stops scaling the moment it needs to run on more than one machine or survive a crash. Scaling means breaking it into pieces that can be multiplied independently: a request queue as the source of truth for pending work, many identical workers that take jobs from it, a storage layer for results, and shared limits that keep each target site at a safe request rate. Add capacity only after you know which piece is the constraint.
The building blocks
| Part | Job | Typical choices |
|---|---|---|
| Queue | pending URLs, retries, priorities | Redis lists or streams, RabbitMQ, SQS, a database table |
| Workers | fetch, solve checks, parse | containers running the same image |
| Rate control | requests per domain per second | a token bucket in Redis keyed by host |
| Storage | raw pages and parsed records | object storage for HTML, a database for records |
| Monitoring | health and cost | metrics, logs, alerts |
Make workers stateless
A worker should hold nothing that matters between jobs. It pulls a job, does the work, writes the result and acknowledges the job. If it crashes, the job returns to the queue after a visibility timeout and another worker picks it up. Stateless workers can be packed into containers and started or stopped freely, which is the core idea of containerized scraping. Keep sessions and cookies in a shared store if several jobs need them.
Concurrency inside each worker
Fetching is mostly waiting on the network, so one process can handle many requests at once with async I/O. A Python worker using asyncio with a semaphore, or a Node.js worker with a promise pool, often replaces ten threaded processes. Browsers are the exception: each one uses real memory and CPU, so size browser pools by measurement, not by guesswork. The entries on concurrency and multi-threaded scraping discuss the trade-offs.
Limit by target, not just by worker
Adding workers multiplies your request rate. Without a shared per-domain limit, ten workers hit one site ten times harder, which brings blocks, CAPTCHAs and complaints. Store a counter per host in a shared store and make every worker take a token before each request. That lets you scale total throughput across many sites while each individual site sees a steady, modest rate.
Plan for CAPTCHAs as a normal step
At scale, some share of requests will meet a challenge. Treat solving as a regular stage, not an exception path. With GateSolver, each API key allows 600 requests per minute, counting task creation and result polling, and there is no cap on concurrent tasks. A worker fleet that polls every three seconds for token tasks can therefore keep many solves in flight from one key. Watch for ERROR_RATE_LIMIT and back off briefly if you see it; the page on ERROR_RATE_LIMIT explains the budget. Keep a balance alert so a zero balance does not stall the fleet; see pricing for per-type costs.
Proxies at scale
More requests need more IP capacity. Assign proxies per target and per session rather than at random, keep sticky sessions for flows that need one identity, and track error rates per proxy so poor ones are removed. The question on proxy setups for large-scale scraping covers pool design.
Store raw, parse later
Save the raw response for each fetch alongside the parsed record. When a parser bug appears, you fix it and reparse stored pages instead of crawling again. Object storage is cheap compared with repeating a crawl, and it also helps answer "what did the page say on that date" questions.
Scale in the right order
- Measure where time goes: fetching, rendering, solving, parsing, writing.
- Fix waste first: caching, skipping unchanged pages, avoiding browsers where an API works.
- Add concurrency inside workers before adding machines.
- Add workers, and raise per-domain limits only where the target site handles it comfortably.
The companion pages on pipeline architecture and monitoring in production fill in the remaining pieces.
Common questions
Do I need Kubernetes to scale a scraper?
No. A queue plus a handful of containers on one or two servers carries a lot of work; orchestration helps later.
How many concurrent CAPTCHA tasks can I run?
Concurrency is unlimited; what is capped is 600 API requests per minute per key, polling included.
Should every worker have its own API key?
No. GateSolver gives one API key per account, so share it and budget the request rate across workers.
What is the most common scaling mistake?
Adding workers without a shared per-domain rate limit, which multiplies load on each target and triggers blocks.
Why store raw HTML?
It lets you rerun fixed parsers on old pages without crawling again, and it documents what the site showed.
Keep reading
- Request queueThe list of URLs a crawler still has to visit, with retries, priorities and deduplication built into how it is stored.
- Containerized scrapingPackaging scrapers and their browsers into containers so the same worker runs anywhere and scales out by adding copies.
- What does a solid scraping pipeline look like?Discovery, fetching, parsing, validation and delivery as separate stages, joined by queues and storage so each can fail safely.
- What CAPTCHA solving costs at scaleA method for estimating CAPTCHA spend from your own volumes: per 1,000 math, mixed workloads, and how far one top-up goes.