AI Interview Prep

AI Interview Prep

Machine Learning System Design Interview #4 - The Infinite Stream Trap

Why batch thinking fails in infinite streams - and how Reservoir Sampling saves you

Hao Hoang's avatar
Hao Hoang
Nov 26, 2025
โˆ™ Paid

Youโ€™re in a Senior ML System Design interview at Twitter. The interviewer sets a trap:

โ€œWe have a firehose of tweets coming in at 50k TPS. I need you to maintain a statistically representative sample of exactly 10,000 tweets for a training buffer at all times. The stream never stops. You cannot store the full history.โ€

90% of candidates walk right into the wall.

Most candidates revert to ๐๐š๐ญ๐œ๐ก ๐“๐ก๐ข๐ง๐ค๐ข๐ง๐ .

AI Interview Prep is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

They say: โ€œEasy. Iโ€™ll buffer the last hour of data into S3, load it into a Dataframe, and run ๐˜ฅ๐˜ง.๐˜ด๐˜ข๐˜ฎ๐˜ฑ๐˜ญ๐˜ฆ(๐˜ฏ=10000)โ€ . Or they suggest:

โ€œI will just flip a coin and keep every 100th tweet.โ€

The interviewer stops you. โ€œYou just crashed production.โ€

The Reality:

User's avatar

Continue reading this post for free, courtesy of Hao Hoang.

Or purchase a paid subscription.
ยฉ 2026 Hao Hoang ยท Privacy โˆ™ Terms โˆ™ Collection notice
Start your SubstackGet the app
Substack is the home for great culture