Timeline generation for celebrities | System Design | Google

I was asked this question in one of the system design rounds recently at Google which I could not answer properly and would need guidance on:

Assuming you have architected a very popular app (similar to i_n_s_t_a_g_r_a_m) and you have a lot of users now.

How will you architect timeline generation function for such an app?

Also how will it take care of a scenario where a celebrity has millions of followers (say President of a country), how will you make sure that each of the follower does not receive these updates with too much latency.

Based on my reading in the Designing Data Intensive Applications book, I proposed the following strategies to take care of this scenario:

  1. push model to update the timeline for subscribers who refresh their timeline very frequently
  2. pull model to update the timeline for subscribers who don't refresh their timelines very frequently.

These details about active users and not-so active subscribers can be found through offline analytics.

The interviewer went into the calculation of the timeline further - say if the number of followers are one million in same region and one million in other parts of the world, how to make sure that the :

  1. latency in updating an active subscriber in the same region is very less
  2. latency in updating an active subscriber in other region is also very less (less than a minute or two)

How many machines would we need? (Say we have an octa core machine)

I mentioned that we can assume that there are 4 threads of the timeline service running on a machine (assuming four threads are there for download and upload service) and each thread can accept upto 1K connections per minute.
This way we would need more than hundreds of machines to do so.

The interviewer was not satisfied with the answer.

Any suggestions on

  1. Optimizing the timeline generation for celebrities
  2. Calculate the hardware requirements for timeline generation
  3. Calculate the software requirements for timeline generation
Comments (11)