Available settings for global rate limits and throttling

Discourse ships with 3 different global rate limits that can be configured by site admins.

Global per-ip rate limits

These limits apply to every unique IP address that hits the Discourse application. (files that are served directly from the filesystem or the CDN are excluded)

By default this rate limit is enabled, you may disable it or set it to a reporting mode.

DISCOURSE_MAX_REQS_PER_IP_MODE : default block, this rate limit applies out of the box. (other options are warn, warn+block, and none)

DISCOURSE_MAX_REQS_PER_IP_PER_MINUTE: number of requests per IP per minute (default is 200)

DISCOURSE_MAX_REQS_PER_IP_PER_10_SECONDS: number of requests per IP per 10 seconds (default is 50)

DISCOURSE_MAX_ASSET_REQS_PER_IP_PER_10_SECONDS: number of asset (avatars/css) requests per IP per 10 seconds (default is 200)

DISCOURSE_MAX_REQS_RATE_LIMIT_ON_PRIVATE: should the rate limit apply to private IPs accessing Discourse? default is false.

DISCOURSE_SKIP_PER_IP_RATE_LIMIT_TRUST_LEVEL: use per user rate limits vs IP rate limits for users with this trust level or more (default 1)

User API rate limits

The mobile applications acquire a user API key per device to access Discourse on behalf of a user (using an open protocol). These API keys are very tightly limited.

DISCOURSE_MAX_USER_API_REQS_PER_MINUTE: default 20
DISCOURSE_MAX_USER_API_REQS_PER_DAY: default 2880

Admin API rate limits

The administrative API keys can be generated via the yoursite.com/admin/api/keys page. These keys can operate on behalf of users, but require administrative privileges to generate. There is a limit of 60 requests per minute, shared between all keys.

Self-hosted users can change this in their app.yml file. Hosted customers will need to contact their hosting provider.

DISCOURSE_MAX_ADMIN_API_REQS_PER_MINUTE : 60

Data Explorer Plugin API rate limits

DISCOURSE_MAX_DATA_EXPLORER_API_REQ_MODE: default warn , this rate limit applies out of the box. (other options are block , warn+block , and none )

DISCOURSE_MAX_DATA_EXPLORER_API_REQS_PER_10_SECONDS: 2

Note: The requests made via the Data Explorer UI do not count towards the rate limit.

What should I do if I hit a rate limit and get throttled?

If you are consuming the API programmatically and receive back a 429 status code throttle reply you should respect it and slow down.

As an end user you should not really experience rate limits if you do, slow down. You could trigger it by opening 50 tabs real quick or doing something like that.

Firewall and proxy warning! :warning:

If you are running a reverse proxy which is mis-configured Discourse may think all the requests are coming from a single IP address, it is very likely you will hit rate limits early. Be sure to configure your reverse proxy to forward the IP correctly.

How do I amend these limits?

To amend the limits add the desired change into your app.yml file in the env section.

:discourse: If you are hosted by Discourse, and on an Enterprise plan, contact team@discourse.org it you need to adjust any of these limits.

Global Rate Limits are not adjustable on starter, pro, or business plans.

Last edited by @MarkDoerr 2025-07-21T23:14:15Z

Last checked by @MarkDoerr 2025-07-21T23:14:23Z

Check documentPerform check on document:
60 Mi Piace

Mi sembra che se hai installato web.ratelimited.template.yml, allora questi non hanno importanza poiché le cose vengono limitate per frequenza da NGINX prima che raggiungano Discourse, giusto?

Questo è ciò che sembra dai miei log di nginx.

La mia soluzione a breve termine è aggiungere il mio indirizzo IP all’elenco IP locali, in modo che superi NGINX. Immagino che la cosa da fare sia rimuovere il template ratelimited per dare un senso a questi?

2 Mi Piace

Riguardo al seguente testo:

Avviso firewall e proxy! :warning:

Se stai eseguendo un reverse proxy mal configurato, Discourse potrebbe pensare che tutte le richieste provengano da un singolo indirizzo IP, è molto probabile che raggiungerai presto i limiti di frequenza. Assicurati di configurare il tuo reverse proxy per inoltrare correttamente l’IP.

Nella nostra configurazione, inoltriamo tutte le chiamate API tramite un proxy. Questo proxy gestisce l’autenticazione e molte altre cose prima di interrogare a volte Discourse.

Qual è il modo consigliato (header specifico?) per inoltrare l’indirizzo IP del richiedente originale?

Correlati

1 Mi Piace

Qualcuno potrebbe aiutarmi a capire questa impostazione di configurazione, per favore?

Sto pensando correttamente che sia già impostato su 1 e che i limiti di frequenza siano già impostati per utente anziché per indirizzo IP (se l’utente è TL1 o superiore)?

1 Mi Piace

in realtĂ  non esisteva per farmi specificare una o piĂą di queste impostazioni.

my script ha sempre rispettato l’header Retry-After, come possiamo vedere dalla riga originale 101;

retry_after = r.headers.get("Retry-After")

tuttavia questo header stava diventando inutilmente grande poiché pianifico diverse unità di servizio per l’esecuzione di questo stesso script in momenti diversi della giornata.

Pertanto, multipli di alcune di queste impostazioni dall’impostazione predefinita hanno migliorato la recapito delle e-mail tramite mail-receiver, il che rimane importante.