brylie / langflow-fastapi-htmx

Langflow chat proxy and frontend using FastAPI and HTMX
MIT License
8 stars 5 forks source link

Implement Rate Limiting for Anonymous Users #6

Open brylie opened 4 months ago

brylie commented 4 months ago

Objective

Implement a rate limiting mechanism to restrict the number of requests per user within a specified time period, ensuring fair usage and service stability for anonymous users.

Why

Description

We need to implement a rate limiting system that restricts the number of requests an anonymous user can make within a given time frame. This will help prevent abuse, ensure fair usage, and maintain the stability and performance of our service.

Tasks

  1. Research and choose an appropriate rate limiting library (e.g., slowapi for FastAPI).
  2. Implement rate limiting middleware:
    • Define rate limit (e.g., 10 requests per minute per IP address)
    • Set up error responses for when the rate limit is exceeded
  3. Integrate the rate limiting middleware with our FastAPI application.
  4. Implement user-friendly error messages when rate limit is reached.
  5. Add configurable settings for rate limits (requests per minute, time window).
  6. Implement logging for rate limit events.
  7. Create a simple dashboard or endpoint for monitoring rate limit statistics.

Technical Considerations

Acceptance Criteria

Additional Notes