跟讀練習: System Design: How to Build an API Rate Limiter - 通過影片學習英語口語

選擇練習模式

每種模式都會開啟全屏練習室。

42 句
如果句子過短或過長,請點選 Edit 進行調整。
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.

下載應用

流利口語所需的一切

AI 發音評分逐句打分
音標練習掌握每個音
詞彙學習建立你的詞庫
詞彙遊戲邊玩邊學

同頻道

FOR YOU

推薦影片

本課的詞彙與口語要點

這節 C1 級別的口語課以影片“System Design: How to Build an API Rate Limiter”為素材。 影片中反覆出現的詞有:Api, user, request, bucket, token。 這段影片共有 42 個句子、594 個單詞可供跟讀。 講話部分時長為 2:47。 說話人語速較快,每分鐘約 213 個詞,會出現較多連讀和弱讀。 82% 的單詞屬於英語最常用的 3,000 詞,其餘的詞建議在練習前先學一下。

影片中的重點詞彙

影片中最難的 11 個單詞,附發音和釋義:

單詞發音釋義
bucket 名詞/ˈbʌkɪt/水桶, 吊桶
token 名詞/ˈtoʊkən/代幣 /代幣, 籌碼 /籌碼
server 名詞/ˈsɝvɚ/伺服器 /伺服器, 伺服器
burst 動詞/bɜːst/爆裂, 破裂
crystal 名詞/ˈkɹɪstəl/結晶 /結晶
belong 動詞/bɪˈlɒŋ/屬於 /屬於
fundamental 形容詞/ˌfʌn.dəˈmɛn.təl/基本
implementation 名詞/ˌɪmplɪmənˈteɪʃən/履行
reset 動詞/ɹiːˈsɛt/重置
millisecond 名詞/ˈmɪlɪˌsɛkənd/毫秒
simplification 名詞/ˌsɪm.plɪ.fɪˈkeɪ.ʃən/簡單化 /簡單化, 簡化 /簡化

影片中出現的短語動詞

單詞釋義
slow down 動詞減速 /減速, 放慢

影片中的語法

說話人最常用的結構,並附上影片中的原話:

結構影片中的用法
條件句 if + 從句,will/would + 動詞 — 條件及其結果If the bucket is empty, we will reject
被動語態 be + 過去分詞 — 強調發生了什麼,而不是誰做的is allowed · is made · are sent

需要注意的發音

  • “sh” 和 “zh” 音: implementation /ˌɪmplɪmənˈteɪʃən/, simplification /ˌsɪm.plɪ.fɪˈkeɪ.ʃən/
  • 長單詞——注意重音位置: 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/

中文母語者容易讀錯的音:

  • 詞尾子音 — 要讀清楚,後面不要加母音: bucket /ˈbʌkɪt/, burst /bɜːst/, clock /klɑk/, reset /ɹiːˈsɛt/, millisecond /ˈmɪlɪˌsɛkənd/
  • /r/ 和 /l/ 的區別: crystal /ˈkɹɪstəl/, refill /ˈɹiː.fɪl/

如何用這段影片練習

  1. 先完整聽一遍影片,不要開口,記下不認識的單詞。
  2. 先用 0.75 倍速逐句跟讀,熟練之後再回到正常速度。
  3. 錄下自己的聲音並與原聲對比,特別注意 bucket, token, server 這類單詞。

什麼是跟讀法?

跟讀法 (Shadowing) 是一種有科學依據的語言學習技巧,最初開發用於專業口譯員的培訓,並由多語言者Alexander Arguelles博士普及。這個方法簡單而強大:您在聽英語母語原聲的同時立即大聲重複——就像是一個延遲1-2秒緊跟說話者的影子。與被動聽力或語法練習不同,跟讀法強迫您的大腦和口腔肌肉同時處理並模模擬實的講話模式。研究表明它能顯著提高發音準確性,語調,節奏,連讀,聽力理解和口語流利度——使其成為雅思口語備考和真實英語交流最有效的方法之一。

影子跟讀法: 閱讀完整分步指南 →