From f530247434b4e9cafec95d46789423e60abaf943 Mon Sep 17 00:00:00 2001 From: Mathias Goncalves Date: Fri, 12 Aug 2022 14:56:40 -0400 Subject: [PATCH] DOC: Rate limiting (#45) * FIX: Update envvar to include MAX in name * DOC: Add documentation for request knobs --- README.md | 11 +++++++++++ migas_server/schema.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index acd724a..991b4ab 100644 --- a/README.md +++ b/README.md @@ -55,3 +55,14 @@ Migas is built with [FastAPI](https://fastapi.tiangolo.com/), [Strawberry](https | redis | MIGAS_REDIS_URI | n/a | Yes | postgres | DATABASE_URL | n/a | Yes | sqlalchemy | MIGAS_DEBUG | n/a | No + + +### Runtime Knobs + +Migas includes the following environmental variables to allow finer control when processing requests: + +| Environmental Variable | Description | Default | +| ---- | ---- | ---- | +| MIGAS_REQUEST_WINDOW | A sliding window for limiting number of queries (in seconds) | 60 | +| MIGAS_REQUESTS_PER_WINDOW | Maximum number of requests per `MIGAS_REQUEST_WINDOW` | 5 | +| MIGAS_MAX_REQUEST_SIZE | Maximum size of request body | 450 | diff --git a/migas_server/schema.py b/migas_server/schema.py index db9073f..22b2e77 100644 --- a/migas_server/schema.py +++ b/migas_server/schema.py @@ -119,7 +119,7 @@ class Watchdog(Extension): """ REQUEST_WINDOW = int(os.getenv("MIGAS_REQUEST_WINDOW", 60)) - MAX_REQUESTS_PER_WINDOW = int(os.getenv("MIGAS_REQUESTS_PER_WINDOW", 5)) + MAX_REQUESTS_PER_WINDOW = int(os.getenv("MIGAS_MAX_REQUESTS_PER_WINDOW", 5)) MAX_REQUEST_SIZE = int(os.getenv("MIGAS_MAX_REQUEST_SIZE", 450)) async def on_request_start(self):