Area: API
Sub-Area: Performance
Applies to: OSS + Cloud
Issue
High-volume API usage gets HTTP 429 responses, which cause ingestion failures or application errors.
The error you see:
-
429with the JSON body{"error": "Rate limit exceeded"}
You Might Be Asking
- What are the DataHub API rate limits?
- How do I handle rate limiting?
- Can I increase rate limits?
Cause
The GMS rate limiter denies a request with HTTP 429 and the body {"error": "Rate limit exceeded"}. The response carries a Retry-After value. The value is never lower than the configured minimum, which is 60 seconds by default.
DataHub Cloud applies distributed rate limiting across REST, GraphQL and OpenAPI.
In the self-hosted GMS application defaults, rate limiting is off (RATE_LIMITS_ENABLED=false).
Some 429 responses do not come from the rate limiter. For example, GMS returns 429 when Elasticsearch or OpenSearch refuses to create a point-in-time, and when an API throttle trips. Those responses carry different messages.
Solution
1. Use the REST emitter's built-in retries
The Python REST emitter already retries. By default it retries status codes 429, 500, 502, 503 and 504 on all methods, including POST. It uses backoff_factor=2 and retry_max_times=4. It gives 429 responses extra retries through a multiplier of 2. The default timeout is 30 seconds, and the connection pools default to 100/100.
Tune these with constructor arguments. Do not mount your own HTTPAdapter on the emitter's session. The emitter builds and mounts its own adapter for http:// and https://, and that adapter holds the retry policy and pool sizes.
from datahub.emitter.rest_emitter import DatahubRestEmitter
emitter = DatahubRestEmitter(
gms_server="https://<name>.acryl.io/gms", # self-hosted: http://<gms-host>:8080
token="<your-token>",
timeout_sec=60,
retry_max_times=6,
pool_connections=50,
pool_maxsize=50,
)
Other constructor arguments are retry_status_codes and retry_methods. The environment variables DATAHUB_REST_EMITTER_DEFAULT_RETRY_MAX_TIMES, DATAHUB_REST_EMITTER_429_RETRY_MULTIPLIER, DATAHUB_REST_EMITTER_DEFAULT_POOL_CONNECTIONS and DATAHUB_REST_EMITTER_DEFAULT_POOL_MAXSIZE also work.
For DataHub Cloud, the endpoint is https://<name>.acryl.io/gms. See Python REST emitter.
2. Add retries to your own GraphQL calls
If you call the GraphQL API directly, add retries to your requests session. Use allowed_methods. The older name method_whitelist is for urllib3 releases before 1.26. The SDK requires urllib3 2.5 or later.
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
def create_session_with_retries():
retry_strategy = Retry(
total=5,
backoff_factor=2,
status_forcelist=[429, 500, 502, 503, 504],
allowed_methods=["HEAD", "GET", "PUT", "DELETE", "OPTIONS", "TRACE", "POST"],
)
adapter = HTTPAdapter(max_retries=retry_strategy)
session = requests.Session()
session.mount("http://", adapter)
session.mount("https://", adapter)
return session
session = create_session_with_retries()
response = session.post(
"<your-datahub-url>/api/graphql",
json={"query": "{ me { platformPrivileges { generatePersonalAccessTokens } } }"},
headers={"Authorization": f"Bearer {token}"},
)
Use the same host you browse DataHub on, followed by /api/graphql. The access token dialog in the UI shows a ready-made curl command with this URL. The endpoint takes POST requests with an Authorization: Bearer header. See GraphQL setup.
Note that me returns corpUser and platformPrivileges. It has no username field. To get the username, use { me { corpUser { username } } }.
3. Respect Retry-After
A 429 from the GMS rate limiter includes Retry-After, with a floor of 60 seconds by default. If you still get 429s after retries, slow your request rate.
4. Change the limits
DataHub Cloud: You can't change server rate limits yourself. Contact DataHub Support and describe your workload.
Self-hosted: Set these GMS environment variables. See GMS rate limiting.
-
RATE_LIMITS_ENABLED: turns the limiter on or off. Defaultfalse. -
RATE_LIMITS_SCOPED_ENABLED: turns on scoped limits. -
RATE_LIMITS_SCOPED_ACTOR_CAPACITY: default 2000. -
RATE_LIMITS_SCOPED_BROWSER_CAPACITY: default 5000. -
RATE_LIMITS_SCOPED_SDK_CAPACITY: default 1000. -
RATE_LIMITS_SCOPED_GLOBAL_CAPACITY: default 20000. -
RATE_LIMITS_ENDPOINT_ENABLEDandRATE_LIMITS_CAPACITY_ENABLED: turn on endpoint and capacity limits. -
RATE_LIMITS_MIN_RETRY_AFTER: minimumRetry-Afterin seconds. Default 60.
Refill periods are in seconds and default to 60.
5. Kafka emitter for high volume (self-hosted)
The Kafka emitter is an alternative to REST. It needs pip install 'acryl-datahub[datahub-kafka]' and direct access to the Kafka brokers and schema registry. For DataHub Cloud, use the REST emitter. See REST and Kafka sinks.