Skip to content
Menu

Rate limits and request limits

View .md

Beacon limits how often a caller may use its routes and how much a single request may carry or take. The limits protect against password guessing, a runaway client, a request that never ends, and an upload that fills memory. Read this page when you size a deployment, when a client receives 429, or when you put Beacon behind a proxy.

There are two groups of settings.

  • Beacon:RateLimits: how many requests a caller may send per time window.
  • Beacon:RequestLimits: how large a request may be, how long it may run, and how many MCP sessions stay open.

Both apply to Beacon’s routes only (/beacon/api, the hub under it and /beacon/mcp). They never touch the host’s own routes, and they are independent of the host’s UseRateLimiter.

Each rate limit is a fixed window per partition. A partition is one caller. The window is WindowSeconds long (default 60). The first PermitLimit requests in a window pass. Later ones are refused until the window ends. Setting PermitLimit to 0 turns that limit off.

CallerPartition keyUsed for
API keyapi-key:<id>REST, MCP, ask
Mapped MCP caller (bearer token)caller:<hash>REST, MCP, ask
Signed-in useruser:<id>REST
Anonymousip:<address>REST anonymous, login, setup

For an IPv6 client the address is reduced to its /64 block, the block one site or subscriber normally gets, so one client cannot draw a fresh budget by changing its low bits. An IPv4-mapped IPv6 address counts as the IPv4 address.

Counts live in process memory. Each Beacon instance counts on its own, so with three instances a caller can send up to three times the limit across them. A restart clears the counts. The lockout is different: it is stored on the user and holds across instances.

Beacon:RateLimits:MaxPartitions bounds the memory. A new partition beyond the cap replaces the least recently used one, which then starts again with a full budget.

A request over a limit is answered 429 as problem+json with a Retry-After header in whole seconds.

HTTP/1.1 429 Too Many Requests
Content-Type: application/problem+json
Retry-After: 17
{ "title": "Too Many Requests", "status": 429, "detail": "Too many requests; retry in 17 seconds." }

The body shows the fields Beacon sets; the framework may add its standard problem fields. Two answers have no body: the health route’s 429 and the MCP initialize refusal.

A client should wait Retry-After seconds and retry. The ask tool answers in its own wording instead: Too many questions for this credential; retry in {0} seconds.

KeyTypeDefaultRangeWhat it limits
Beacon:RateLimits:Login:PermitLimitint100 to 100000Password sign-in, per client address. First-run setup has its own partition with the same size.
Beacon:RateLimits:Api:PermitLimitint6000 to 100000Every /beacon/api request, per authenticated caller (anonymous: per address).
Beacon:RateLimits:Anonymous:PermitLimitint300 to 100000Anonymous requests Beacon answers 401 (no credential, unknown or expired key or token), per address. Over the limit they get 429.
Beacon:RateLimits:Mcp:PermitLimitint600 to 100000Every request to /beacon/mcp, per API key or mapped caller.
Beacon:RateLimits:Ask:PermitLimitint100 to 100000The ask tool (MCP and the playground), per caller.
Beacon:RateLimits:Feedback:PermitLimitint300 to 100000The feedback tool (MCP and the playground), per caller.
Beacon:RateLimits:<Limit>:WindowSecondsint601 to 3600Length of the window for that limit.
Beacon:RateLimits:MaxPartitionsint10000100 to 1000000Partitions each limit keeps in memory.

Lockout and break-glass delay settings are on Sign-in and session hardening.

Out-of-range values fail startup, for example:

Beacon:RateLimits:Api:PermitLimit must be between 0 and 100000.
Beacon:RateLimits:Mcp:WindowSeconds must be between 1 and 3600.
Beacon:RateLimits:MaxPartitions must be between 100 and 1000000.
{
"Beacon": {
"RateLimits": {
"Login": { "PermitLimit": 5, "WindowSeconds": 60 },
"Api": { "PermitLimit": 300, "WindowSeconds": 60 },
"Mcp": { "PermitLimit": 120, "WindowSeconds": 60 },
"Ask": { "PermitLimit": 10, "WindowSeconds": 60 },
"Feedback": { "PermitLimit": 30, "WindowSeconds": 60 },
"MaxPartitions": 10000
}
}
}
Terminal window
Beacon__RateLimits__Api__PermitLimit=300
Beacon__RateLimits__Mcp__WindowSeconds=60

