H1 interview question

System design, difficult level question