Guarding the Gates: How Rate Limiting Ensures Fair Access and Security in Cyberspace

Jaspreet Singh Sodhi
3 min readJul 15, 2024

--

Rate Limiting

Imagine a bustling library in a quiet town. This library, named “Tech Haven,” has become increasingly popular due to its extensive collection of rare books and free internet access. To ensure everyone gets a fair chance to use the resources, the library introduces some rules — much like how rate limiting works in cybersecurity.

Setting the Scene: The Need for Rate Limiting

Tech Haven faces several challenges:

  1. The Book Hoarder: Some visitors check out large stacks of books, making it difficult for others to find the titles they need.
  2. The Internet Hog: A few individuals use all the available internet bandwidth, slowing down the connection for everyone else.
  3. The Fake Visitor: There are even rumors of bots — automated programs — using fake library cards to check out books and steal information about rare collections.

Enter Rate Limiting: The Library’s Solution

To maintain order and ensure fair access, Tech Haven’s librarian, Ms. Byte, implements some rules:

  1. Preventing Book Hoarding: Each visitor can check out up to five books per visit. This rule ensures that the most popular books are available to everyone. It’s similar to how rate limiting blocks users who make too many requests.
  2. Managing Internet Access: Visitors can use the library’s internet for up to one hour per session. If someone tries to use it for longer, their connection is paused for a while. This is like how rate limiting controls network traffic to prevent system overload.
  3. Stopping Fake Visitors: The library’s system now checks for suspicious activity, such as multiple fake library card uses from the same IP address, and blocks these attempts. This protects against bots trying to steal information or use resources unfairly.

Different Types of Rate Limiting: Ms. Byte’s Methods

Ms. Byte uses different strategies to manage the library’s resources:

  1. Fixed-Window Rate Limiting: Visitors can check out up to five books per day. Once they hit this limit, they have to wait until the next day to borrow more.
  2. Leaky Bucket Rate Limiting: The library has a fixed number of internet stations. When all are in use, new visitors must wait until a station is free, much like requests waiting in a queue.
  3. Sliding-Window Rate Limiting: Instead of resetting daily, book check-out limits adjust based on the visitor’s activity. If someone borrows five books at 3 PM, they can borrow more at 3 PM the next day.

The Result: A Fair and Efficient Library

Thanks to Ms. Byte’s rate limiting rules, Tech Haven becomes a more orderly and enjoyable place. Visitors appreciate having fair access to books and internet, and the library’s resources are protected from misuse. Just as Tech Haven thrives with these rules, systems and networks also benefit from rate limiting, ensuring stability, security, and fairness for all users.

I hope this Intutive explanation helps you understand Rate Limiting!

That’s it!. Feel free to follow me and share your thoughts on what else I can improve.

See you in the next part! 😊

--

--

Jaspreet Singh Sodhi

Full Stack Software Engineer | Curating Top-Notch Content @jaspreet.dev on Instagram ✨