
Where top software engineers prepare for interviews
Joined May 2023
- Tweets986
- Following2
- Followers5.2K
- Likes53
Which is why the other three exist, and why the right one depends on whether you can serve stale data while the rebuild happens.
1
288
Cache locking is the first fix. One request rebuilds, everyone else waits. Simple, and if the rebuild is slow or fails you now have ten thousand requests waiting on it.
1
276
Your cache entry expires and ten thousand requests hit the database in the same instant. That is a stampede, and the cache working correctly is what caused it.
All five stages, end to end: hellointerview.com/twitter/y…
69
Everything after that is a pipeline: transcode into renditions, generate thumbnails, build manifests, push to the CDN. None of it blocks the upload finishing.
1
1
229
The client splits the file into chunks and sends each straight to blob storage with presigned URLs. A job ID comes back immediately so the page does not hang, and dropping your connection resumes rather than restarts.
1
1
211
How each type works and where each one stops helping: youtube.com/watch?v=338NIkny…
2
827
Every index is also a write tax, which is why adding one without saying what it costs gets you a follow-up.
1
6
687
B-tree is the default and the right answer most of the time. Hash when you only ever do exact lookups. Inverted when you need search. Picking wrong costs orders of magnitude on the read you cared about.
Full breakdown: hellointerview.com/twitter/t…
2
333
The worker can publish an event and crash before marking it done, so it publishes again on restart. Consumers have to handle duplicates. You trade exactly-once for at-least-once and lean on your DB's transaction guarantees for the hard part.
1
513
Write the event to an outbox table in the same transaction as the order. Both writes commit or neither does. A background worker reads the outbox and publishes to Kafka, retrying if Kafka is down. No event gets lost.
1
1
546
Save the order, then publish to Kafka so the warehouse ships it. If the save succeeds and the Kafka publish fails, you've got an order that never ships. The transactional outbox fixes this.
