This is a part of question I was asked at a startup recently. I was supposed to design a news feed where users are subscribed to multiple topics.
Design a service that returns 1 post from user's subscribed topics that user has not read before.
Once the user reads it, the service is re-invoked to get a new post.
This feed is real time, which means the feed should not return any post that was previously read by user, including the one they just read.
My solution was to add the Post IDs in the user's database entry, and apply filter in the query to get feed. But since the user may have read thousands of posts, applying this filter may not be scalable.
I can't think of any optimizations for this case. Any suggestions?