Alex Xu Profile picture
Jul 1 9 tweets 3 min read Twitter logo Read on Twitter
Twitter has enforced very strict rate limiting. Some people cannot even see their own tweets.

Rate limiting is a very important yet often overlooked topic. Let's use this opportunity to take a look at what it is and the most popular algorithms.

A thread.

#RateLimitExceeded
What is rate limiting? Rate limiting controls the rate at which users or services can access a resource. Here are some examples:

- A user can send a message no more than 2 per second
- One can create a maximum of 10 accounts per day from the same IP address
Fixed Window Counter

The algorithm divides the timeline into fixed-size time windows and assigns a counter for each window. Each request increments the counter by some value. Once the counter reaches the threshold, subsequent requests are blocked until the new time window begins
Sliding Window Log

The Sliding Window Log algorithm fixes the issue with the Fixed Window Counter algorithm where it allows more requests to slip through at the edges of a time window.
Sliding Window Counter

The Sliding Window Counter algorithm is a more efficient variation of the Sliding Window Log algorithm. It is a hybrid that combines the fixed window counter and sliding window log.
Token Bucket

The Token Bucket algorithm is widely used for rate limiting. It is simple, well understood and commonly used by large tech companies. Both Amazon and Stripe use this algorithm to throttle their API requests.
Leaky Bucket

The algorithm uses a "bucket" metaphor but processes requests differently. Requests enter the bucket and are processed at a fixed rate, simulating a "leak" in the bucket. If the bucket becomes full, new requests are discarded until there is space available.
I hope you've found this thread helpful.

Follow me @alexxubyte for more.

Like/Retweet the first tweet below if you can:

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Alex Xu

Alex Xu Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @alexxubyte

May 29
/1 Our system design newsletter just reached a new milestone: 400,000 subscribers. Here are the most popular ones: 👇

Subscribe here: blog.bytebytego.com Image
/2 Understanding Database Types: blog.bytebytego.com/p/understandin… Image
/3 Password, Session, Cookie, Token, JWT, SSO, OAuth - Authentication Explained: blog.bytebytego.com/p/password-ses… Image
Read 7 tweets
May 19
/1 Free Algorithm, Git, Python, SQL, Java Books (And Many More)

These books were compiled from Stack Overflow Documentation and can be helpful for quick reference. Image
/2 The link to the books: books.goalkicker.com
/3 Subscribe to our weekly newsletter to get a Free System Design PDF (158 pages): bit.ly/42Ex9oZ Image
Read 4 tweets
May 18
/1 What is the difference between “pull” and “push” payments?

The diagram below shows how the pull and push payments work. Image
/2 🔹 When we swipe a credit/debit card at a merchant, it is a pull payment, where the money is sent from the cardholder to the merchant. The merchant pulls money from the cardholder’s account, and the cardholder approves the transaction.
/3 🔹 With Visa Direct or Mastercard Send, the push payments enable merchant, corporate, and government disbursements.

Step 1: The merchant initiates the push payment through a digital channel. It can be a mobile phone or a bank branch etc. Image
Read 9 tweets
May 15
/1 Netflix Tech Stack - Databases Image
/2 The Netflix Engineering team selects a variety of databases to empower streaming at scale.

Relational databases: Netflix chooses MySql for billing transactions, subscriptions, taxes, etc. They use CockroachDB to support a multi-region active-active architecture. Image
/3 Columnar databases: Netflix primarily uses them for analytics purposes. They utilize Redshift and Druid for structured data storage, Spark and data pipeline processing, and Tableau for data visualization. Image
Read 10 tweets
May 11
/1 How to choose between RPC and RESTful?

Communication between different software systems can be established using either RPC (Remote Procedure Call) or RESTful (Representational State Transfer) protocols, which allow multiple systems to work together in distributed computing. Image
/2 The two protocols differ mainly in their design philosophy. RPC enables calling remote procedures on a server as if they were local procedures, while RESTful applications are resource-based and interact with these resources via HTTP methods.
/3 When choosing between RPC and RESTful, consider your application's needs.
Read 7 tweets
May 10
/1 How much storage could one purchase with the price of a Tesla Model S?

Why do we do this? There's a trade-off between the price of a storage system and its access latency. Naturally, one might wonder how much storage could be obtained if one is willing to sacrifice latency. Image
/2 To make this calculation more intriguing, let's use the price of a Tesla Model S as a benchmark.

🔹 Tesla Model S: $87,490 per car
🔹 L1 cache: $7 per megabyte
🔹 L2 cache: $7 per megabyte
🔹 RAM: $70 for 32G
🔹 SSD: $35 for 128G
🔹 HDD: $350 for 12T Image
/3 Get a Free System Design PDF (158 pages) by subscribing to our weekly newsletter today: blog.bytebytego.com Image
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(