GET /beacon/api/health has a fixed limit that is not configurable: 120 database probes per minute per remote address (the full address string, not the /64 block). Over it the answer is a bare 429 with Retry-After and no body. Behind a proxy, a load balancer’s probes all share the proxy address unless forwarded headers are on.

An MCP client opens a session with an initialize request. Beacon limits how many sessions one caller may open, because each session holds memory.

KeyTypeDefaultRangeWhat it does
Beacon:RequestLimits:McpMaxInitializesPerCallerint600 or more (0 off)initialize requests per caller per window. The caller is the API key, the mapped caller, the user, or the whole client address.
Beacon:RequestLimits:McpInitializeWindowSecondsint600 or moreWindow length.
Beacon:RequestLimits:McpMaxIdleSessionsint10000 or moreIdle MCP sessions kept in memory. The idle timeout is 30 minutes.

Over the initialize limit the answer is 429 with Retry-After set to the window length, before a session exists, and Beacon logs a Warning: MCP initialize refused: too many sessions opened by one caller.

MaxConcurrentQueriesPerKey limits how many SQL-carrying tool calls (query, ask and similar) one credential may have running at once. A call over the limit is refused at once and never queues. The tool answers:

Too many concurrent queries for this credential; retry shortly.

The stored MCP setting defaults to 4. A host can cap what an Admin may raise it to with Beacon:Mcp:Ceilings:MaxConcurrentQueriesPerKey (also MaxRowLimit, StatementTimeoutSeconds, MaxResultBytes). The regulated profile requires these four ceilings to be set. See Deployment locks for the full list.

KeyTypeDefaultRangeWhat it does
Beacon:RequestLimits:ApiMaxBodyByteslong2097152 (2 MiB)0 or more (0 off)Largest request body on /beacon/api.
Beacon:RequestLimits:McpMaxBodyByteslong4194304 (4 MiB)0 or moreLargest request body on /beacon/mcp.
Beacon:RequestLimits:ApiTimeoutSecondsint3000 or moreHow long one /beacon/api request may run before its cancellation token is cancelled.
Beacon:RequestLimits:HubMaxReceiveMessageByteslong8192 (8 KiB)0 or moreLargest message the realtime hub accepts from a client. The hub has no client-callable methods.
Beacon:RequestLimits:HubMaxParallelInvocationsPerClientint10 or moreHub invocations running at once per connection.
Beacon:RequestLimits:HubClientTimeoutSecondsint300 or moreSeconds without a client message before the hub drops the connection.

A negative value fails startup: Beacon:RequestLimits:ApiTimeoutSeconds must not be negative (0 turns the bound off).

Two things to know.

  • A host’s stricter limit wins. Beacon lowers Kestrel’s MaxRequestBodySize for its routes when its own value is smaller, and never raises it.
  • The Kestrel keep-alive and header timeouts, and the 5-minute HttpClient timeout the AI calls depend on, are not changed here.
CaseAnswer
Body over the limitBeacon lowers the request’s maximum body size to the limit. What the client then sees for an oversized body is decided by the web server, not by Beacon’s code.
/beacon/api request over ApiTimeoutSecondsWhen the handler stops with a cancellation and the response has not started: 504 with {"status":504,"title":"The request took too long."} as application/problem+json.

The hub and routes that run long work in the request are exempt from ApiTimeoutSeconds and keep their own timeouts. The body limit still applies to them. Beacon marks routes such as a migration run, a metadata refresh and an AI evaluation with .WithBeaconLongRunning(). A host can mark its own routes that Beacon’s pipeline covers:

