Once a broker API publishes a quota, the hard problem is not finding the number. It is deciding which workload gets the next request when order flow, account polling and a reconnecting client all compete for capacity. A limit applied only at the edge can protect a service while still allowing one busy account to starve every other task on a shared connection.
Design the controls around workload priority and failure behaviour, not just a requests-per-second figure. A market-data snapshot can wait. An order cancellation during a volatile market cannot be treated like a routine balance poll.
Choose a limit model that matches the traffic
Fixed windows and rolling windows
A fixed-window counter is simple: allow, for example, 60 calls per minute, then reset the counter at the next minute boundary. It is cheap to implement, but a client can use nearly all its allowance just before the reset and repeat just after it. The resulting burst can be close to twice the nominal per-minute rate.
A rolling-window counter smooths that boundary effect by counting requests over the preceding interval. It gives more predictable protection, at the cost of additional state and processing. A sliding log is precise but can be expensive at high volume; a sliding counter approximation often provides a useful balance.
Token buckets and leaky buckets
A token bucket is usually a better fit when an API needs to permit short bursts while keeping a sustained rate under control. Tokens refill at a set rate, and each request consumes one or more tokens. A bucket holding 20 tokens that refills at 10 per second allows an initial burst of 20, then settles near 10 requests per second.
A leaky bucket instead drains queued work at a stable rate. That makes it useful for smoothing non-urgent jobs, such as statement retrieval or historical-data queries.
It is less suitable as the only order-entry control: a queue that grows during a spike can turn a temporary throttle into stale trading instructions. Set queue expiry and reject work that is no longer useful.
Put controls at the right boundary
Client pacing protects shared capacity
Server-side limits remain necessary, but a client-side scheduler can prevent avoidable 429 responses and protect a broker's shared quota. Keep separate budgets for order entry, account reads, market-data snapshots and historical queries. Within each budget, use weighted priority: cancellations and risk-reducing actions should generally outrank new orders, while repetitive account refreshes can be delayed or coalesced.
Partition quotas by the dimensions the API actually enforces. These may include account, API key, IP address, endpoint, or a combination. A single global limiter in a multi-tenant gateway is simple but can let one firm's traffic consume capacity intended for others. Per-account controls improve fairness, though they add state and require careful handling when clients use multiple keys for the same account.
Gateway throttles add a reliable backstop
A gateway is a practical place to enforce shared limits, apply per-client budgets and return consistent rate-limit headers. It also introduces a possible failure point.
If the limiter's state store becomes unavailable, choose explicitly between failing closed, which rejects traffic, and failing open, which risks overloading downstream services. For order APIs, the choice should reflect risk controls and the broker's degraded-mode policy rather than a generic gateway default.
The figures below are typical planning ranges for common retail brokerage API patterns, not universal quotas or promises from a provider. Published limits differ by product, account tier and endpoint. Confirm the actual contract, including whether failed requests count.
| Workload | Typical sustained range | Typical burst or concurrency range | Control to consider |
|---|---|---|---|
| Order entry and amendments | 2-10 requests per second per account | 5-20 requests in a short burst | Reserve capacity for cancels and risk-reducing actions |
| Account and position reads | 5-20 requests per second per key or account | 10-50 requests in a short burst | Cache briefly and coalesce duplicate reads |
| Market-data snapshots | 1-10 requests per second per key or account | 1-5 concurrent requests per client | Prefer streaming subscriptions for frequent updates |
| History and reporting | 1-5 requests per second per client | 1-3 concurrent requests | Queue, paginate and schedule outside peak periods |
Make backoff safe for trading requests
A 429 response is a pacing signal, not an invitation to retry every request at once. Honour a Retry-After header where present, and also read any remaining-quota or reset headers the API supplies.
If the server gives no guidance, use exponential backoff with full jitter: choose a random delay between zero and the current cap, then increase the cap after each failure. A typical starting delay is 100-500 milliseconds, with a cap of 5-30 seconds and a small retry budget of three to five attempts for read operations.
Retries need different rules for different request types:
- Retry idempotent reads after a 429 or transient 5xx response, within a bounded time and attempt budget.
- Do not blindly resend an order after a timeout. The broker may have accepted it even if the acknowledgement was lost. Use an idempotency key or query order status before deciding whether to submit again.
- For a connection reset during order submission, mark the result as unknown and reconcile against the broker's order state. Treating uncertainty as rejection can create duplicate exposure.
- Stop retrying when the client has cancelled the intent, the market session has changed, or the order is no longer valid.
Jitter matters when many workers share a limit. Without it, they can all wake on the same reset boundary and recreate the burst that triggered throttling. A circuit breaker can stop repeated calls to a failing endpoint, but it should not block independent paths such as cancellations if those use a separate service or quota.
Measure fairness as well as throughput
Record throttle responses by endpoint, account and client, alongside queue depth, request age, retry count and time to acknowledgement. A low average 429 rate can hide a concentrated problem: one account may be throttled continuously while aggregate traffic remains within quota. Track p95 and p99 queue wait, not only average latency, and alert when a priority queue approaches its expiry limit.
Load tests should include quota exhaustion, synchronized reconnects, slow responses and ambiguous order acknowledgements. Test whether one client's burst affects another, whether reserved cancellation capacity remains available, and whether limiter state survives a gateway restart.
In multi-region deployments, check whether limits are local to each region or coordinated globally. Independent local buckets can multiply the effective allowance after failover.
For infrastructure teams comparing platform and API design choices, Trading Technology's coverage of trading infrastructure provides broader operational context. The implementation decision still comes down to the broker's actual quota model, the costs of delaying each request class, and the recovery path when acknowledgements are uncertain. Which workload would your team protect first if every client hit its limit during a market spike?
Frequently Asked Questions
What is a sensible starting rate limit for a broker API?
There is no universal quota, and order entry, account reads and history queries should not share one undifferentiated budget. Typical planning ranges can help with initial sizing, but the broker's published limits and endpoint-specific rules take precedence.
How should a trading client respond to an HTTP 429?
Use the Retry-After header or reset information when provided, then apply bounded backoff with jitter. Retry safe reads selectively, and avoid resending an order until its status is known.
Should order cancellations have a separate rate limit?
Where the API architecture permits it, reserve capacity for cancellations and other risk-reducing actions. A shared limit can allow polling or new orders to consume the quota needed to reduce exposure.
Is a token bucket better than a fixed-window limiter?
A token bucket gives a clearer control over burst size and sustained rate, making it useful for many broker API workloads. Fixed windows are simpler, but can permit concentrated bursts around counter resets.
Platforms · Software · Providers · Markets