A transparent proxy for handling Discord's API ratelimits.
100K+
A transparent, Redis backed proxy for handling Discord's API ratelimits.
The easiest way to run the proxy for yourself is Docker, images are available here.
docker run -d \
-p 8080:8080 \
-e HOST=0.0.0.0 \
-e REDIS_HOST=redis \
limbolabs/discord-api-proxy
Once up and running, just send your normal requests to http://YOURPROXY/api/v* instead of https://discord.com/api/v*.
You'll get back all the same responses, except when you would have hit a ratelimit - then you'll get a 429 from the proxy with x-sent-by-proxy and x-ratelimit-bucket headers.
If you get a 429 from the proxy, you should just retry until it works. If it's happening a lot, just stop hitting them.
| Name | Description |
|---|---|
HOST | The host to listen on. Defaults to 127.0.0.1. |
PORT | The port to listen on. Defaults to 8080. |
REDIS_HOST | The host of the Redis server. Defaults to 127.0.0.1. |
REDIS_PORT | The port of the Redis server. Defaults to 6379. |
REDIS_USER | The host of the Redis server. Defaults to an empty string, is only available on Redis 6+`. |
REDIS_PASS | The host of the Redis server. If unset, auth is disabled. |
REDIS_POOL_SIZE | The size of the Redis connection pool. Defaults to 64. Note: At least one connection is always reserved for PubSub. |
ENABLE_METRICS | Whether to expose Prometheus metrics on /metrics. Defaults to true. |
LOCK_WAIT_TIMEOUT | Duration (in ms) a request should wait for a lock to be released before retrying. Defaults to 500. |
RATELIMIT_ABORT_PERIOD | If the proxy does ever hit a 429, the duration (in ms) it should abort all incoming requests with a 503 for. Defaults to 1000. |
When sending globally ratelimited requests, the proxy currently starts the 1s bucket time from when the first response is received as Discord never provide the exact time. This can cause the proxy to be slightly over-restrictive, with a bot where the global ratelimit is 50 only being allowed up to ~47 requests per second.
Under extreme load, Redis calls to check ratelimits may start to slow down, causing the global ratelimit bucket expiry to drift. We try to mitigate this by monitoring the time taken for ratelimit checks and aborting the request when overloaded, but some can still slip through.
In the event that the proxy does receive a 429 from Discord, it will abort all further requests for 1 second.
Content type
Image
Digest
sha256:f5cddb539…
Size
53.2 MB
Last updated
about 1 year ago
docker pull limbolabs/discord-api-proxy