2. Domain 2: Production Integration, Reliability, and Knowledge Grounding

2.2. 2.2 Scale and throughput: rate limits, backpressure, tenant quotas and batch pipelines

CCDV-P · Domain 2 · Lesson 2.2 · 20 min read

How Claude rate limits count, how to find the binding constraint, and how queues, tenant quotas and batches stop one big customer starving the rest.

Why one district's homework took down 400 schools

Atlas Learning Cloud sells an essay-feedback service to schools. A student submits an essay, Claude reads it against the teacher's rubric, and feedback comes back in a few seconds. About 400 schools and small districts use it every school day, at a peak of roughly 450 essays a minute. All of it runs through one Anthropic organization and one set of limits.

Then Lakemoor Unified, Atlas's largest customer, signed on. In the week before term reports its teachers uploaded 900,000 essays in one go, and Lakemoor's import job pushed them into the same request path with 200 parallel workers. Within minutes, students at the 400 smaller schools got rate-limit errors, and the retry logic made the pile-up worse. It lasted most of two days.

Nothing was broken. Every component did exactly what it was built to do: the import job sent as fast as it could, the API enforced Atlas's limits, and the first sender to reach the limit got the capacity. What Atlas lacked was a design for throughput: knowing which limit binds, deciding who gets capacity when demand exceeds it, and moving work that can wait onto a path built for waiting. Rafa, the infrastructure engineer on call that week, now owns that design.

Three meters and a bucket: how Claude rate limits work

When the API says "rate limited", which limit does it mean? Claude's Messages API meters each model class on three dimensions at once: requests per minute (RPM), input tokens per minute (ITPM) and output tokens per minute (OTPM). They are set at the organization level by your usage tier, and exceeding any one of them returns HTTP 429 with error type rate_limit_error, naming the limit you hit.

The limits refill continuously rather than resetting on the minute. The API uses a token bucket: think of a water tank with a steady tap and a size cap, so you can draw a burst if the tank is full, then only as fast as the tap refills it. A limit of 60 RPM may be enforced as one request a second, so a burst can trip a limit your average never reaches.

Two counting rules decide most capacity plans. First, ITPM is cache-aware: uncached input_tokens and cache_creation_input_tokens count, but cache_read_input_tokens do not. Second, OTPM counts the output tokens actually generated, and max_tokens plays no part, so a generous output ceiling costs no throughput.

A third kind of 429 catches teams in the week they need capacity most. A ramp limit caps how fast your token usage on a model may grow: roughly your recent per-minute peak plus a step, rising as successful usage grows. After a sharp jump, requests can fail while you are still under ITPM and OTPM, and the response carries error_code: "ramp_limit_exceeded" in its error.details.

Meter What counts toward it What loosens it
RPM Every request, whatever its size Fewer, larger requests; a higher tier
ITPM Uncached input plus cache writes; cache reads are free Prompt caching of the shared prefix; a higher tier
OTPM Output tokens actually generated Shorter outputs; a higher tier
Ramp limit Growth in tokens per minute over the recent peak Ramping up gradually; it rises as successful usage grows
Monthly spend cap Spend this calendar month A higher tier; otherwise requests stay blocked until next month

Memorise the first three rows and the cache rule. Recognise the last two by their signature: a ramp-limit 429 says ramp_limit_exceeded, and a spend-cap 429 says enforced_spend_limit_reached and carries no retry-after header, so retrying it is pointless. Every response also reports your position through anthropic-ratelimit-requests-remaining, anthropic-ratelimit-input-tokens-remaining, anthropic-ratelimit-output-tokens-remaining and their -limit and -reset partners.

Capacity planning: find the binding constraint before the traffic does

"We hit rate limits" is a symptom, not a diagnosis. Before changing anything, Rafa asks which of the three meters runs out first at the traffic Atlas expects. That meter is the binding constraint, and only a change that loosens it raises throughput.

The method is arithmetic. Take tokens per unit of work from real usage records, multiply by the forecast rate, and divide by each limit. An Atlas feedback call reads a 2,000-token rubric and instructions prefix from the cache, about 1,000 uncached tokens of essay and task, and writes about 500 tokens of feedback. Atlas's limits for its feedback model are 4,000 RPM, 2,000,000 ITPM and 400,000 OTPM.