app.MapPost("/beacon/api/my-long-job", async (IMyJob job, CancellationToken ct) =>
{
await job.RunAsync(ct);
return Results.Accepted();
})
.WithBeaconLongRunning();
{
"Beacon": {
"RequestLimits": {
"ApiMaxBodyBytes": 1048576,
"ApiTimeoutSeconds": 120,
"McpMaxBodyBytes": 4194304,
"McpMaxIdleSessions": 500
}
}
}
Terminal window
Beacon__RequestLimits__ApiTimeoutSeconds=120

The embed surface (Beacon:Embed, off by default) has its own limits, because its routes are anonymous. They are described fully on Embedding. Every refusal answers the same body, 401 {"error":"embed_unavailable"}, except the rate limit (429 with Retry-After) and a busy render slot (503 with Retry-After).

KeyTypeDefaultRangeWhat it does
Beacon:Embed:RateLimits:ExchangePerGrantPerMinuteint601 to 10000Token exchanges per grant.
Beacon:Embed:RateLimits:RenderPerGrantPerMinuteint1201 to 10000Renders per grant.
Beacon:Embed:RateLimits:RefusalsPerIpPerMinuteint301 to 10000Refusals counted per client address. Once spent, the exchange and the page answer 429 before any lookup.
Beacon:Embed:RateLimits:PagePerClientPerMinuteint601 to 10000Page loads per client address and grant.
Beacon:Embed:MaxConcurrentRendersint81 to 256Renders running at once in the process.
Beacon:Embed:MaxConcurrentRendersPerGrantintunset (a quarter of MaxConcurrentRenders, at least 1)1 to MaxConcurrentRendersRenders running at once per grant.
Beacon:Embed:MaxRowsint10001 to 100000Rows a render returns.
Beacon:Embed:TokenTtlSecondsint3001 to MaxTokenTtlSecondsLifetime of an issued token.
Beacon:Embed:MaxTokenTtlSecondsint9001 to 900Longest token lifetime.

Every call to an LLM provider goes through one queue (LlmRequestQueue), so a burst of questions cannot open unlimited provider connections.

SettingDefaultWhat it does
MaxConcurrentRequests50Calls running at once.
MaxQueuedRequests200Calls waiting for a slot. A call that finds the queue full gets The LLM is busy. Try again later.
RequestsPerMinute1000Enforced only while rate limits are on. Non-positive: unlimited.
TokensPerMinute80000Enforced only while rate limits are on. Non-positive: unlimited.
RateLimitsEnabledfalseWhether the two per-minute limits are enforced.
MonthlyBudget100.00Recorded, not enforced.

Only an Admin may change the concurrency limit, the per-minute limits or whether they are enforced. For anyone else the save succeeds for the other settings and writes no limit row. A stored limit replaces the host-configured one, also at startup. An attempt by a non-Admin to change them answers: Only an Admin can change the LLM concurrency limit, the requests or tokens per minute, or whether they are enforced.

Per-address limits (login, setup, anonymous 401s, health) and the cookie’s Secure flag use the address and scheme the host reports. Behind a proxy that is the proxy’s own address unless the host runs UseForwardedHeaders. Without it, every client shares one budget and the first noisy client can lock everyone out of login.

Trust only your own proxies, and put the middleware first in the pipeline.

using System.Net;
using Microsoft.AspNetCore.HttpOverrides;
var forwarded = new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
};
forwarded.KnownProxies.Clear();
forwarded.KnownNetworks.Clear();
forwarded.KnownProxies.Add(IPAddress.Parse("10.0.0.5"));
app.UseForwardedHeaders(forwarded);

The reference host Beacon.SampleProject turns this on from configuration, and trusts nothing when the list is empty:

{
"Beacon": {
"ForwardedHeaders": {
"Enabled": true,
"KnownProxies": [ "10.0.0.5" ]
}
}
}

