Before diving into an implementation example, you need to know that there are actually different types of throttling, among which Rate-Limit, IP-level Limit (based on a list of whitelisted IP addresses for example), and Concurrent Connections Limit, to only cite those three. The first two are relatively easy to experiment with. We will focus on the first one here.

Let's see an example of rate-limit type throttling using a Flask application. To get a minimal Flask application running on your development machine, you have to add Flask to the Python environment, using the pip install flask command. Then add the Flask-Limiter extension using the pip install flask-limiter command.

As usual, we setup the Flask application with the ...

Get Mastering Python Design Patterns - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.