Limit of requests per hour

How to limit requests per hour from one IP address, like on Twitter? For example, I want to provide 100 requests per hour. Is there a solution? Apache Modules? Thanks.

+4
source share
2 answers

Getting started is easy.

  • Use the concept of API keys (let's say its guid is mapped to a domain or account).
  • Every time your API hits, and increment its corresponding counter.
  • Write rules for restrictions based on your counter (in this case, the clock)
  • Reset

IP blocking is not recommended. NAT is a problem

+6
source

Do not do this over IP. People from an entire university, company or internet cafe can use the same IP address. It is best if you enter a cookie with a random value in the first HTTP response for each client to identify uniqueness.

0
source

All Articles