In week one, a broker API integration usually passes its tests: one service sends requests, the limit in the documentation looks generous, and a retry handles the occasional 429 response. By week six, several pods may be polling the same accounts, a reconnect can trigger a burst of subscriptions, and a market event can send order updates, cancels and reads through one shared quota. The limit has not changed. The traffic pattern has.
Build rate limiting as shared capacity management, not a sleep statement inside each client. The aim is to keep routine reads within budget while preserving capacity for order changes and risk controls. That requires knowing which limits apply, coordinating callers, and treating throttling as feedback rather than a transient error.
Week one passes; week six finds the collision
A first integration often runs as a single process with a small account set. Its local limiter stays below the documented request rate, and manual testing rarely overlaps a session refresh, a reconnect or a burst of market-data requests. Production changes the arithmetic. A limit may apply per API key, account, IP address, endpoint family or WebSocket connection. Two services can therefore consume the same allowance without either service seeing the other.
Consider eight replicas, each configured for 10 requests per second. If the broker enforces 30 requests per second per key, the deployment can collectively offer 80 requests per second against a 30-request budget.
Autoscaling makes the mismatch worse unless new instances receive a share of the existing budget. Retries can then amplify the overload, especially if a 429 response causes every replica to retry at once.
Before launch, list the traffic that competes for broker capacity:
- Order entry, amend and cancel requests, including automated strategy traffic.
- Positions, balances, executions and order-status polling.
- Account discovery, session refreshes and reconnect recovery.
- Market-data snapshots and subscription management, where those share a quota.
- Health checks and dashboards that may multiply across services or accounts.
Assign each call to a limit scope. Do not assume that a global API key means every endpoint shares one bucket, or that separate endpoint paths have separate capacity.
Confirm the scope, burst allowance and reset behaviour with the provider, then test the answer. Documentation and observed behaviour can differ, particularly around short bursts.
Map the limit surface before setting budgets
Use the provider's published limits as constraints, not as a target to consume continuously. The figures below are typical market ranges for planning, not promises from any vendor.
Actual limits vary by product, account tier, region and endpoint. A single provider can also apply more than one limit at a time.
| API surface | Typical market range | Budget design | Common failure signal |
|---|---|---|---|
| General REST reads | 5-30 requests per second per key | Start at 60-80% of the confirmed sustained limit | 429 responses across unrelated read routes |
| Order writes | 1-10 requests per second per account or route | Reserve capacity for cancels and risk actions | Order amendments queue behind polling |
| Short burst allowance | About 2-5 times the sustained rate for seconds | Use a token bucket, but do not plan around full burst use | Brief 429 spikes after reconnects |
| WebSocket subscriptions | About 50-500 symbols per connection | Track connection and subscription limits separately | Subscription rejects or forced reconnects |
These ranges are broad because quota units differ. One API may count each request equally. Another may assign higher costs to history, search or bulk endpoints.
Record the unit, window, scope and reset rule for each quota. Check response headers for remaining capacity or reset time, if supplied. Treat their absence as a reason to measure conservatively, not as evidence that no limit exists.
Translate the documented limit into an operating budget with headroom. If the sustained allowance is 20 requests per second, a starting application budget of 12-16 per second leaves room for variance and provider-side traffic. Use a lower target during initial rollout. Recalculate after measuring normal and peak load, and include all services using the same credentials. A local limiter cannot enforce a shared budget if it has no view of its peers.
Share capacity and protect order flow
Put quota control at a point that can see the whole deployment. That may be a central request gateway or a distributed limiter backed by an atomic store. A central service is easier to reason about but adds a dependency and a network hop. Distributed coordination avoids a single request path, but needs careful handling of clock drift, store latency and partial failure.
In either design, define what happens when the limiter itself is unavailable. For order writes, failing open can exceed the broker quota; failing closed can delay trading. The right choice depends on the operation and the firm's risk controls.
Use weighted budgets if endpoints have different costs. A history request that returns thousands of records should not necessarily consume the same allowance as a lightweight status check.
Apply per-account fairness as well as a global limit. One busy account should not use all available capacity and starve other accounts or a risk service.
A practical implementation sequence is:
- Group calls by the actual provider quota, such as API key, account, route or connection.
- Set a sustained token rate below the confirmed limit and a small burst capacity for legitimate short spikes.
- Allocate account or service sub-budgets whose sum cannot exceed the shared budget.
- Reserve a defined share for cancels, order-status checks and risk actions. A starting reserve of 20-30% is a useful planning range, then tune it against observed traffic.
- Queue low-priority reads when their budget is spent. Drop stale polling work rather than allowing an old request queue to grow without bound.
Priority must reflect the operation's purpose, not just its HTTP method. A cancel request can be time-sensitive, but a repeated cancel for an already terminal order may be wasteful. Deduplicate outstanding reads and coalesce requests for the same account where possible. If five services need the same balance snapshot, one request with a short-lived shared result may be safer than five separate calls.
Keep client order identifiers stable across retries and use the broker's idempotency mechanism where available. After a timeout on order submission, the outcome may be unknown: the broker could have accepted the order while the response was lost.
Query by client order identifier or reconcile order state before resubmitting. Blindly retrying a new order can create duplicate exposure.
Back off without multiplying the outage
Handle 429 responses according to their scope. If a response includes Retry-After, respect it, then add a small random delay so every caller does not wake together.
If it does not, use exponential backoff with full jitter: choose a random delay from zero to a ceiling that grows on each attempt. For idempotent reads, an initial ceiling of 200-500 milliseconds, doubling to a cap of 2-5 seconds, is a reasonable starting range for many integrations. Tune it to the provider's reset window and the freshness requirement of the data.
Do not retry every failure in the same way. A 429 indicates capacity pressure; a validation error is not fixed by waiting.
A 5xx response may justify a bounded retry for a safe read, while a timeout on an order write needs reconciliation before another submission. Set a retry budget, such as two or three attempts for a read, and stop when the data is no longer useful. Keep retries inside the overall request deadline, not on top of it.
Backoff buys time. It does not create capacity, and it does not make an uncertain order outcome safe to repeat.
For order traffic, queueing can be preferable to immediate retry, but only if the queue preserves intent and expiry. A stale quote request can be discarded.
A cancel may need priority over a new entry. Define maximum queue age by operation, expose it to callers, and reject work that can no longer meet its purpose. Never let a retry loop sit outside the queue and compete with new work.
When throttling persists, apply a circuit breaker to non-critical reads. Pause or reduce polling, keep essential order and risk paths available within their reserved budgets, then probe recovery gradually.
A half-open probe should be small, not a full replay of deferred traffic. For streaming APIs, reconnect with jitter and restore subscriptions in batches. Replaying hundreds of subscriptions at once can turn a short disconnection into another throttle event.
Operate the limit as a production control
Log every throttle response with the account or quota scope, endpoint, request class, retry delay and remaining-capacity headers where available. Keep order identifiers out of broad operational logs unless access controls and retention rules support them. Metrics should show demand as well as failure: requests per second by route and scope, limiter rejections, queue depth and age, retry count, 429 rate, and order-write latency.
Set alerts on sustained signals rather than a single 429. A useful initial trigger might be a 429 rate above 1% for five minutes, or a priority queue approaching its age limit.
The thresholds depend on baseline traffic and the provider's reset window. Page on missed order or risk-control objectives; use a lower-severity alert for read throttling that is being contained successfully.
Test the controls with a load generator that mirrors production scope. Include several replicas sharing one credential, a reconnect burst, a slow response, a missing Retry-After header and an ambiguous order timeout.
Verify that the limiter keeps total traffic below the configured budget, that cancels retain reserved capacity, and that restarting a pod does not reset the entire deployment's allowance. A sensible rollout starts below the expected peak, measures the queue and error rate, then raises the budget in small steps.
Document the provider's confirmed limits, the internal budgets, fallback behaviour and escalation path in the same operational runbook. Broker infrastructure teams tracking API and platform changes can use Trading Technology's broker infrastructure coverage as part of that review, but provider-specific limits still need direct verification.
The mistake most readers will still make is treating a 429 as a retry instruction, rather than evidence that their shared budget, queue or request design is wrong.
Frequently Asked Questions
What should a broker API do when it receives a 429 response?
Respect Retry-After when the provider sends it, then add jitter to avoid synchronised retries. If the header is absent, use bounded exponential backoff and stop when the request is no longer useful. Do not blindly repeat an order submission after an ambiguous timeout.
How much headroom should a broker API rate limit budget leave?
A starting application budget of 60-80% of the confirmed sustained limit is a practical planning range. Leave additional capacity for bursts, provider-side variation and reserved order or risk operations. Adjust it after measuring peak traffic across every service sharing the quota.
Should rate limiting be handled per service or centrally?
A per-process limiter is insufficient when multiple services share an API key or account quota. Use a central gateway or coordinated distributed limiter so the combined request rate stays within budget. Account for the availability and latency trade-offs of the chosen design.
How should order requests be retried after a timeout?
Treat the result as unknown because the broker may have accepted the order before the response was lost. Reconcile using a stable client order identifier or the broker's idempotency mechanism before submitting again. A new order retry can otherwise create duplicate exposure.
What API rate-limit metrics should a trading operations team monitor?
Track request rate by quota scope and endpoint, 429 frequency, retry count, remaining capacity, queue age and order-write latency. Alert on sustained throttling or a queue nearing its maximum age, not just isolated 429 responses. Monitor the rate limiter itself and its failure mode as well.
Platforms · Software · Providers · Markets