Meter Per essay Ceiling in essays per minute Use at today's 450 a minute
RPM 1 request 4,000 11%
ITPM 1,000 uncached tokens 2,000 23%
OTPM 500 output tokens 800 56%

Output binds, at 800 essays a minute. That changes the advice. Adding caching would not help, because ITPM has room to spare. Lowering max_tokens would not help either, because OTPM counts what the model writes, not the ceiling. What helps is a tighter feedback format that writes fewer tokens, or a higher limit. The cache is already doing its job: without it each essay would count 3,000 input tokens and ITPM would bind at about 667 a minute.

Which constraint binds at Atlas?

More retriesthe 429s are the symptom, not the cause
Lower max_tokensOTPM ignores the ceiling
More cachingITPM sits at 23%
Larger tier for everythingmay be needed, but it is not the first lever
OTPM binds at 800 a minuteshorten output, then plan a limit increase
Only the meter that runs out first limits throughput, so the fix must loosen that one.

Capacity planning runs the same table on the forecast, not on today. Atlas expects interactive traffic to double in report week, to about 900 essays a minute: 450,000 output tokens a minute, above the OTPM limit before Lakemoor sends a single essay. Rafa sets a working ceiling of 80% of each limit, trims the feedback format to about 350 tokens (79% at 900 a minute), and requests a higher limit through the Console's Rate limits page well before term ends. He also checks the monthly spend cap and any workspace spend limit, because a plan that fits the per-minute limits can still stop on spend.

The guide frames the diagnosis as three possible answers. If a per-minute rate limit binds, you pace, cache or shorten to fit it, or raise it. If raw token throughput binds even after that, you need more capacity or less work per request. And if the work has no realtime deadline at all, the binding constraint is batch economics: the question is no longer "how fast" but "how cheap within the deadline", and the answer sits outside the realtime limits altogether.

Queueing, backpressure and priority classes

Atlas's bad week in one sentence: whoever sent fastest got the capacity. Without a queue, the API's limit becomes your scheduler, and it schedules by speed of arrival. The fix is to stop letting callers talk to the API directly and put a dispatcher in between: a service that accepts work, queues it, and sends it at a rate it controls.

