Why do Flask rate limiting solutions use Redis? Why do Flask rate limiting solutions use Redis? flask flask

Why do Flask rate limiting solutions use Redis?


Redis allows you to store the rate-limiting state in a persistent store.

This means you can:

  1. Restart your web server or web application and still have the rate-limitation work. You won't lose the records of the last requests made because of the working process being destroyed and a new one being created, instead.
  2. Use multiple web servers or web applications. This is because the rate-limitation state is stored in an external data store that also solves the issue of shared data synchronisation and data races. You can run as many web servers as you wish - the rate-limitation is shared among all of them.
  3. Look at the rate-limitation state. Redis offers easy CLI tools that allow you to look at the current active data in an ad-hoc manner, even MONITORing the incoming commands and requests.
  4. Let Redis manage TTL, LRU etc for rate-limitation algorithms. Redis supports this intrinsically.