ubuntu.com icon indicating copy to clipboard operation
ubuntu.com copied to clipboard

Micro service to limit search rate

Open DimondKudzai opened this issue 3 months ago • 2 comments

This PR introduces application-level rate limiting to the /search route using Flask-Limiter. While there is already rate limiting at the content-cache level (as noted in the documentation), this enhancement adds a secondary layer of protection directly within the application.

Key Features:

  • Limits each IP to 10 search requests per minute
  • Custom error message returned when the limit is exceeded
  • Lightweight and easy to maintain
  • Helps prevent abuse and reduce load from spam or bots

Why this matters:

Rate limiting at the app level provides better transparency, immediate protection, and improved debugging. It also complements existing caching strategies without depending solely on infrastructure-level controls.

Implementation:

  • Flask-Limiter is initialized with get_remote_address to track IPs
  • Applied directly to the search view before registering the route

Tested: Yes, locally with mock requests

DimondKudzai avatar Sep 18 '25 22:09 DimondKudzai

DimondKudzai is not a collaborator of the repo

webteam-app avatar Sep 18 '25 22:09 webteam-app

Hi @DimondKudzai! Thanks a lot for your contribution! Could you please add Flask-Limiter to the dependencies list, specifying the exact version as well?

akbarkz avatar Oct 10 '25 03:10 akbarkz