Menu

Java LLD: Designing a High-Concurrency Twitter Feed
📰
0

Java LLD: Designing a High-Concurrency Twitter Feed

DEV Community·Vishal Aggarwal·about 1 month ago
#qE79i98h
#java#systemdesign#interview#feed#tweet#long
Reading 0:00
15s threshold

Java LLD: Designing a High-Concurrency Twitter Feed Designing a Twitter-style news feed is a staple of FAANG machine coding interviews. It forces you to demonstrate a deep understanding of read-vs-write trade-offs and thread-safe data structures in a high-scale environment. I built javalld.com while prepping for senior roles — complete LLD problems with execution traces, not just theory. The Mistake Most Candidates Make The Pull Model Trap: Querying the database for all followed users' tweets and sorting them by timestamp on every single read request. This results in $O(N \log N)$ read latency, which kills performance as the social graph grows. Ignoring Concurrency: Using standard collections like ArrayList or HashMap for feeds, leading to ConcurrentModificationException when one thread posts a tweet while another reads the feed. Lack of Bound Checks: Failing to implement a sliding window or capacity limit for in-memory feeds, eventually leading to OutOfMemoryError as the system scales.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More