docs(api): delegate rate limiting to the edge (ADR-0013) - #148
Merged
Conversation
The OpenAPI advertised per-IP and per-user rate limits with a 429 plus Retry-After, but no ledger code enforced them and the ledger is stateless and scaled to 10 replicas by the HPA, so per-replica counters cannot enforce a global limit. Records the decision (ADR-0013) to enforce rate limiting at the API gateway / edge and annotates the spec so the enforcer is unambiguous. The 429 contract and the 100/sec and 1000/sec targets are unchanged; no in-service rate-limiting code or dependency is added. Closes #52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Decision
Resolves issue #52 by delegating rate limiting to the API gateway / edge, not implementing it in the ledger. Records the decision in ADR-0013 and annotates
api/openapi.yamlso the enforcer is unambiguous.Why delegate (not implement in-service)
X-Forwarded-Forextraction, i.e. a stateful dependency bolted onto a deliberately stateless service.gatewayservice. The edge already holds the trusted client IP and the JWT subject; a token bucket there is a config line, not a new subsystem.What changes
api/openapi.yaml- the## Rate limitingdescription and theTooManyRequestsresponse now state enforcement is at the gateway / edge. The429+Retry-Aftercontract and the 100/sec / 1000/sec targets are unchanged (clients still receive 429 from the edge).ADR-0013 (staged for Wiki)
The decision record
ADR-0013-Rate-Limiting-At-The-Edge.md(decision, rationale, preserved targets, vendor-neutral reference gateway config - Spring Cloud Gateway RequestRateLimiter + Redis, with NGINX/Envoy/Kong equivalents, consequences, alternatives) is prepared underwiki/(gitignored per the docs-in-Wiki convention) and theADR-Indexrow added, for the owner to publish to the GitHub Wiki. It is not part of this git diff.Verification
Description-only spec change;
OpenApiContractITcompares path keys, so the contract test is unaffected (no path or schema key added/removed). Gate chain: analyst (decided the path with rationale), writer (ADR-0013 draft).Closes #52