A bulk job has sent a long list of requests and only a fraction of the responses have come back. Nothing has errored yet, but the queue inside your worker pool keeps growing, memory creeps up, and the retry counter has started to tick. You set the pool to 50 because the plan allows 5 requests per second and 50 sounded conservative. It wasn't.
Concurrency isn't a dial you turn up until something breaks. It's occupied capacity. Every call in flight holds a socket, a slot in your worker pool, a buffer for the response, and a matching slot somewhere on the provider's side. The number that matters isn't how many calls you can fire. It's how many you can keep in flight and still finish, at the latency you get rather than the latency you hoped for.
The short answer, before the detail: run roughly your target requests per second multiplied by your P95 latency, then add about 25 percent headroom. Everything below is about why that holds, where it breaks, and how to defend it under retries, fan-out and multi-tenant load.
Table of Contents
- What API Concurrency Means for Your Requests
- Concurrency Limits Versus Rate Limits Compared
- How to Calculate a Safe Concurrency Limit
- Implementing a Bounded Worker Pool in Code
- Handling 429 Responses and Retry Storms
- Bounding Parallel Calls with Queues and Fair Shares
- Measuring Useful Concurrency Before You Scale
- Set Your Concurrency Limit Before Launch
What API Concurrency Means for Your Requests
Think of a shop with a door that admits one customer every three seconds. That door is a rate limit: it governs arrivals. Concurrency is how many customers are inside the shop being served at the same moment. A shop with one till and a queue out the door, and a shop with ten tills and the same door policy, are entirely different businesses, and the door policy alone tells you nothing about which one you're running.
Count concurrency from the moment a request leaves your code until the full response has arrived. At 10 requests per second with a 1 second response time, about 10 calls are in flight at any instant. Push the same rate against a 1.5 second P95 and the in-flight count climbs to roughly 15. Same rate limit, 50 percent more occupied capacity.

