Design Whatsapp | Design a Chat Service

Medium

Functional Requirements (FRs)

  • 1:1 chat and group chat (Max 256 members per group)
  • Only text messages allowed. No multi-media support.
  • Online/Last seen indicator
  • Push notifications on message receive

Non-Functional Requirements (NFRs)

  • Daily-active users (DAU): 100M
  • Messages sent per day: 10x of DAU.
  • Max Message Length: 10000 characters.
  • Chat history should be available forever.
  • Message latency should be low.

How to solve the problem?

  • General:
    • Note everything you are discussing or thinking of in the text editor.
    • Draw everything that your interviewer needs to visualize on the whiteboard.
    • Be cognizant of how much time you've left and pace yourself (as required) so as to cover things that the interviewer wants to see you do based on the FRs and NFRs that were finalized.
  • Step 1: Think about the functional and non-functional requirements.
    • In an interview, the FRs and NFRs won't be provided.
    • You need to have a discussion with your interviewer to finalize these.
    • This step should take around 10-15 mins.
  • Step 2: For senior developers:
    • Note down the metric estimations.
    • The metrics would generally include read and write QPS, latency, storage, memory, bandwidth, etc.
  • Step 3: (Optional) Note down the APIs that you would need to support the functional requirements. Do it only if you've time.
  • Step 4: High-level design:
    • Propose and draw a very high-level design.
    • This design might have flaws and bottlenecks.
    • This design should just give a very high-level idea of the overall system.
  • Step 5: Deep-dive into the design:
    • Come up with the bottlenecks in the initial design and iteratively come up with a better design addressing the bottlenecks and trade-offs.
    • Update the design on the whiteboard as you are solving the bottlenecks.
    • Try to come up with multiple solutions for certain bottlenecks and mention the trade-offs and the reasons why you are picking up one over the others. If you don't have time, just mention them but don't note them.
    • If the interviewer asks, mention the DB schema as well. While practicing, make sure to add the DB schema.
  • Step 6: Overview:
    • Try to give an overview of the entire design specifically talking about the major decisions taken.
Creators
Gaurav
Gaurav Chandak
Setter