Code Monkey home page Code Monkey logo

php-rate-limiter's Introduction

PHP Rate Limiting with Redis

sudo apt update
sudo apt install -y php-redis
sudo systemctl restart apache2

Add a rate-limiter.php file in the root directory (/var/www/html/) of your web server. This file will be accessible to the public and users can type its address in a web browser to run it.

Hit:

curl -H "Accept: text/plain" -H "Content-Type: text/plain" -X GET http://localhost/rate-limiter.php?[1-5]

Understand the problem and establish design scope

Q: What kind of rate limiter are we going to design? Is it a client-side rate limiter or server-side API rate limiter?

A: Great question. We focus on the server-side API rate limiter.

Q: Does the rate limiter throttle API requests based on IP, the user ID, or other properties?

A: The rate limiter should be flexible enough to support different sets of throttle rules.

Q: What is the scale of the system? Is it built for a startup or a big company with a large user base?

A: The system must be able to handle a large number of requests.

Q: Will the system work in a distributed environment?

A: Yes.

Q: Is the rate limiter a separate service or should it be implemented in application code?Interviewer: It is a design decisio up to you.

Q: Do we need to inform users who are throttled?

A: Yes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.