Skip to content

Commit

Permalink
DOC: Rate limiting (#45)
Browse files Browse the repository at this point in the history
* FIX: Update envvar to include MAX in name

* DOC: Add documentation for request knobs
  • Loading branch information
mgxd authored Aug 12, 2022
1 parent ece36b8 commit f530247
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
2 changes: 1 addition & 1 deletion migas_server/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit f530247

Please sign in to comment.