Beacon:ForwardedHeaders is a setting of that sample host, not of Beacon itself. In your own host, call UseForwardedHeaders as shown above. Trusting a client-supplied X-Forwarded-For lets any client pick its own address and so draw a new budget on every request. See Production checklist.

A few dozen users, single sign-on, no public access. The defaults fit. Turn the lockout down only if your identity provider already enforces its own.

{
"Beacon": {
"RateLimits": {
"Api": { "PermitLimit": 600 },
"Mcp": { "PermitLimit": 60 }
}
}
}

Anonymous traffic reaches the login and 401 paths, so tighten those and bound memory.

{
"Beacon": {
"RateLimits": {
"Login": { "PermitLimit": 5, "WindowSeconds": 60 },
"Anonymous": { "PermitLimit": 20, "WindowSeconds": 60 },
"Api": { "PermitLimit": 300, "WindowSeconds": 60 },
"MaxPartitions": 50000
},
"RequestLimits": {
"ApiMaxBodyBytes": 1048576,
"ApiTimeoutSeconds": 120
}
}
}

Many agents share a small number of API keys. Raise the MCP limit per key, keep ask tight because each ask can cost several LLM calls, and cap idle sessions.

{
"Beacon": {
"RateLimits": {
"Mcp": { "PermitLimit": 240, "WindowSeconds": 60 },
"Ask": { "PermitLimit": 10, "WindowSeconds": 60 }
},
"RequestLimits": {
"McpMaxIdleSessions": 2000,
"McpMaxInitializesPerCaller": 120
}
}
}

Several instances multiply every in-memory limit. Divide each PermitLimit by the number of instances, or use session affinity so a caller stays on one instance.

WhatWhere
A limited REST, MCP, login or setup requestThe client sees 429 and Retry-After. Beacon writes no dedicated log event for it.
An MCP initialize refusalWarning MCP initialize refused: too many sessions opened by one caller.
A locked accountLog event 7124 UserLockedOut, audit action auth.user_locked_out.
A request over ApiTimeoutSecondsThe client sees 504 when the cancellation reaches the middleware; Beacon writes no dedicated log event.

Count 429 and 504 responses at your proxy or in your request logging to watch for pressure.

SettingDevelopmentProductionRegulated profile
RateLimits:Login, Api, Anonymous, Mcp, Askdefaultsdefaults or tightereach PermitLimit must be above 0
RateLimits:Lockoutononmust be on
RequestLimits boundsdefaultsdefaults or tighternot constrained
Mcp:Ceilings (four numeric ceilings)unsetsetmust be set; filled by the profile when unset
UseForwardedHeadersoffon, own proxies onlyon, own proxies only (the profile does not check it)

The regulated profile (Beacon:Profile = Regulated) fails startup when any of the five rate limits is off (PermitLimit 0) or the lockout is off, naming each key in one message.

SymptomCauseFix
Everyone gets 429 on loginBehind a proxy without forwarded headers, so all clients share one addressAdd UseForwardedHeaders with your proxies.
One automation job gets 429 on /beacon/apiIt exceeds 600 requests per minute on one keyRaise Api:PermitLimit, or give each job its own key.
MCP client gets 429 right after connectingToo many initialize calls from one callerReuse the session; raise McpMaxInitializesPerCaller if legitimate.
Too many concurrent queries for this credentialMore running queries than MaxConcurrentQueriesPerKeyRetry shortly, or raise the setting within the host ceiling.
504 on a long jobThe route is not marked long-runningUse .WithBeaconLongRunning(), or raise ApiTimeoutSeconds.
A large import is refusedBody over ApiMaxBodyBytesRaise it; a lower host Kestrel limit still wins.
The LLM is busy. Try again later.The LLM queue is fullRaise MaxQueuedRequests or MaxConcurrentRequests (Admin).
Limit seems higher than configuredSeveral instances count separatelyDivide the limit by instance count.
Startup fails on a limitOut of rangeThe message names the key and range.