Endpoint limits
← All configuration scenariosLimit an expensive route
protection.endpoints defaults to an empty list. Each rule sets a request rate, a per-worker concurrency limit or both. Admission is checked before the application handler runs. This profile gives reports a shared request budget while leaving unrelated routes such as /health available.
{
"listen": { "port": 9000 },
"protection": {
"endpoints": [{
"paths": ["/reports/*"],
"methods": ["GET"],
"max_concurrent_per_worker": 2,
"rate": { "requests": 5, "period_seconds": 1, "burst": 10 }
}]
}
}To try this locally, save it as reports.json next to vendor/ and start the bundled inspection handler.
php vendor/mini4work/webserver/examples/server.php reports.jsonFor a predictable test, set rate to { "requests": 1, "period_seconds": 30, "burst": 1 } and restart. In another terminal, send these requests in quick succession.
curl -i http://127.0.0.1:9000/reports/daily
curl -i http://127.0.0.1:9000/reports/daily
curl -i http://127.0.0.1:9000/healthWith an initially full bucket, expect 200, then 429 with Retry-After. The health request still reaches the handler and returns 200.
Match requests
paths accepts exact paths and subtrees. Here /reports/* covers /reports and its descendants. Query parameters do not create separate budgets. List aliases together if they should consume the same allowance. If several rules match, all must permit admission.
methods accepts uppercase HTTP methods. Omitting it or supplying an empty list covers all methods. HEAD inherits GET protection. The server also considers method overrides when matching a request.
Read the result
rate· 429 when depleted- In this example the bucket starts with capacity for 10 requests and refills at 5 per second. The budget applies across workers of one running server, including its TCP companion. Replacing a worker preserves the bucket. Restarting the whole server resets it. Independently launched servers have separate budgets.
max_concurrent_per_worker· 503 when full- Each worker can admit two matching requests at once. Streaming output holds its slot until the response finishes or closes. A free slot on another worker does not increase this worker’s allowance.
Both limit responses include Retry-After and Cache-Control: no-store. A 429 indicates budget depletion. A 503 from this rule indicates occupied concurrency slots. These limits apply to application work after transport setup.