西维蜀黍

【Distributed System】Multi-region Active-active Architecture

演化

单机架构

我们从最简单的开始讲起。

假设你的业务处于起步阶段,体量非常小,那你的架构是这样的:

这个架构模型非常简单,客户端请求进来,业务应用读写数据库,返回结果,非常好理解。

但需要注意的是,这里的数据库是「单机」部署的,所以它有一个致命的缺点:一旦遭遇意外,例如磁盘损坏、操作系统异常、误删数据,那这意味着所有数据就全部「丢失」了,这个损失是巨大的。

  ...


【Distributed System】Scalability

Vertical Scalability

Vertical scaling, referred to as “scale up”, means the process of adding more power (CPU, RAM, etc.) to your servers. Horizontal scaling, referred to as “scale-out”, allows you to scale by adding more servers into your pool of resources.

When traffic is low, vertical scaling is a great option, and the simplicity of vertical scaling is its main advantage. Unfortunately, it comes with serious limitations.

  • Vertical scaling has a hard limit. It is impossible to add unlimited CPU and memory to a single server.
  • Vertical scaling does not have failover and redundancy. If one server goes down, the website/app goes down with it completely.
  ...


【Architecture】System Design - ID Mapping

Scope Title Bi-Directional Scalable Highly Available ID Mapping Question Description The e-commerce platform would like to maintain its own user id space so it can support users from different business / products Design a highly scalable, highly available bi-directional user id mapping service to bind an external user id to an internal e-commerce platform user id. map(external_uid) ==> internal_uid reverse_map(internal_uid) ==> external_uid Describe key components for your design, including database selection and design, cache design, logical flow etc.   ...


【Architecture】System Design - Notification System

Scope

  • Candidate: What types of notifications does the system support? Interviewer: Push notification, SMS message, and email.

  • Candidate: Is it a real-time system? Interviewer: Let us say it is a soft real-time system. We want a user to receive notifications as soon as possible. However, if the system is under a high workload, a slight delay is acceptable.

  • Candidate: What are the supported devices? Interviewer: iOS devices, android devices, and laptop/desktop.

  • Candidate: What triggers notifications? Interviewer: Notifications can be triggered by client applications. They can also be scheduled on the server-side.

  • Candidate: Will users be able to opt-out? Interviewer: Yes, users who choose to opt-out will no longer receive notifications.

  • Candidate: How many notifications are sent out each day? Interviewer: 10 million mobile push notifications, 1 million SMS messages, and 5 million emails.

  ...


【Architecture】System Design - Youtube

Scope

  1. Candidate: What features are important? Interviewer: Ability to upload a video and watch a video.
  2. Candidate: What clients do we need to support? Interviewer: Mobile apps, web browsers, and smart TV.
  3. Candidate: How many daily active users do we have? Interviewer: 5 million
  4. Candidate: What is the average daily time spent on the product? Interviewer: 30 minutes.
  5. Candidate: Do we need to support international users? Interviewer: Yes, a large percentage of users are international users.
  6. Candidate: What are the supported video resolutions? Interviewer: The system accepts most of the video resolutions and formats.
  7. Candidate: Is encryption required? Interviewer: Yes
  8. Candidate: Any file size requirement for videos? Interviewer: Our platform focuses on small and medium-sized videos. The maximum allowed video size is 1GB.
  9. Candidate: Can we leverage some of the existing cloud infrastructures provided by Amazon, Google, or Microsoft? Interviewer: That is a great question. Building everything from scratch is unrealistic for most companies, it is recommended to leverage some of the existing cloud services.
  ...