Example: Rate limiter

Step 1 - Understand the problem and establish design scope

What is it? Used to limit number of requests. Examples:

  • A user can write no more than 2 posts per second.
  • You can create a maximum of 10 accounts per day from the same IP address.
  • You can claim rewards no more than 5 times per week from the same device.
image

Step 2 - Propose high-level design and get buy-in

Algorithms: based on IP, or some limit (subscription limit), or user id?

  • Token based
image
image
image

Step 3 - Design deep dive

Let’s answer to this questions now.

  • How are rate limiting rules created? Where are the rules stored?
  • How to handle requests that are rate limited?
image
SuperMade with Super