Skip to content

modal-projects/rate-limiter-kowser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rate Limiter Challenge

Welcome! This exercise is about debugging and extending a small FastAPI app. You will find a rate limiter that behaves incorrectly under certain conditions, then improve it step by step.

The tasks build on each other. There are more tasks than fit in an hour, so finish what you can and explain your reasoning as you go.


Setup

# Install dependencies
uv sync

# Start the server
uv run uvicorn app.web_app:app --reload

# In another terminal, test the endpoint
curl http://localhost:8000/api/resource

Project Structure

rate-limiter-challenge/
├── app/
│   ├── web_app.py       # FastAPI application
│   ├── rate_limiter.py  # Rate limiter implementation
│   └── config.py        # Configuration
├── tests/
│   ├── task0/test_basic_limiting.py      # Basic tests (should pass)
│   ├── task1/test_consistency.py         # Bug-revealing tests (will fail)
│   └── task2...task5/ (see task folders)
├── scripts/
│   └── demo_bug.py      # Demonstrates the bug
├── tasks/
│   └── ... task instructions
└── CHALLENGE.md         # This file

How to Work

  • Start with Task 1, then move on in order.
  • The tests act as the specification. It is OK to read them.
  • You do not need to change the tests.
  • Avoid hardcoding values; use configuration or runtime data.

Tasks

Task instructions live in the tasks/ folder. Start with Task 1:

  • tasks/task1/README.md

When you finish Task 1, continue with tasks/task2/README.md.


Testing Your Solution

Run all tests at once:

uv run pytest -v

Run a specific test file:

uv run pytest tests/task1 -v

Run a specific test:

uv run pytest tests/task1/test_consistency.py::TestWindowConsistency::test_consistency_across_edges -v

Submission

Please include:

  1. Your modified code
  2. A brief explanation of the bug (Task 1)
  3. Any design decisions or trade-offs you made
  4. Instructions for running your solution

Good luck!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages