Shadowing Practice: System Design: How to Build an API Rate Limiter - Learn English Speaking with Video

Creando lección...
1
Let's design an API rate limiter for an application that takes thousands of requests per second.
2
User journey is simple.
3
User can make API calls to your server to do something.
4
Each user is allowed to make 100 API calls per minute.
5
If a user makes more than 100 calls per minute, then your server will not process those API calls.
6
Most engineers approach this problem with a counter.
7
For each user, you store user ID, count of API calls, and current minute.
8
Every time a request is made by user, you increase this count, and you will reject the requests once it passes 100 requests.
9
This implementation is good enough for internal API calls, but let's take two specific examples why this solution is not good.
10
Let's say user Alan is a burst user, and makes 100 API calls in first two seconds.
11
Then he will get rejected for the next 58 seconds.
12
Alan will be able to make calls when next minute starts.
13
And our second user, John, sends 100 API requests, but these requests are sent at the last second of the current minute.
14
The next second clock will reset to new minute, and John can send another 100 requests.
15
Basically, John sent 200 requests in 2 seconds, because according to Counter, these 100 requests belong to different minutes.
16
Basically, users will experience different behavior of APIs based on when they make the API call.
17
There is a fundamental issue with the approach we just discussed.
18
The Counter is watching the clock instead of watching the user.
19
Let's see a better approach.
20
So, we will give every user a bucket that holds 100 tokens.
21
Every API request from user takes one token out, and we will keep filling the bucket at a rate of 100 tokens per minute, which is approximately 1.67 tokens per second.
22
For simplification, let's assume we will fill two tokens per second.
23
If user doesn't make any API call, the bucket will remain at 100, and we don't need to fill.
24
If the bucket is empty, we will reject the request.
25
This token bucket approach is what Stripe, GitHub, and most API gateways actually use for tracking API calls.
26
Now let's take a look at Alan and John's requests again, and see how this bucket system will work.
27
Alan drains all 100 tokens in 2 seconds.
28
Then Alan has to slow down.
29
Bucket fills about 2 tokens per second.
30
That's why he can now make 2 calls per second.
31
John, who is making 100 API calls at the end of the minute, will also need to wait for Bucket to fill, because once he makes 100 requests in a second, Bucket will get empty.
32
So he can also make about 2 per second, as Bucket fills with time.
33
Next question is, how do we store these buckets?
34
We just need to store the token count, and the time of the last refill, so that you can add tokens per second.
35
But what if your app works at large scale, and you have 20 different servers accepting API calls.
36
Two requests for the same user can land on two servers in the same millisecond.
37
Therefore, you keep the bucket outside the servers, in one common shared storage.
38
This storage needs to be fast, and that's why we usually use Redis.
39
When any of these 20 servers processes any API call, we change the count at this common Redis.
40
To make this crystal clear in your mind, you need to remember that request limit is not just one number.
41
It's two numbers.
42
First, how much a user can burst in one go, and second, how fast they can go after the burst.

Vocabulario y notas de pronunciación para esta lección

Esta lección de conversación de nivel C1 se basa en el vídeo “System Design: How to Build an API Rate Limiter”. Las palabras que más se repiten: Api, user, request, bucket, token. Este vídeo tiene 42 frases y 594 palabras para practicar shadowing. La parte hablada dura 2:47. El hablante habla rápido, unas 213 palabras por minuto, así que espera sonidos enlazados y reducidos. El 82 % de las palabras está entre las 3.000 más comunes del inglés; conviene repasar el resto antes de empezar.

Vocabulario clave de este vídeo

Las 14 palabras más avanzadas del vídeo, con su pronunciación y significado:

PalabraPronunciaciónSignificado
bucket sustantivo/ˈbʌkɪt/balde, cubeta
token sustantivo/ˈtoʊkən/seña
server sustantivo/ˈsɝvɚ/servidor
burst verbo/bɜːst/reventar
clock sustantivo/klɑk/cuentakilómetros
crystal sustantivo/ˈkɹɪstəl/cristal
belong verbo/bɪˈlɒŋ/pertenecer [with en or a]
fundamental adjetivo/ˌfʌn.dəˈmɛn.təl/fundamental, cimental
implementation sustantivo/ˌɪmplɪmənˈteɪʃən/puesta en práctica, implementación
drain sustantivo/dɹiːn/desagüe, drenaje
reset verbo/ɹiːˈsɛt/restablecer, resetear
millisecond sustantivo/ˈmɪlɪˌsɛkənd/milisegundo
refill sustantivo/ˈɹiː.fɪl/refill, reservida
simplification sustantivo/ˌsɪm.plɪ.fɪˈkeɪ.ʃən/simplificación

Phrasal verbs que vas a escuchar

PalabraSignificado
slow down verbodesacelerar, decelerar

Gramática en este vídeo

Las estructuras que más usa el hablante, con las palabras exactas del vídeo:

EstructuraEn el vídeo
Oraciones condicionales if + oración, will/would + verbo — una condición y su resultadoIf the bucket is empty, we will reject
Voz pasiva be + participio pasado — importa lo que ocurre, no quién lo haceis allowed · is made · are sent

Pronunciación a tener en cuenta

  • Los sonidos de “sh” y “zh”: implementation /ˌɪmplɪmənˈteɪʃən/, simplification /ˌsɪm.plɪ.fɪˈkeɪ.ʃən/
  • Palabras largas — cuida el acento: fundamental /ˌfʌn.dəˈmɛn.təl/, implementation /ˌɪmplɪmənˈteɪʃən/, millisecond /ˈmɪlɪˌsɛkənd/, simplification /ˌsɪm.plɪ.fɪˈkeɪ.ʃən/

Cómo practicar con este vídeo

  1. Escucha el vídeo entero una vez sin hablar y anota las palabras que no conoces.
  2. Empieza a velocidad 0,75×, haz shadowing frase por frase y vuelve a la velocidad normal cuando te resulte fácil.
  3. Grábate y compara con el original, prestando atención a palabras como bucket, token, server.

¿Qué es la Técnica de Shadowing?

Shadowing es una técnica de aprendizaje de idiomas respaldada por la ciencia, desarrollada originalmente para la formación de intérpretes profesionales y popularizada por el políglota Dr. Alexander Arguelles. El método es simple pero poderoso: escuchas audio en inglés nativo y lo repites en voz alta de inmediato, como una sombra que sigue al hablante con solo 1-2 segundos de retraso. A diferencia de la escucha pasiva o los ejercicios de gramática, el shadowing obliga a tu cerebro y músculos de la boca a procesar y reproducir simultáneamente patrones de habla reales. Las investigaciones muestran que mejora significativamente la precisión de la pronunciación, la entonación, el ritmo, el habla conectada, la comprensión auditiva y la fluidez al hablar, convirtiéndola en una de las metodologías más efectivas para la preparación del IELTS Speaking y la comunicación en inglés en el mundo real.

Técnica de shadowing: lee la guía completa paso a paso →