Three mechanisms make the dispatcher work. Admission control decides whether a request may join the queue at all, using a per-tenant quota. Priority classes decide who goes next: Atlas runs three, interactive (a student waiting on screen), same-day (a teacher's class set) and bulk (imports and backfills). Pacing sends from the queue below the API limits, using a local token bucket sized to Atlas's 80% working ceiling and corrected by the anthropic-ratelimit-*-remaining headers on every response.

Atlas's dispatcher

ADMITper-tenant quota, else 429 or 202 with an ETA
QUEUEinteractive, same-day, bulk
PACElocal bucket at 80% of each limit
SENDrealtime calls, headers fed back to PACE
DIVERTbulk with no realtime deadline goes to batch
Work is admitted per tenant, queued by priority and paced below the limit, so a full queue pushes back on the sender instead of turning into 429s.

Backpressure is what happens when the queue fills: the dispatcher tells producers to slow down instead of absorbing work it cannot finish. For Lakemoor's import API that means answering "accepted, here is your position and estimated time" for work it can schedule, and refusing with its own 429 and a retry-after once the tenant's queue share is full. Without it the queue grows, everyone's latency climbs, and callers time out and resubmit, adding load when there is none to spare.

Priority must not mean strict priority. If interactive work always goes first, a busy afternoon starves the bulk class forever. Atlas gives each class a guaranteed share of the paced rate (interactive 60%, same-day 25%, bulk 15%) and lets any class borrow what another leaves unused. Inside a class, tenants are served in turn, not by arrival, so one tenant's 900,000 essays cannot sit in front of another school's thirty.

Anthropic once sold a Priority Tier capacity commitment. It is now legacy and no longer sold, so for a design today, priority is something your dispatcher implements, not something the API grants.

Tenant isolation: workspaces and per-tenant quotas

The dispatcher shares capacity fairly, but it lives in Atlas's code. Rafa also wants a limit Anthropic's API enforces, so that a bug in the dispatcher or a forgotten script cannot spend the whole organization's budget. That is what workspaces provide: subdivisions of an organization with their own API keys, resources, and optional spend and rate limits.

A workspace rate limit is set per meter (RPM, ITPM, OTPM) and per model, in the Console or through the Rate Limits API. Two rules decide how to use it. A workspace limit is a CEILING, not a reservation: capacity a workspace does not use stays available to the others. And organization-wide limits always apply, even if the workspace limits add up to more. So you protect a group of tenants by capping the workspace that could flood them, not by trying to promise each one a slice.

Atlas's organization after the redesign

Organization limits4,000 RPM, 2M ITPM, 400K OTPM
feedback-liveinteractive and same-day, no cap below the org
feedback-bulkcapped at 30% of each limit; owns the batches
dev-and-evalcapped low, never touches production
The organization limit applies to all traffic; the bulk workspace is capped so interactive feedback always keeps headroom.

Should each of the 400 schools get its own workspace? It is tempting, and the default allowance of 1,000 workspaces per organization would fit them. Resist it for this workload. Prompt caches are isolated by workspace, so the shared rubric prefix would be cached 400 times over, cache hit rates would fall, and uncached input tokens would climb toward the ITPM limit. A per-workspace cap also cannot lend a quiet school's share to a busy one. Use coarse workspaces for blast radius and fine per-tenant quotas in the dispatcher.

Per-tenant quotas in the dispatcher are plain counters keyed by tenant: tokens per minute and concurrent requests, sized by contract tier, with a burst allowance. Atlas tags every request with the tenant id it served and records usage from each response, so quotas, cost allocation and noisy-neighbour alerts share one set of numbers. Each response also carries an anthropic-workspace-id header, which lets Rafa confirm that bulk traffic really counted against the bulk workspace.

Batch pipelines for work that can wait

Lakemoor's essays were needed before report cards, days away. Sending them through the realtime path was the root error: a deadline of days competed with a deadline of seconds for one per-minute budget. The Message Batches API is the path built for this work: you submit many Messages requests at once, they are processed asynchronously, and you collect the results later.

The facts that shape a pipeline:

  • PRICE. Batch usage costs 50% of standard prices, on input and output alike, and it stacks with prompt-caching discounts.
  • TURNAROUND. Most batches finish within an hour, but nothing is promised under 24 hours. A batch that has not finished by then expires, and its unprocessed requests come back with result type expired and are not billed.
  • SIZE. One batch holds up to 100,000 requests or 256 MB, whichever comes first.
  • LIMITS. Batches have their own rate limits, shared across models: HTTP requests per minute to the batch endpoints and a cap on batch requests waiting in the processing queue. Batch usage does not affect your Messages API rate limits, and batches are not subject to ramp limits.
  • RESULTS. Results can come back in any order, so each request carries a custom_id (1 to 64 letters, digits, hyphens or underscores) to join them up. Each result is succeeded, errored, canceled or expired, and results stay downloadable for 29 days.

Rafa's import job now splits Lakemoor's upload into chunks of 100,000 and never has more queued than Atlas's processing-queue limit of 200,000 requests. Look at the custom_id line, which encodes tenant and essay, and the queue check, which is backpressure the pipeline applies to itself.

import anthropic
from anthropic.types.message_create_params import MessageCreateParamsNonStreaming
from anthropic.types.messages.batch_create_params import Request

client = anthropic.Anthropic()          # key scoped to the feedback-bulk workspace
CHUNK, QUEUE_LIMIT = 100_000, 200_000   # max per batch; Atlas's processing-queue limit

def submit_tenant(tenant_id, essays):
    for start in range(0, len(essays), CHUNK):
        chunk = essays[start:start + CHUNK]
        wait_until(lambda: queued_requests() + len(chunk) <= QUEUE_LIMIT)  # self-imposed backpressure
        batch = client.messages.batches.create(requests=[
            Request(custom_id=f"{tenant_id}-{e.id}",   # join results by id, never by position
                    params=MessageCreateParamsNonStreaming(
                        model=FEEDBACK_MODEL, max_tokens=1024,
                        system=RUBRIC_BLOCKS,          # identical cached prefix in every request
                        messages=[{"role": "user", "content": e.text}]))
            for e in chunk])
        record_batch(tenant_id, batch.id)            # poll until processing_status == "ended"

When a batch ends, a collector streams its results, stores each by custom_id, and resubmits anything expired plus any server-error errored result. Because batches can take longer than the default five-minute cache lifetime, the docs suggest the one-hour cache duration for a shared prefix; cache hits in a batch are best effort.

Path When it wins What it costs
Realtime Messages API A person is waiting, or the deadline is minutes Full price, and it draws on the per-minute limits everyone shares
Message Batches API Deadline of hours to a day or more, high volume Half price; up to 24 hours per batch and an expired path to handle
Realtime, low priority class The batch deadline is at risk, or results are needed within the hour Full price, but only capacity the interactive class leaves unused

Nine batches at half price, outside the realtime budget: that is the batch economics answer. Rafa keeps the third row as a fallback for essays still unfinished near the deadline.

The exam traps

  • ✗ Treating every 429 as a reason to retry harder or buy a higher tier. ✓ Read what the 429 says first: a per-minute limit, a ramp limit after a surge, or a spend cap with no retry-after. Each has a different fix, and only one of them is a bigger limit.
  • ✗ Cutting max_tokens to relieve output-token pressure. ✓ OTPM counts tokens actually generated, so only shorter outputs (a tighter format, a more concise instruction) or a higher limit relieve it.
  • ✗ Adding prompt caching to fix a 429 when output is the binding meter. ✓ Compute utilization per meter first; caching loosens ITPM only, because cache reads do not count toward it.
  • ✗ Splitting the organization limit into per-tenant workspace slices that add up to the total, expecting guaranteed shares. ✓ Workspace limits are ceilings, and many small workspaces fragment the prompt cache. Cap the workspace that can flood the rest and do per-tenant fairness in your dispatcher.
  • ✗ Running a deadline-of-days backlog through the realtime path with more workers. ✓ More workers only reach the shared limit sooner. Send it through the Message Batches API: separate limits, half price, results within 24 hours.
  • ✗ One first-come, first-served queue, or strict priority for interactive work. ✓ Priority classes with guaranteed shares, and round-robin between tenants within a class, so neither the bulk class nor a small tenant starves.

Put it together: plan capacity for a surge and prove it

You now have every piece: the three meters, the binding-constraint arithmetic, a dispatcher with backpressure, workspaces as ceilings, and a batch path. The exercise runs the arithmetic on your own account, then breaks it.

This lesson decides how much work reaches the API and in what order. Reliability engineering (2.1) handles a call that still fails, with retry and fallback by failure class. Cost architecture (6.1) extends batch economics with model routing and per-tenant budgets, and latency engineering (6.2) tunes the interactive path.

Key takeaways

  • ✓ The Messages API meters RPM, ITPM and OTPM per model class with a continuously refilling bucket, and ramp limits can reject a sudden surge below those limits.
  • ✓ Cache reads do not count toward ITPM, and OTPM counts generated tokens regardless of max_tokens.
  • ✓ The binding constraint is the meter that runs out first at forecast traffic; only loosening that meter raises throughput.
  • ✓ A dispatcher admits by tenant quota, queues by priority class with guaranteed shares, paces below the limits and pushes back on producers when full.
  • ✓ Workspace limits are API-enforced ceilings, not reservations: cap the workspace that could flood the others and keep tenants sharing a cached prefix together.
  • ✓ The Message Batches API takes work that can wait at half price, outside the realtime limits, up to 100,000 requests per batch and 24 hours to finish, with results joined by custom_id.

Practise this

Practice questions for CCDV-P are being written and are not in this course yet. Read this lesson on the web to answer its check questions, with every option explained: https://claude.termidy.com/learn/ccdv-p/production-integration-reliability/scale-throughput/.

Sources