西维蜀黍

【Architecture】System Design - Id Generator

Scope

  • QPS

  • SLA

  • Required Performance

    • The system should be able to generate 10,000 IDs per second.
  • Do IDs only contain numerical values?

    • Interviewer: Yes, that is correct.
  • What is the ID length requirement?

    • Interviewer: IDs should fit into 64-bit.
  • For each new record, does ID increment by 1?

    • Interviewer: The ID increments by time but not necessarily only increments by 1. IDs created in the evening are larger than those created in the morning on the same day.
  ...


【Architecture】System Design - Chat

Background

Candidate: What kind of chat app shall we design? 1 on 1 or group based? Interviewer: It should support both 1 on 1 and group chat.

Candidate: Is this a mobile app? Or a web app? Or both? Interviewer: Both.

Candidate: What is the scale of this app? A startup app or massive scale? Interviewer: It should support 50 million daily active users (DAU).

Candidate: For group chat, what is the group member limit? Interviewer: A maximum of 100 people

Candidate: What features are important for the chat app? Can it support attachment? Interviewer: 1 on 1 chat, group chat, online indicator. The system only supports text messages.

Candidate: Is there a message size limit?

Interviewer: Yes, text length should be less than 100,000 characters long.

Candidate: Is end-to-end encryption required?

Interviewer: Not required for now but we will discuss that if time allows.

Candidate: How long shall we store the chat history? Interviewer: Forever.

  ...


【Architecture】System Design - Consistent Hashing

  ...


【Architecture】System Design - News Feed

Background

What is news feed? According to the Facebook help page, “News feed is the constantly updating list of stories in the middle of your home page. News Feed includes status updates, photos, videos, links, app activity, and likes from people, pages, and groups that you follow on Facebook”.

Similar questions commonly asked are: design Facebook news feed, Instagram feed, Twitter timeline, etc.

  ...


【Architecture】System Design

Overall

  1. 理清需求(功能性需求和非功能性需求)
    1. 约束条件,如QPS、用户量、存储量,Page View,Daily Active User
  2. High-level Design
    1. 描述系统中的一些组件和组件之间的交互关系

High-level Design

Template - System Design Details

  • Acknowledgement

    • By other teams
  • Changelog

  • Deployment Sequence

    • Same deployment sequence means they can be deployed together (no strong requirement on the sequence)
  • Introductions

    • Background
      • A little background on the changes
        • why the feature is necessary
        • why do we take this approaches
        • Terminologies
    • Objectives
      • Provide the objective of the services to support the feature/changes
    • Requirements
      • Functional Requirements
      • Non-Functional Requirements
  • Flows and Logics

  • APIs

    • logic changes
    • highlight the new fields that are added
    • how to use the API
    • potential errors
  • Databases

    • ER Diagram
  • Dependencies

    • API level dependency multiplier
  • Performance

    • QPS analysis and potential bottlenecks. Might not need very accurate numbers here but can have some kind of estimations or justifications why this is not a concern.
    • Can also include performance issues that might not show up now but might be an issue in the future
  • Backward Compatibility

    • Feature Toggle
    • Clean up code
  • Monitoring

  • Downgrade/Rollback Plan

    • E.g., Rate limit, circuit breaker
  • System Limitation

  • Implementation Details

  • Investigations

    • Put the investigation result here
      • Alternatives that were considered but were not chosen due to xxx
      • Supporting data
  • Clean-up Plan

    • If this feature/project, needs any cleanup phase after the release, add the details here. (It can also be in a separate document and add a link to the document here)

      Details including, but are not limited to,

      • Code Clean up details
      • DB Clean up details
      • Config Clean up details
  • Financial Risk

  • Result Analysis

  • Task breakdown

  ...