The separation between holding connections open and finishing work is old. Software engineer Dan Kegel formalized it as the C10k problem in 1999, framed as supporting 10,000 clients concurrently on a single server, and cited the Simtel FTP host cdrom.com as a system reportedly serving 10,000 clients at once over a 1-gigabit-per-second Ethernet link (Wikipedia's C10k entry). The framing still holds: concurrency is scheduling and resource management, throughput is how quickly work completes.
Volume makes the stakes concrete. Salt Security's 2024 State of API Security Report found that 67% of surveyed organizations handled more than 10 million API requests per month (Salt Security). Monthly volume says nothing about how many of those requests land in the same second.
Live data APIs feel this harder than cached ones. Each call fetches the record at the moment of the request, so there's no shared cache to absorb a burst and no snapshot to serve while a backend catches up. Every in-flight call holds a connection, a response buffer and a worker slot on your side, and a matching slot on the provider's.
The same arithmetic governs any system that opens a line and waits. Teams handling compliant outbound calling during peak demand size their dialers from answer times and agent availability for exactly this reason: a fixed number of slots, filled by work that takes unpredictable time.
So take a list of 50,000 professional profile URLs to enrich. How many should run at once? Not 50,000, and not the published rate limit either. The number comes from your measured latency, and by the end of this you'll be able to name which of your limits you're hitting.
Concurrency Limits Versus Rate Limits Compared
| Concept | What It Limits | Typical Unit | Where It Shows Up | What Happens When Exceeded |
|---|---|---|---|---|
| Concurrency limit | Requests in flight at the same moment | Simultaneous calls | Client semaphore, HTTP/2 stream setting, API gateway | Calls queue, time out or get throttled |
| Rate limit | Requests started within a time window | Requests per second | Provider rate policy, API gateway | HTTP 429 Too Many Requests |
| Throughput | Successful work completed over time | Successful calls per second | Measured by your own pipeline | Falls as latency rises, even when the rate is unchanged |
| Burst capacity | Short spikes above the steady rate | Calls within a few seconds | Provider burst allowance | A spike returns 429 even when the daily average is low |
| Account allowance | Total usage over a billing period | Calls or credits per period | Account dashboard | Calls stop or the account needs a larger allowance |
The two middle columns of that table get conflated constantly. A pool of 20 workers where each call finishes in half a second sends 40 requests per second. The same 20 workers against a 2 second response time send 10. The concurrency cap never moved, the rate collapsed. That's why a concurrency limit doesn't protect you from a rate limit, and a rate limit doesn't stop worker slots filling when responses slow down.
Why HTTP/2 Didn't Remove the Ceiling
HTTP/2, standardized in RFC 7540 in May 2015 and updated by RFC 9113 in June 2022, changed the mechanics by letting multiple request and response exchanges share a single TCP connection (HTTP Working Group). Each exchange becomes an independent stream and frames interleave across streams, so parallel requests no longer need a connection each. The protocol also defines SETTINGS_MAX_CONCURRENT_STREAMS, and RFC 9113 recommends a value of at least 100 where possible so parallelism isn't needlessly restricted.
That's a protocol ceiling, not your quota. A provider can impose stricter application limits based on authentication, account tier, backend capacity or operational policy. You can open a hundred streams and still get queued, timed out or throttled. Reading published policy correctly matters here, and how API rate limits work is a reasonable primer before you size anything.
Effective concurrency is set by the smallest constraint across your client, the network, the protocol, the gateway and the downstream data systems. Find that constraint first. The mechanics of per-second ceilings versus per-window quotas are worth reviewing in API rate limit mechanics before you assume one number governs every endpoint.
The counterintuitive part: past a certain pool size, adding more parallel calls lowers throughput. Requests queue, latency rises for every call, and the completed count per second drops while your send count keeps climbing.
Count completed successful work, not requests sent. That single change in measurement usually explains why a bigger pool made things worse.
How to Calculate a Safe Concurrency Limit
The rule underneath all of it: calls in flight equal target rate multiplied by response time. Everything else is measurement discipline.
Concurrency is occupied capacity. Every parallel slot you open is a seat someone is sitting in for the full length of their call, and while they sit there, that slot serves nobody else. Retries occupy extra seats. Slow responses hold seats longer. A queue that feeds a full pool does not create capacity, it just parks the overflow. So the right pool size comes from your measured latency, not from the biggest number the provider publishes.

- Measure median and P95 latency per endpoint, over at least one full day of normal traffic, kept separate from bulk job traffic. Bulk jobs distort the sample because they run at a different pool size than production features do.
- Pick the target rate you need, say 20 requests per second, and keep it comfortably under the published ceiling. The ceiling is a maximum, not a target.
- Multiply target rate by P95 latency, not the median, to get the in-flight count during the slow tail. The median is where nothing interesting happens.
- Add 25 percent headroom for retries and outliers. A retry occupies a second slot while the first call is still pending, so a pool sized to the exact in-flight count has nowhere to put the duplicate.
- Set the worker pool and semaphore to that number, not to the full rate limit. Setting the pool to the published rate leaves no room for anything to go wrong.
- Run a ramp test. Double the pool, watch P95 latency and error rate, and stop at the first sign the queue is growing. The queue is the earliest warning you'll get.
| Target Rate | In-Flight at 1.0 s Median | In-Flight at 1.5 s P95 | Suggested Pool With 25% Headroom |
|---|---|---|---|
| 5 requests per second | 5 | 8 | 10 |
| 20 requests per second | 20 | 30 | 38 |
| 100 requests per second | 100 | 150 | 188 |
Take the middle row. You need 20 requests per second, your P95 is 1.5 seconds, so about 30 calls sit in flight during the slow tail. Round up with headroom and you run a pool of 38, not 100 and not 20.
That gap between 38 and the published ceiling is the entire point. If your plan allows 100 requests per second and you size the pool to 100, every slot is spoken for on a normal day. The first retry storm or latency spike arrives and there is nowhere to absorb it. Calls pile into the queue, wait times stretch, and each queued call ages toward its own timeout while still holding its place in line.
Practical rule: the median tells you what a good day looks like. Size the pool for the day the P95 turns into the median.
A healthy run looks boring. Latency stays flat as the pool grows, the 429 count is zero or explained, and the completed-successful count per second holds steady at the rate you planned for. If latency climbs while completions flatten, you've passed the point where the pool was helping. Shrink it back to the last size where latency held, because every slot beyond that point is capacity you are paying for in wait time without getting throughput in return.
Implementing a Bounded Worker Pool in Code
In Python, one semaphore per endpoint, acquired before the request and released when the response or the deadline arrives:
POOL = 38
sem = asyncio.Semaphore(POOL)
async def fetch(session, url):
async with sem:
for attempt in range(4):
try:
async with session.get(url, timeout=5) as r:
if r.status == 429:
wait = float(r.headers.get("Retry-After", 2 ** attempt))
await asyncio.sleep(wait + random.random())
continue
r.raise_for_status()
return await r.json()
except (asyncio.TimeoutError, aiohttp.ClientError):
await asyncio.sleep(2 ** attempt + random.random())
return None
The timeout=5 is the per-call deadline. Without it, a stalled response holds a slot indefinitely and the pool drains one call at a time.
In JavaScript, the equivalent is a fixed set of workers pulling from one shared queue:
const queue = [...urls];
const worker = async () => {
while (queue.length) await handle(queue.shift());
};
await Promise.all(Array.from({ length: 38 }, worker));
The failure mode to avoid is Promise.all(urls.map(handle)) over 50,000 URLs. That starts every call at once, fills the pool in milliseconds and buries the actual limit under a wall of 429s. Results belong in a bounded output queue, and anything deferred gets written to a record for a later pass. Choosing between synchronous and asynchronous API delivery determines whether that later pass is a retry or a scheduled job.
Pre-launch checklist: one semaphore per endpoint, a deadline on every call, backoff on every 429, and live counters for in-flight and completed calls.
Handling 429 Responses and Retry Storms
HTTP 429 is the standardized response for rate limiting. It means the client sent too many requests within a given period. RFC 6585 recommends the response explain the condition and permits a Retry-After header telling the client how long to wait (RFC 6585). The spec's own example: a server allowing 50 requests per hour returns Retry-After: 3600, so the client waits 3,600 seconds.
The RFC doesn't prescribe how a service identifies clients or counts requests. A limit may apply per resource, across a whole server, or across a group of servers, identified by credentials or a stateful cookie. So don't assume one global counter or one fixed window covers every endpoint.
The rule: read Retry-After first, sleep for exactly that long, and only then consider your own backoff logic.
When the header is missing, back off exponentially with jitter. Never retry immediately, and never let a retry loop outlive the deadline of the request that triggered it.
Why Fan-Out Breaks the Average
A single agent request can spawn dozens of parallel tool calls. Your dashboard averages look safe because they smooth the burst across the minute, while instantaneous concurrency exhausts the provider's capacity in the two seconds where the fan-out lands. That gap between average and peak is where retry storms begin. Every worker gets a 429 at the same moment, every worker retries on the same schedule, and the retry wave hits the server as a second, larger burst. Without jitter the wave re-forms at each backoff interval, so a spike that would have cost you one round of 429s now costs you four or five. Each failed wave also occupies slots in your worker pool while sleeping, which starves fresh work that never touched the limit.
The defensive pattern is unglamorous. Exponential backoff with jitter, a fixed retry count inside a total deadline, a per-tenant retry budget so one workload can't spend everyone else's attempts, and cancellation when the caller has already moved on. Providers also publish quota information through RateLimit-Policy and RateLimit headers, and the draft standard specifies that Retry-After takes precedence when both appear (HTTPAPI RateLimit headers draft). Parse Retry-After first, then use the advertised quota for pacing and pool sizing.
| Response | What It Signals | Worker Action |
|---|---|---|
| 429 with Retry-After | Rate limit reached and a wait time given | Wait the stated seconds, then resume at a lower pool size |
| 429 without Retry-After | Rate limit reached with no wait time | Back off exponentially with jitter and reduce the pool |
| Timeout on a synchronous call | Response missed the client deadline | Retry only if the call is safe to repeat, otherwise defer |
The last row matters more than it looks. A retry on a call that already mutated state can duplicate work, while deferring it to a later pass costs nothing but time. I treat any non-idempotent call as defer-by-default and whitelist the safe exceptions, because the reverse default is what turns a timeout into a data problem.
A 429 rate-limited response means you went over your requests per second, and the right response is a short backoff before retrying. Note the ceiling that no amount of budget changes: every self-serve option, subscription or pay as you go, runs at 5 requests per second, and buying more credits does not move it. Pace below 5 per second regardless of your credit balance, and treat a sustained stream of 429s at that ceiling as a signal to shrink the pool rather than retry harder. The mechanics of exponential backoff with jitter are worth getting exactly right, because a retry storm is usually a backoff bug rather than a capacity problem. If you run headless browser automation alongside the API calls, identity coherence for Playwright scrapers covers that separate failure surface, since session blocks there look nothing like a 429 and need their own handling.
Bounding Parallel Calls with Queues and Fair Shares
An unbounded queue is a memory leak with extra steps. It accepts work faster than the pool can drain it, grows until the process dies, and gives you no signal until the crash. A bounded queue rejects or defers at a fixed size, which turns an outage into a measurable event you can alert on.

Admission control is the gate in front of the pool. Pair a semaphore per endpoint with a separate budget per tenant, so one large customer cannot occupy every slot while a smaller one waits. The reasoning is straightforward once you treat concurrency as occupied capacity: every in-flight call holds a worker slot for its full duration, and a call that will time out in 30 seconds locks that slot for 30 seconds whether or not it ever returns anything. Long-running or throttled requests are therefore the expensive ones, and fair scheduling exists to stop them from starving everyone else. When latency stretches, the correct response is shrinking the pool or shedding work, because adding workers against a slowing endpoint just converts spare slots into occupied ones.
Splitting the Pool Between Interactive and Background Work
Give background work a fixed share of the pool and let interactive traffic keep the rest. A signup flow waiting on a profile lookup needs a slot within a second or two, which is realistic when the API's median response time is 1 second and its P95 is 1.5 seconds. A nightly refresh of 50,000 records can wait.
pool total: 38
interactive reserve: 12 (signup, search, in-app lookups)
background reserve: 20 (nightly refresh, backfill)
shared overflow: 6 (either side, whichever is idle)
Reserves beat a single shared counter because a backfill job will always win a race against a user waiting on a page load. At a median of 1 second per call, the background reserve of 20 slots moves roughly 20 records per second when it is fully saturated, so the nightly job finishes on schedule without ever touching the interactive reserve. The split makes the priority explicit instead of hoping scheduling works out. Tune the numbers by watching how often the interactive side dips into the overflow: frequent borrowing means the reserve is too small, an idle overflow means you sized it out of caution rather than measurement.
Synchronous calls need a strict deadline and real cancellation, because a caller is blocked on the other end. Asynchronous delivery suits long-tail work, provided its queue is bounded and monitored, and provided you record what got deferred so a later pass can pick it up. There is no separate batch API and no job queue to poll here: calls run concurrently up to the rate limit, which means the queue, the scheduler and the retry bookkeeping are yours to build.
Shedding rule: when the pool is full, drop or postpone the least important enrichment first, and log what you deferred. Shedding in priority order beats dropping whatever happened to arrive last.
One more constraint on what you keep. Public availability does not remove privacy obligations. An official European Commission comparison guide states that GDPR personal data includes publicly available information, and that a controller collecting personal data from a publicly available source remains subject to GDPR requirements (European Commission comparison guide). Your queue log should therefore record which records were fetched, for what purpose, and how long you retain them. Since the API fetches each profile record at the moment of the request and stores nothing between calls, your own log is the only retention surface you control, which makes it the right place to enforce those limits.
Measuring Useful Concurrency Before You Scale
Define the metric precisely: useful concurrency is successful completions per second at a given pool size. Optimise that, not the number of requests sent. The two diverge the moment queueing starts.
Watch six signals together:
- In-flight count against the pool, which tells you how often every slot is occupied.
- Queue depth and wait time, the earliest indicator that arrivals outpace completions.
- P50 and P95 latency per endpoint, tracked separately because a fast profile call and a slower company call need different pools.
- 429 rate as a share of total calls, which should sit near zero in steady state.
- Retries per successful call, which exposes hidden load your send counter doesn't show.
- Deadline misses, the calls that consumed a slot and returned nothing usable.

Benchmark endpoint by endpoint. Run each one at 5, 10, 20 and 40 concurrent calls for ten minutes apiece, and plot completions per second against pool size. Every endpoint has a shape, and the shapes don't match.
The Knee of the Curve
Somewhere on that plot the line bends. Before the knee, more parallelism buys more completions. After it, queueing adds latency to every call and the completed count falls while CPU stays pinned. I'd rather run a pool slightly under the knee than at it, because the knee moves when the provider has a slow afternoon.
That argues for an adaptive pool rather than a fixed one. Reduce the pool when P95 rises past a threshold you set, then increase it slowly while latency stays flat. It protects your service level objectives better than any number you pick once and forget.
Alert thresholds that earn their pager: P95 latency up 50 percent from its seven-day baseline, or 429s above a small share of calls for ten straight minutes. Both mean the pool is saturated, not that the provider is broken.
Set Your Concurrency Limit Before Launch
Five steps, in order, before real traffic arrives.
First, pick a starting pool from the sizing method: measured P95 latency times target rate, plus 25 percent headroom. Second, confirm the rate ceiling of the plan you're on and pace below it, so the pool can't outrun the allowance. Third, decide which endpoints run synchronously and which run asynchronously, and put a fixed size on every queue in the path.
Fourth, rehearse failures in staging. Force one 429 with a Retry-After header and one timeout, then confirm your backoff, retry budget and cancellation behave as designed. A retry path nobody has exercised is a retry path that doesn't work. Fifth, check that the in-flight count and 429 rate in your own monitoring match what your workers send before you scale traffic. If those two numbers disagree, fix the instrumentation before you tune the pool.
If a workload later needs more sustained throughput than the plan allows, treat it as a planned change backed by measured numbers rather than adding workers. Dedicated higher-throughput capacity is provisioned in 2 to 5 business days and is set up with Fetchin rather than bought in one click. Custom terms, a service level agreement, or a plan built around your usage are arranged through Fetchin the same way.
Commit to a pool size you measured, write it into configuration with a comment explaining where the number came from, and schedule a review after the first full week of traffic. Compare completed successful calls per second against the pool size you chose. That comparison is the only evidence that matters.
Fetchin turns professional profile and company URLs into structured JSON with a 1 second median and 1.5 second P95 response time, which means the pool sizing above lands on numbers you can measure rather than guess. Calls run concurrently up to your rate limit, with synchronous responses by default and asynchronous delivery when a workflow needs to absorb a long tail. If you're planning a bulk enrichment job, visit Fetchin to see the endpoints and rate limits before you pick a pool size.



