# How do rate limiting and throttling mechanisms protect Salesforce endpoints from excessive traffic spikes?

**Topic:** Integration · **Difficulty:** Medium · **Tags:** Integration, Rate Limiting, Throttling Strategies

Read it on the site: https://www.forcechallenges.com/interview-questions/how-do-rate-limiting-and-throttling-mechanisms-protect-salesforce-endpoints-from-excessive-traffic-spikes

## Answer

**Basics:** Every org has a rolling 24-hour limit on API requests, based on edition and licenses (for example Enterprise Edition gets a base of 100,000 plus an amount per user license, which you should verify for your contract). There is also a limit on concurrent long-running requests (over 20 seconds), commonly 25 in production. Bulk API, event delivery and streaming have their own limits.

**How it works:**
1. Each REST, SOAP, Bulk or Apex REST call is counted.
2. Responses include a `Sforce-Limit-Info: api-usage=used/limit` header.
3. When the allocation is exceeded, calls fail with `REQUEST_LIMIT_EXCEEDED`.
4. The `/limits` REST resource (`DailyApiRequests`, and other entries) shows remaining capacity.
5. Clients back off and retry, and heavy loads use Bulk API or composite requests.

**Advanced / deep dive:** Build throttling in layers. A gateway enforces per-client quotas before traffic reaches Salesforce. Clients use exponential backoff with jitter and stop on persistent errors. Reduce call counts with the Composite API (up to 25 subrequests per call, and `allOrNone` option), sObject Collections (up to 200 records), Bulk API 2.0 for large loads, and Change Data Capture instead of polling. For custom Apex REST endpoints, Salesforce does not provide per-caller throttling, so implement a counter in Platform Cache or custom logic if needed. Monitor with the Salesforce API Total Usage event and set alert thresholds with Event Monitoring or the `/limits` endpoint.

**Code / config example:**
```text
Response header:  Sforce-Limit-Info: api-usage=87423/115000
Error body:       [{"message":"TotalRequests Limit exceeded.","errorCode":"REQUEST_LIMIT_EXCEEDED"}]  (HTTP 403)
Client rule:      retry with delay = min(60s, 2^attempt + random(0..1)s); stop after 5 tries
```

**Hidden gotchas & must-remember points:**
- It is HTTP 403, not 429, so generic 429 handlers will miss it.
- The 24-hour allocation is rolling, not reset at midnight.
- Sandboxes and Developer Edition have much smaller allocations.
- Long-running calls (over 20 seconds) count toward a small concurrency limit, and exceeding it also fails requests.
- Retrying blindly makes things worse. Always back off.
- Apex callouts out of Salesforce have separate limits (100 per transaction).

**Best practice:** Throttle at the edge, batch calls, prefer events over polling, and alert before reaching about 80 percent of the allocation.

---
Source: ForceChallenges · last updated 2026-11-02
