Django limit the number of requests per minute
NickName:brad Ask DateTime:2015-03-29T02:52:47

Django limit the number of requests per minute

I'm trying to limit the number of requests from an IP in case I get too many requests from it.

For example: if I will get more than 50 requests per minute I want to block that IP for 5 minutes.

When I use request.META['REMOTE_ADDR'] I always get the IP of the local host and not the one that sent the request.

  1. How can I get the IP of the computer that sent the request?
  2. How can I limit that IP to not send more requests for X time?

Copyright Notice:Content Author:「brad」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/29321224/django-limit-the-number-of-requests-per-minute

Answers
DeRauk 2015-03-29T06:37:37

django-ratelimit will limit the number of requests you receive over a given amount of time.\nInstall:\npip install django-ratelimit\n\nIn your view:\nfrom django_ratelimit.decorators import ratelimit\n\n@ratelimit(key='ip', rate='10/m')\ndef myview(request):\n...\n",


More about “Django limit the number of requests per minute” related questions

Django limit the number of requests per minute

I'm trying to limit the number of requests from an IP in case I get too many requests from it. For example: if I will get more than 50 requests per minute I want to block that IP for 5 minutes. Whe...

Show Detail

how to limit the number of lambda function calls per minute?

Im using a AWS Lambda function receving many unexpected signals from several channels and sending request to another API. the problem is the another API is limiting the number of requests per minut...

Show Detail

golang rate limit per minute

How to rate limit 20 requests per minute? import "golang.org/x/time/rate" limiter := rate.NewLimiter(rate.Every(1*time.Minute), 20) for { limiter.Wait() //more code } This does...

Show Detail

PromQL Requests per minute

I'm trying to create a graph of total POST requests per minute in a graph, but there's this "ramp up" pattern that leads me to believe that I'm not getting the actual total of requests per minute, ...

Show Detail

Limit number of requests per minute using Supertest

We're using supertest with Typescript to test out APIs. For some of them (e.g. user registration, change password, etc) an email address is sent that is required for confirmation (user confirm token,

Show Detail

How to limit number of Linux processes spawned per minute?

My application requires to inhibit any fork bombs created by Python/Bash. I use ulimit program which set a limit to number of processes per user. Can anyone suggest me how I could limit number of

Show Detail

Limit number of JWT token per minute

I have a system where users get authentication token after valid credentials. that token can be used for further operations. Now I want to limit the number of tokens. I want that system should only

Show Detail

How to limit Google Cloud Tasks to execute 200 API requests per minute?

The third party API has a limit of 200 API requests per minute. We are using Google Cloud tasks as our core engine to execute the API calls. Wondering how we can setup the max dispatches and max

Show Detail

Glassfish: limit number of requests a user can make per second/minute

Ok I've been doing some googling about this and I haven't found anything definitive. Is there a preferred way of limiting the number of a requests a user can make to an application running on Glas...

Show Detail

Configuring django in heroku for a lot of requests per minute

I have a instance of django deployed in Heroku as follow, Procfile: web: python manage.py collectstatic --noinput ; gunicorn MY_APP.wsgi --log-file - worker: celery -A MY_APP worker beat: celery -A

Show Detail