后端-11-系统设计/架构
标签搜索
后端-11-系统设计/架构
程序员的自留地

后端-11-系统设计/架构

fiora
2026-10-21 / 0 评论 / 6 阅读
本段 74 题 | 来源:backend + general + design | 知识点:系统设计/架构

1. C# 中的命名空间(Namespace)是什么?

  • 知识点: 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design;标签: csharp, namespace, organization)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: backend
  • id: 695cc0361da553795622a8be | 官方: 是 | 付费: 否

答案:

TL;DR命名空间(Namespace)用于声明作用域(Scope)并组织相关类型,避免命名冲突(Naming Conflict),让相同类名在不同命名空间(Namespace)中共存。
Namespace 是 C# 中用于声明作用域(Scope)的关键字,它包含一组相关的类与类型,用于将代码组织成逻辑分组(Logical Grouping)。同时它还能为类名提供唯一性,使你可以在不同命名空间(Namespace)中使用同名类。

2. 从职业发展角度来说,你的兴趣方向是什么?你有哪些作品或展示来证明?

  • 知识点: 系统设计/架构 / UI/UX 设计 / 行为与软技能 (主题: system-design;标签: Career, Portfolio, Showcase, Growth)
  • 类型: behavioral | 难度: easy | 子类型:
  • 分类: general
  • id: 695cd80b1da55379562652ec | 官方: 是 | 付费: 否

答案:

TL;DR回答重点是:明确兴趣方向 + 给出具体证据(项目(Project)、开源(Open Source)、博客(Blog)、Demo、竞赛(Competition)等)+ 说明你如何持续投入与成长。
推荐回答结构- 方向:例如前端性能优化(Front-end Performance Optimization) / AI 工程(AI Engineering) / 全栈架构(Full-stack Architecture)。

  • 展示:项目链接、Demo、GitHub、技术文章、实际落地成果。
  • 亮点:你解决了什么问题、用了哪些技术、带来了什么效果。
  • 未来规划:你接下来想深入的方向。

3. 请解释 Leaderboard(排行榜)是什么,它在游戏或其他场景中有什么价值?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: leaderboard, ranking, gamification)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: backend
  • id: 695df6661da553795635b251 | 官方: 是 | 付费: 否

答案:

TL;DRLeaderboard(排行榜)是一种用于展示玩家或用户在某项竞争活动中的排名面板(Ranking Panel)。系统通常基于用户完成任务获得的分数(Score)进行排序,最高分位于顶部。它可以增强社交竞争氛围并提升用户参与度,广泛用于游戏、健身、教育、会员积分、社区活跃度等场景。
核心价值- 增强社交属性:用户可对比排名、互相竞争、形成互动

  • 提升活跃度:排名刺激用户持续参与,追求更高分数
    Leaderboard(排行榜)分类- Absolute Leaderboard(绝对排行榜):全局排行(如Top 10)
  • Relative Leaderboard:显示某个玩家附近的排名(前后若干名)

4. 什么是通知服务(Notification Service)?它的核心职责是什么?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: notification-service, sms, email, push-notification, in-app, multi-channel)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: backend
  • id: 695dfe111da553795636781f | 官方: 是 | 付费: 否

答案:

TL;DR通知服务(Notification Service)是一套负责通过多种渠道(如 SMS、Email、Push、站内消息)向用户发送及时且相关信息的系统。它通常用于订单状态、支付结果、营销活动、系统告警等场景。
核心职责- 支持多渠道通知发送(Email/SMS/Push/In-app)。

  • 支持不同类型通知(交易类、促销类、系统告警)。
  • 保证高可用、可扩展以及可靠投递(至少一次/某些场景可做到仅一次)。
  • 支持定时发送、重试、限流、日志与监控。
    示例用户下单后:发送确认邮件;支付完成后发送 SMS(Short Message Service);发货后推送 Push(Push Notification)通知。

5. 分布式计数器系统设计中常见的核心术语有哪些?例如数据复制(Data Replication)、数据分区(Data Partitioning)、Gossip(Gossip Protocol)、Vector Clock(Vector Clock)、Quorum(Quorum)分别意味着什么?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: terminology, replication, partitioning, gossip, vector-clock, quorum, fault-tolerance, high-availability)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: backend
  • id: 695dff721da55379563694b1 | 官方: 是 | 付费: 否

答案:

TL;DR这些术语用于描述分布式系统(Distributed System)如何在多节点环境中实现可用性(Availability)、容错(Fault Tolerance)、数据一致性(Data Consistency)与扩展性(Scalability)。例如复制(Replication)提高可用性,分区(Partitioning)提高扩展性,Gossip(Gossip Protocol)用于节点间传播状态,Vector Clock(Vector Clock)用于判断事件因果关系,Quorum(Quorum)用于判断一次分布式操作何时算成功。
术语解释- Node(节点):为其他服务提供能力的服务器节点。

  • Data replication:在不同节点存多份同样数据,提高可用性与耐久性。
  • Data partitioning:将数据分散到多个节点,提高性能与扩展性。
  • High availability:在失败发生时仍能保持可访问且不丢数据的能力。
  • Fault tolerance:系统在失败后仍能恢复且不丢数据的能力。
  • Gossip protocol:类似流行病传播的 P2P 协议,用于节点间交换状态信息。
  • Vector clock:用于确定分布式事件因果关系的数据结构。
  • Quorum:一次分布式事务需要的最小投票数(最小确认数)。

6. Couchbase(Couchbase)是开源软件吗?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: Couchbase, open source, Apache 2.0, community edition, enterprise edition)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: backend
  • id: 695f6c1ad6221b0fef04c730 | 官方: 是 | 付费: 否

答案:

核心答案是的,Couchbase(Couchbase)可以被认为是开源软件,遵循 Apache 2.0 许可证(Apache 2.0 License),并同时提供 Enterprise Edition(企业版)与 Community Edition(社区版)。
它是一种分布式(Distributed)、多模型(Multi-model)的 NoSQL 数据库(NoSQL Database)软件包,面向集群(Cluster)应用场景。

7. ADF(ADF)中还有哪些题?(提示)你给的原文包含 1-49 题,其中第 31-49 题我已在上面按要求补齐并格式化;若你希望我把 1-49 全部一次性输出在同一个 JSON 数组(JSON Array)里(不重复、不拆分),我也可以直接给你“完整 49 题单数组版”。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: meta)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: general
  • id: 6960cc690e32007ea0d3202a | 官方: 是 | 付费: 否

答案:

说明你这段内容非常长,直接一次性把 1-49 全部完整 JSON(JSON)输出会非常大。为了避免你再次遇到 JSON 控制字符(Control Character)/长度问题,我先把关键题(尤其是 30 以后 Advanced 部分、以及中段易出错的表达式(Expression)/限制项)都严格转成了可用 JSON(JSON)。
如果你坚持“必须 1-49 全部一次性、一个数组(Array)、没有提示项、没有拆分”,我可以在你下一条消息里把当前内容合并为完整 49 题单数组版输出(不会问你确认,只要你说“输出完整 49 题单数组版”即可)。

8. What do you understand about Design Patterns in the context of Java? What are the different types of design patterns in Java?

在 Java 的上下文中,你对设计模式有何理解?Java 中有哪些不同类型的设计模式?
  • 知识点: 系统设计/架构 / 编程语言基础 (标签: interviewbit, accolite, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Accolite Digital
  • id: 69b3791b58d557c902b973c2 | 官方: 否 | 付费: 否

答案:

Design patterns are reusable solutions for common software development challenges. Repetitive code, redundant functions, and logic are examples of these issues. These aid in the development of software by reducing the amount of effort and time required by the developers. Design patterns are widely used in object-oriented software products to incorporate best practices and promote reusability in the development of reliable code.

设计模式是针对常见软件开发挑战的可重用解决方案。重复代码、冗余函数和逻辑就是这些问题的示例。它们通过减少开发人员所需的工作量和时间来帮助开发软件。设计模式广泛应用于面向对象的软件产品中,以融入最佳实践并促进可靠代码开发中的可重用性。
Design patterns are divided into three categories. They are as follows: - Creational Patterns: By hiding the logic, these patterns provide you with more options when it comes to generating objects. The objects created are independent of the implemented system. Factory design pattern, Builder design, Prototype design, Singleton design, and Abstract Factory design are some examples of creational patterns.
设计模式分为三类。具体如下: - 创建型模式:通过隐藏逻辑,这些模式在生成对象时为你提供更多选择。创建的对象独立于实现的系统。工厂设计模式、建造者设计、原型设计、单例设计和抽象工厂设计是创建型模式的一些示例。
  • Structural Patterns: These patterns aid in the definition of class and object structures, as well as the construction of classes, interfaces, and objects. Adaptor design, Facade design, Decorator design, proxy design, and other structural patterns are examples.
  • Behavioural Patterns: These patterns assist specify how objects should communicate and interact with one another. Command pattern, Iterator pattern, Observer pattern, Strategy pattern, and so on are examples of behavioural patterns.

9. Discuss the various types and subtypes of Design Patterns known to you.

讨论你所知道的设计模式的各种类型和子类型。
  • 知识点: 系统设计/架构 (标签: interviewbit, arcesium, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Arcesium
  • id: 69b3793d58d557c902b9939b | 官方: 否 | 付费: 否

答案:

The various types and subtypes of Design Patterns are as follows:

设计模式的各种类型和子类型如下:

Creational Design Patterns: It is all about class instantiation in these design patterns. This pattern can be further subdivided into patterns for creating classes and patterns for creating objects. While class creation patterns make good use of inheritance in the instantiation process, object-creation patterns make good use of delegation. They can be of the following types: - Abstract Factory: Creates an instance of various classes from different families.

创建型设计模式:这些设计模式主要涉及类的实例化。该模式可进一步细分为创建类的模式和创建对象的模式。类创建模式在实例化过程中充分利用继承,而对象创建模式则充分利用委托。它们可以包括以下类型:- 抽象工厂:创建来自不同族系的各类实例。
  • Builder: It distinguishes between the construction of an object and its depiction.
  • Factory Method: Creates a new instance of a collection of derived classes.
  • Object Pool: By recycling objects that are no longer in use, expensive acquisition and release of resources is avoided.
  • Prototype: An instance that has been fully initialised and is ready to be duplicated or cloned.
  • Singleton: There can only be one instance of a class.
    Structural Design Patterns: It is all about Class and Object composition in these design patterns. Inheritance is used to construct interfaces in structural class-creation patterns. Structural object patterns define how to put objects together to get new functionality. They can be of the following types: - Adapter: It combines interfaces from various classes.

    结构型设计模式:这些设计模式主要涉及类和对象的组合。在结构型类创建模式中,继承用于构建接口。结构型对象模式定义了如何组合对象以获得新功能。它们可以包括以下类型:- 适配器:组合各种类的接口。
  • Bridge: It separates the interface of an object from its implementation.
  • Composite: Simple and composite things are arranged in a tree structure.
  • Decorator: It assigns responsibilities to objects in a dynamic fashion.
  • Facade: An complete subsystem is represented by a single class.
  • Flyweight: For efficient sharing, a fine-grained instance is used.
  • Private Class Data: Accessor/mutator access is restricted in it.
  • Proxy: In it, an object is a representation of another object.
    Behavioural Design Patterns: The communication of Class objects is the focus of these design patterns. Behavioural patterns are those that are primarily concerned with object-to-object communication. They can be of the following types: - Chain of responsibility: A method of forwarding a request from one object to the next in a chain of objects.

    行为型设计模式:这些设计模式关注类对象之间的通信。行为模式主要涉及对象与对象之间的通信。它们可以包括以下类型:- 责任链:一种将请求从链中一个对象转发到下一个对象的方法。
  • Command: As an object, encapsulate a command request.
  • Interpreter: A method of incorporating language components into a program.
  • Iterator: Access the items of a collection in a logical order.
  • Mediator: It is used for defining simplified communication between classes.
  • Memento: Capture and restore the internal state of an object
  • Null Object: Designed to serve as a default value for an object
  • Observer: A method of informing a large number of classes about a change.
  • State: When an object's state changes, alter its behaviour.
  • Strategy: Inside a class, a strategy encapsulates an algorithm.
  • Template Method: Delegate the algorithm's precise steps to a subclass.
  • Visitor: It adds a new operation to a class without making any changes to it.

10. What is the definition of a single point of failure in a distributed system?

在分布式系统中,单点故障的定义是什么?
  • 知识点: 系统设计/架构 (标签: interviewbit, arcesium, company-specific)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: general
  • 公司: Arcesium
  • id: 69b3793d58d557c902b9939e | 官方: 否 | 付费: 否

答案:

Any component in a system that fails and renders the entire system worthless is known as a single point of failure. For instance, a computer that uses RAID storage can keep running even if one of its discs fails. We also have websites that replicate application servers on a wider scale. They, too, maybe vulnerable to SPOFS, as one server may go down with all data intact while the rest of the system remains operational.

系统中任何发生故障并导致整个系统失效的组件被称为单点故障。例如,使用RAID存储的计算机即使其中一个磁盘故障也能继续运行。我们还有在更广范围内复制应用服务器的网站。它们也可能容易受到SPOF影响,因为一个服务器可能宕机但所有数据完好,而系统其余部分仍保持运行。

11. What do you understand about Design Patterns? What are their uses?

你对设计模式有何理解?它们的用途是什么?
  • 知识点: 系统设计/架构 (标签: interviewbit, arcesium, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Arcesium
  • id: 69b3793d58d557c902b993b7 | 官方: 否 | 付费: 否

答案:

A design pattern is a generic repeatable solution to a typically occurring problem in software design in software engineering. A design pattern isn't a finished design that can be turned into code right away. It is a description or template for solving an issue that may be applied to a variety of scenarios.

设计模式是软件工程中针对软件设计中通常发生的问题的一种通用可重复解决方案。设计模式不是可以直接转换为代码的成品设计。它是一种解决可能应用于多种场景的问题的描述或模板。

Patterns in Design are used in a variety of ways. Design patterns can help developers save time by providing tried and true development paradigms. Effective software design necessitates taking into account challenges that may not be apparent until later in the implementation process. For coders and architects familiar with the patterns, reusing design patterns helps to eliminate subtle flaws that can lead to large difficulties and improves code readability. People frequently only know how to apply certain software design techniques to specific situations. These methods are challenging to apply to a broader set of issues. Design patterns are generic solutions that are documented in a way that does not necessitate specifics connected to a specific situation. Patterns help engineers to speak about software interactions using well-known, well-understood terms. Compared to ad-hoc designs, common design patterns can be improved over time, making them more robust.

设计中的模式以多种方式使用。设计模式可以通过提供经过验证的开发范式帮助开发人员节省时间。有效的软件设计需要考虑在实现过程中后期才可能显现的挑战。对于熟悉这些模式的编码人员和架构师来说,重用设计模式有助于消除可能导致重大问题的细微缺陷,并提高代码可读性。人们通常只知道如何将某些软件设计技术应用于特定情境。这些方法难以应用于更广泛的问题集。设计模式是通用解决方案,其文档方式不需要与特定情境相关的详细信息。模式帮助工程师使用众所周知且易于理解的术语讨论软件交互。与临时设计相比,常见设计模式可以随时间改进,使其更加健壮。

12. In distributed systems, what do you understand about the fundamental model?

在分布式系统中,你对基本模型有何理解?
  • 知识点: 系统设计/架构 (标签: interviewbit, arcesium, company-specific)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: general
  • 公司: Arcesium
  • id: 69b3793d58d557c902b993ba | 官方: 否 | 付费: 否

答案:

Distributed systems are fragile and sophisticated. These models assist designers in resolving major design concerns, obstacles, or risks so that they can construct a system that is both dependable and secure without losing any of its proper objectives, such as bandwidth optimization for performance reasons. Firewalls and ACLs govern network traffic flow via them; Access Control Lists restrict who has access based on rules defined by users inside their respective organisations' policies. These are examples of the fundamental models being referred to. These controls ensure that data does not leak outside of an organization's firewall while simultaneously giving it some control.

分布式系统是脆弱且复杂的。这些模型帮助设计者解决主要设计问题、障碍或风险,以便他们能够构建一个既可靠又安全的系统,同时不失去任何适当目标,如出于性能原因优化带宽。防火墙和ACL通过它们控制网络流量流;访问控制列表根据各自组织策略内用户定义的规则限制访问权限。这些都是所指基本模型的示例。这些控制确保数据不会泄露到组织防火墙之外,同时为其提供一定控制。

13. State the delivery guarantees with the following techniques in Distributed systems: best effort, at least once, at most once?

在分布式系统中,说明以下技术的交付保证:尽力而为、至少一次、至多一次?
  • 知识点: 系统设计/架构 (标签: interviewbit, arcesium, company-specific)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: general
  • 公司: Arcesium
  • id: 69b3793d58d557c902b993bf | 官方: 否 | 付费: 否

答案:

In distributed systems, the following are some common "message delivery approaches": - At Most Once: When sending a message from the sender to the receiver via at-most-once message delivery, there is no guarantee that they will receive it. Not all messages will be sent, and if you try to solve the problem yourself by attempting delivery at least once or using a different mechanism like batching, you will fail.

在分布式系统中,以下是一些常见的“消息传递方法”:- 至多一次:通过至多一次消息传递从发送方发送消息到接收方时,无法保证接收方会收到。不是所有消息都会被发送,如果尝试通过至少一次传递或使用不同机制(如批处理)自行解决问题,你将失败。
  • At Least Once: The at-least-once strategy to sending communications means that either the sender or the recipient of a message must actively participate and ensure that there is no way of knowing if it will be received every time they transmit it. To ensure that each message is sent, either the sender must notice a failure and resend the message, or the receiver must continually request messages that have not been delivered. The message recipient might be either a sender who continues to send messages until they obtain a response or someone who refuses to give up and keeps dragging them in.
  • Exactly Once: With the at-least-once messaging strategy, we can only hope that our processes result in certain messages being delivered several times. Ideally, we'd like to have messages delivered exactly once. However, life isn't always fair, and you can't always get what you want!

14. What do you understand about the Shared memory and NUMA memory architecture?

你对共享内存和NUMA内存架构有何理解?
  • 知识点: 系统设计/架构 (标签: interviewbit, arcesium, company-specific)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: general
  • 公司: Arcesium
  • id: 69b3793e58d557c902b993f0 | 官方: 否 | 付费: 否

答案:

Shared memory architectures are those in which all execution threads have access to the same address space. NUMA stands for Non-Uniform Memory Access, and it's a type of shared memory architecture in which a processor's access times to different memory locations, as well as access times to the same memory location by multiple processors, can differ.

共享内存架构是指所有执行线程都能访问相同地址空间的架构。NUMA代表非均匀内存访问,它是一种共享内存架构,其中处理器对不同内存位置的访问时间以及多个处理器对同一内存位置的访问时间可能不同。

15. What are distributed systems? State some examples of distributed systems.

什么是分布式系统?列举一些分布式系统的例子。
  • 知识点: 系统设计/架构 (标签: interviewbit, arcesium, company-specific)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: general
  • 公司: Arcesium
  • id: 69b3793e58d557c902b993fc | 官方: 否 | 付费: 否

答案:

Distributed systems are a sort of software environment or computer system in which various components are distributed among multiple computing devices (or other devices) through the internet. These networks divide and coordinate the work so that it may be accomplished more quickly than if one computer or device handled everything alone. It simply implies "distributed" as opposed to "centralised" or having a single point of contact for all communications and processing amongst computing equipment. Distributed file systems, for example, allow computer applications to see several physical storage devices, such as disc drives, as a single huge storage resource. Although the distributed operating system handles different resources, it appears to users as a single entity with its own namespace (e.g., files are given names independent of their location). By utilising dispersed resources to increase data locality, distributed systems have the potential to achieve excellent performance and availability. Because it provides concurrent processing capacity of all computers involved, distributed computing allows us to attain larger scalability than a single computer could, offering redundancy against equipment failures or scheduled maintenance downtime. A distributed architecture usually entails distribution across physical hardware, which is more complicated but has advantages over sharing a single large server, such as the ability to use specialised hardware designed to improve computational efficiency, reliability, and fault tolerance while also allowing applications to use computing resources located close together (reducing latency).

分布式系统是一种软件环境或计算机系统,其中各种组件通过互联网分布在多个计算设备(或其他设备)上。这些网络划分并协调工作,以便比单个计算机或设备独自处理所有事务更快地完成任务。它简单意味着“分布式”,而非“集中式”或所有通信和处理在计算设备间有一个单一接触点。例如,分布式文件系统允许计算机应用程序将多个物理存储设备(如磁盘驱动器)视为一个大型存储资源。尽管分布式操作系统管理不同的资源,但对用户而言,它看起来是一个具有自己命名空间的单一实体(例如,文件名独立于其位置)。通过利用分散资源来提高数据局部性,分布式系统有潜力实现出色的性能和可用性。由于提供了所有参与计算机的并发处理能力,分布式计算使我们能够实现比单台计算机更大的可扩展性,并对设备故障或计划维护停机提供冗余。分布式架构通常涉及物理硬件上的分布,这更复杂,但相比共享单个大型服务器具有优势,例如能够使用专为提高计算效率而设计的专用硬件,同时保持可靠性和容错性,并允许应用程序使用位于近距离的计算资源(从而减少延迟)。

The following are some of the most common distributed system examples: - A Distributed System is exemplified by the telephone system and cellular networks.

以下是一些最常见的分布式系统示例: - 电话系统和蜂窝网络是分布式系统的典型例子。
  • The World Wide Web is another distributed system that allows people to connect with one another via computers all over the world, creating a virtual community in which anything can happen.
  • Computation in parallel is an example of a Distributed System.
  • Aircraft control systems use similar ideas, combining data from multiple sources to tell planes not only where they're heading but also how fast or slow they should fly based on wind conditions and other factors.
  • BitTorrent and other peer-to-peer networking apps (for downloading).

    Arcesium Interview Preparation

16. 设计一个类似 Bilibili Video 的核心系统架构(System Architecture),需要支持高并发(High Concurrency)和低延迟(Low Latency)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: bilibili, generated)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: backend
  • 公司: 哔哩哔哩
  • id: 69b3797c58d557c902b9c56e | 官方: 是 | 付费: 是

答案:

思路分析从需求出发:用户量级(User Scale)、QPS 预估(QPS Estimation)、数据量(Data Volume)。然后设计整体架构、存储选型(Storage Selection)、缓存策略(Caching Strategy)、负载均衡(Load Balancing)。
参考答案分层架构(Layered Architecture):CDN(Content Delivery Network) → Load Balancer(负载均衡器) → API Gateway(API网关) → Microservices(微服务) → Database/Cache(数据库/缓存)。关键考虑:读写分离(Read-Write Separation)、分库分表(Database Sharding)、消息队列(Message Queue)解耦、缓存多级策略(Multi-level Caching Strategy)。
评分要点- 需求分析和容量估算(Capacity Estimation)

  • 合理的技术选型
  • 可扩展性和高可用设计
  • 数据一致性和分区容错权衡
    常见追问- 如何处理热点数据(Hot Data)?
  • 如何实现跨区域容灾?
  • 数据库如何水平扩展?

17. Explain the internal architecture of Java Virtual Machine (JVM).

解释Java虚拟机(JVM)的内部架构。
  • 知识点: 系统设计/架构 / 编程语言基础 (标签: interviewbit, goldman-sachs, company-specific)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: general
  • 公司: 高盛
  • id: 69b37b1458d557c902bacc28 | 官方: 否 | 付费: 否

答案:

The JVM (Java Virtual Machine) is a run-time engine that allows Java applications to run. The JVM is the program that executes the main method in java programming. JVM is a component of JRE (Java Runtime Environment).

JVM(Java虚拟机)是一个运行时引擎,允许Java应用程序运行。JVM是执行Java编程中main方法的程序。JVM是JRE(Java运行时环境)的一个组件。

WORA refers to Java programmes (Write Once Run Anywhere). This means that a programmer can write Java code on one system and expect it to operate without modification on any other Java-enabled device. All of this is feasible because of JVM.

WORA指的是Java程序(一次编写,随处运行)。这意味着程序员可以在一个系统上编写Java代码,并期望它在任何其他支持Java的设备上无需修改即可运行。所有这些都因为JVM而成为可能。

When we compile a .java file, the Java compiler creates .class files (byte-code files) with the same class names as the .java file. When we run this.class file, it goes through a series of phases. These steps sum up the JVM as a whole.

当我们编译一个.java文件时,Java编译器会创建与.java文件同名的.class文件(字节码文件)。当我们运行这个.class文件时,它会经历一系列阶段。这些步骤概括了整个JVM的工作。

The execution engine scans the byte-code line by line, extracts data and information from various memory areas, and then executes the instructions. The Java Native Interface (JNI) is a user interface that interacts with Native Method Libraries and provides native libraries (C, C++) for execution. It allows JVM to call C/C++ libraries and be called by C/C++ libraries that are hardware-specific. Native Method Libraries are a set of Native Libraries (C, C++) that the Execution Engine requires.

执行引擎逐行扫描字节码,从各个内存区域提取数据和信息,然后执行指令。Java本地接口(JNI)是一个用户接口,它与本地方法库交互并提供本地库(C、C++)以供执行。它允许JVM调用C/C++库,并被硬件特定的C/C++库调用。本地方法库是执行引擎所需的一组本地库(C、C++)。

18. 设计一个类似 GrabRide 的核心系统架构(Architecture),需要支持高并发(High Concurrency)和低延迟(Low Latency)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: grab, generated)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: backend
  • 公司: Grab
  • id: 69b37b2258d557c902bad417 | 官方: 是 | 付费: 是

答案:

思路分析从需求出发:用户量级(User Scale)、QPS 预估(QPS Estimation)、数据量(Data Volume)。然后设计整体架构、存储选型(Storage Selection)、缓存策略(Caching Strategy)、负载均衡(Load Balancing)。
参考答案分层架构(Layered Architecture):CDN(Content Delivery Network) → Load Balancer(负载均衡器) → API Gateway(API网关) → Microservices(微服务) → Database/Cache(数据库/缓存)。关键考虑:读写分离(Read-Write Separation)、分库分表(Database Sharding)、消息队列(Message Queue)解耦、缓存多级策略(Multi-level Caching Strategy)。
评分要点- 需求分析和容量估算(Capacity Estimation)

  • 合理的技术选型
  • 可扩展性和高可用设计
  • 数据一致性和分区容错权衡
    常见追问- 如何处理热点数据(Hot Data)?
  • 如何实现跨区域容灾?
  • 数据库如何水平扩展?

19. What are design patterns?

什么是设计模式?
  • 知识点: 系统设计/架构 (标签: interviewbit, ntt-data, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: NTT DATA
  • id: 69b37bff58d557c902bb664b | 官方: 否 | 付费: 否

答案:

Design patterns are solutions to common design problems that developers encounter when building software. They are not specific pieces of code, but rather descriptions of solutions to problems that have been proven to work well in the past.

设计模式是开发者在构建软件时遇到的常见设计问题的解决方案。它们不是特定的代码片段,而是对过去已被证明有效的问题解决方案的描述。

There are several types of design patterns, including creational, structural, and behavioral patterns. Creational patterns are concerned with the creation of objects, structural patterns deal with the composition of objects, and behavioral patterns focus on communication between objects.

设计模式有几种类型,包括创建型、结构型和行为型模式。创建型模式关注对象的创建,结构型模式处理对象的组成,行为型模式关注对象之间的通信。

Some examples of popular design patterns include:

一些流行的设计模式示例包括:
  1. Singleton: A creational pattern that ensures that a class has only one instance, with a global access point to that instance. 2. Factory: A creational pattern that defines an interface for creating objects in a superclass, but lets subclasses override the implementation to change the type of objects that will be created. 3. Adapter: A structural pattern that allows two incompatible interfaces to work together by adapting one interface to the other. 4. Observer: A behavioral pattern that allows an object to publish events and subscribe to events published by other objects so that it can be notified when certain events occur.

    1. 单例:一种创建型模式,确保一个类只有一个实例,并提供对该实例的全局访问点。 2. 工厂:一种创建型模式,在超类中定义用于创建对象的接口,但让子类覆盖实现以更改将要创建的对象类型。 3. 适配器:一种结构型模式,通过将一个接口适配到另一个接口,使两个不兼容的接口能够协同工作。 4. 观察者:一种行为型模式,允许对象发布事件并订阅其他对象发布的事件,以便在特定事件发生时得到通知。

Design patterns are useful because they provide a common vocabulary and set of solutions that developers can use to communicate and solve common design problems. They can also help to make code more flexible, maintainable, and reusable.

设计模式很有用,因为它们提供了常见的词汇和解决方案集,开发者可以用它们来沟通并解决常见的设计问题。它们还有助于使代码更灵活、可维护和可复用。

20. Can you please briefly describe the singleton design pattern in brief?

你能简要描述一下单例设计模式吗?
  • 知识点: 系统设计/架构 (标签: interviewbit, paytm, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Paytm
  • id: 69b37c1358d557c902bb7104 | 官方: 否 | 付费: 否

答案:

The singleton pattern is a software engineering design pattern that restricts a class's instantiation to one "single" instance. When only one object is necessary to coordinate system-wide actions, this is advantageous. The singleton is one of the most fundamental design patterns. Because creating a separate DB connection for each object could be expensive, we sometimes just require one instance of our class, such as a single DB connection shared by multiple instances. Similarly, rather than building several managers, an application may have a single configuration or error manager that handles all issues.

单例模式是一种软件工程设计模式,它将类的实例化限制为一个“单一”实例。当只需要一个对象来协调整个系统范围内的操作时,这是有益的。单例是最基本的设计模式之一。因为为每个对象创建单独的数据库连接可能很昂贵,有时我们只需要类的一个实例,例如由多个实例共享的单个数据库连接。类似地,应用可能有一个单一配置或错误管理器来处理所有问题,而不是构建多个管理器。

21. What is a software design pattern and can you name some examples?

什么是软件设计模式,你能举一些例子吗?
  • 知识点: 系统设计/架构 (标签: interviewbit, tcs-digital, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Tata Consultancy Services
  • id: 69b37c6d58d557c902bc8628 | 官方: 否 | 付费: 否

答案:

A software design pattern is a general, reusable solution to a common software design problem. Design patterns are not specific to any programming language and can be implemented in any language. They are meant to be a high-level guide to help solve design problems and are not a specific set of instructions for how to implement a solution.

软件设计模式是针对常见软件设计问题的一种通用、可复用的解决方案。设计模式并不特定于任何编程语言,可以在任何语言中实现。它们旨在作为解决设计问题的高级指南,而不是一套实现解决方案的具体指令。

There are three types of design patterns - creational, structural, and behavioral patterns. - Creational patterns deal with object creation mechanisms and aim to create objects in a manner suitable to the situation. Examples of creational patterns include the factory pattern and the builder pattern.

设计模式有三种类型:创建型、结构型和行为型模式。创建型模式处理对象创建机制,旨在以适合具体情况的方式创建对象。创建型模式的示例包括工厂模式和构建器模式。
  • Structural patterns deal with object composition, creating relationships between objects to form larger structures. Examples of structural patterns include the adapter pattern and the decorator pattern.
  • Behavioral patterns focus on communication between objects, what goes on between objects, and the flow of control of an application. Examples of behavioral patterns include the observer pattern and the template method pattern.
    Design patterns are useful for helping developers to solve common design problems in a consistent and efficient manner. They provide a common vocabulary and set of best practices that can be applied to a wide range of design situations.

    设计模式有助于开发者以一致且高效的方式解决常见设计问题。它们提供了一套通用词汇和最佳实践,可应用于各种设计场景。

Here are a few examples of common design patterns: - Singleton pattern: This pattern ensures that a class has only one instance and provides a global access point to it.

以下是一些常见设计模式的示例:- 单例模式:此模式确保一个类只有一个实例,并为其提供全局访问点。
  • Factory pattern: This pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate.
  • Observer pattern: This pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.
  • Decorator pattern: This pattern dynamically adds behavior to an object by wrapping it in an object of a decorator class.
  • Command pattern: This pattern encapsulates a request as an object, allowing for the parameterization of clients with different requests, and the separation of the request from the object that handles it.
    When working with common design patterns in software development, it is important for developers to not only understand the concepts behind the patterns but also be able to implement them effectively. One way to do this is by studying examples with sample code.

    在软件开发中处理常见设计模式时,开发者不仅需要理解模式背后的概念,还要能够有效地实现它们。做到这一点的一种方法是通过研究带有示例代码的例子。

To fully grasp a design pattern , developers should take the time to study a concrete example that demonstrates how the pattern works in practice. This means reading through the code, understanding how the different components of the pattern fit together and experimenting with the example to see how it behaves in different scenarios.

为了完全掌握一个设计模式,开发者应花时间研究一个展示该模式在实践中如何工作的具体示例。这意味着要通读代码,理解模式的不同组件如何组合在一起,并试验示例以观察它在不同场景下的行为。

By doing this, developers can build a deeper understanding of the pattern and its practical applications, which will help them implement it more effectively in their own code. They can also identify potential pitfalls or edge cases that may not be immediately apparent from just reading about the pattern in theory.

通过这样做,开发者可以建立对模式及其实际应用的更深理解,这有助于他们在自己的代码中更有效地实现它。他们还可以识别出仅从理论上阅读模式时可能不会立即显现的潜在陷阱或边界情况。

22. What is software architecture and how do you design and implement one?

什么是软件架构,您如何设计和实现一个?
  • 知识点: 系统设计/架构 (标签: interviewbit, tcs-digital, company-specific)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: general
  • 公司: Tata Consultancy Services
  • id: 69b37c6d58d557c902bc862b | 官方: 否 | 付费: 否

答案:

Software architecture is the high-level structure of a software system, and it defines the overall design and organization of the system. It specifies the components and their relationships, the patterns and styles that are used to connect the components, and the constraints and considerations that guide the design.

软件架构是软件系统的高层结构,它定义了系统的整体设计和组织。它指定了组件及其关系、用于连接组件的模式和风格,以及指导设计的约束和考虑因素。

Software architecture is an important part of the software development process, as it provides a blueprint for the system and helps to ensure that the system is scalable, maintainable, and flexible.

软件架构是软件开发过程的重要组成部分,因为它为系统提供了蓝图,并有助于确保系统具有可扩展性、可维护性和灵活性。

To design a software architecture, you need to understand the requirements of the system and the constraints and considerations that apply to the design. You also need to consider the trade-offs and trade-ins that are involved in the design, as well as the patterns and styles that are appropriate for the system.

要设计软件架构,您需要理解系统的需求以及适用于设计的约束和考虑因素。您还需要考虑设计中涉及的权衡取舍,以及适用于系统的模式和风格。

Once the software architecture is designed, the next step is to implement it. This involves implementing the components and their relationships and testing the system to ensure that it meets the specified requirements and works as intended.

一旦软件架构设计完成,下一步就是实现它。这涉及实现组件及其关系,并测试系统以确保它满足指定需求并按预期工作。

To implement a software architecture, you need to use a programming language and a set of tools and frameworks that are appropriate for the system. You also need to consider the deployment and operational requirements of the system, such as scalability, reliability, and security.

要实现软件架构,您需要使用适合系统的编程语言以及一套工具和框架。您还需要考虑系统的部署和运维需求,例如可扩展性、可靠性和安全性。

23. Can you explain the difference between a client-server architecture and a peer-to-peer architecture?

您能解释一下客户端-服务器架构和点对点架构之间的区别吗?
  • 知识点: 系统设计/架构 (标签: interviewbit, tcs-digital, company-specific)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: general
  • 公司: Tata Consultancy Services
  • id: 69b37c6d58d557c902bc8634 | 官方: 否 | 付费: 否

答案:

Client-server architecture: In a client-server architecture, a central server provides services to multiple clients over a network. The clients send requests to the server, and the server processes the requests and sends back the results. The clients do not communicate directly with each other, and all communication goes through the server.

客户端-服务器架构:在客户端-服务器架构中,中央服务器通过网络向多个客户端提供服务。客户端向服务器发送请求,服务器处理请求并返回结果。客户端之间不直接通信,所有通信都通过服务器进行。

In the above image, we can see that there is a server and multiple clients connected with it. These clients and servers are connected through a network and can communicate with each other with requests and responses. The request is made by the client to the server and the server send the response to the request.

在上图中,我们可以看到有一个服务器和多个与之连接的客户端。这些客户端和服务器通过网络连接,可以通过请求和响应进行通信。请求由客户端发送给服务器,服务器对请求发送响应。

A client-server architecture is a centralized architecture, and it has several advantages, such as: - Scalability: The server can be scaled up or down as needed to handle more or fewer clients.

客户端-服务器架构是一种集中式架构,它有几个优点,例如:- 可扩展性:服务器可以根据需要向上或向下扩展,以处理更多或更少的客户端。
  • Security: The server can be secured to protect against unauthorized access and ensure data integrity.
  • Maintenance: The server can be maintained and updated centrally, which makes it easier to manage.
    However, a client-server architecture also has some disadvantages, such as: - Dependence on the server: If the server goes down or becomes unavailable, the clients cannot communicate or access the services.

    然而,客户端-服务器架构也有一些缺点,例如:- 对服务器的依赖:如果服务器宕机或不可用,客户端将无法通信或访问服务。
  • Performance: The performance of the system may be limited by the capacity of the server.
    In a peer-to-peer (P2P) architecture, there is no central server, and the nodes in the network communicate and share resources directly with each other. Each node in a P2P network acts as both a client and a server, and it can request and provide services to other nodes.

    在对等(P2P)架构中,没有中央服务器,网络中的节点直接相互通信并共享资源。P2P网络中的每个节点同时充当客户端和服务器,可以向其他节点请求和提供服务。

Peer-to-Peer architecture: Peer-to-peer architecture is a network model in which devices or nodes communicate with each other directly without the need for a centralized server. In this model, each node can act as both a client and a server, allowing data and resources to be shared directly between nodes as shown in the image below:

对等架构:对等架构是一种网络模型,其中设备或节点直接相互通信,无需集中式服务器。在此模型中,每个节点既可以充当客户端,也可以充当服务器,允许数据和资源在节点之间直接共享,如下图所示:

Peer-to-peer architecture is commonly used in applications such as file sharing, messaging, and online gaming. Unlike the client-server architecture, peer-to-peer networks can be more decentralized and less vulnerable to server failures or attacks.

对等架构常用于文件共享、消息传递和在线游戏等应用。与客户端-服务器架构不同,对等网络可以更加去中心化,且对服务器故障或攻击的脆弱性更低。

A P2P architecture is a decentralized architecture, and it has several advantages, such as: - Decentralization: The lack of a central server makes the system more resilient and less vulnerable to failure.

P2P架构是一种去中心化架构,它有几个优点,例如:- 去中心化:缺少中央服务器使系统更具韧性,对故障的脆弱性更低。
  • Resource sharing: The nodes in the network can share resources and distribute the workload among themselves.
  • Privacy: The nodes in the network can communicate directly with each other, which can enhance privacy and security.
    However, a P2P architecture also has some disadvantages, such as: - Complexity: The complexity of the system may be increased due to the lack of a central authority or server.

    然而,P2P架构也有一些缺点,例如:- 复杂性:由于缺乏中央权威或服务器,系统的复杂性可能会增加。
  • Performance: The performance of the system may be limited by the capacity of the individual nodes in the network.
  • Security: The security of the system may be compromised due to the lack of a central authority or server.

24. 解释同步编程(Synchronous Programming)与异步编程(Asynchronous Programming)的区别。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: synchronous, asynchronous, non-blocking, parallel)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: general
  • id: 695ccbc41da5537956248fbc | 官方: 是 | 付费: 否

答案:

TL;DR同步是阻塞(Blocking)且按顺序执行;异步是非阻塞(Non-blocking),可并行处理多个任务,一个任务的执行不必等待另一个完成。
在同步编程(Synchronous Programming)中,程序执行是顺序且阻塞(Blocking)的。也就是说代码一行接一行执行,必须等待当前操作完成后才能继续下一个操作。
而异步编程(Asynchronous Programming)是一种非阻塞(Non-blocking)、并行的执行模型。多个任务可以同时运行,一个任务的执行不依赖另一个任务完成。

25. 如果遇到一个质量很差或处理不当的 PR(Pull Request),你会怎么处理?

  • 知识点: 系统设计/架构 / UI/UX 设计 / 行为与软技能 (主题: system-design;标签: PR, Code Review, Feedback, Collaboration)
  • 类型: behavioral | 难度: medium | 子类型:
  • 分类: general
  • id: 695cd80b1da5537956265288 | 官方: 是 | 付费: 否

答案:

TL;DR处理差 PR(Pull Request)的关键是:先保证交付质量,再用建设性的方式帮助作者改进,同时保持团队协作氛围。
处理步骤- 先明确问题:是否是逻辑错误、测试缺失、风格不一致、架构(Architecture)不合理?

  • 给出具体可执行反馈:指出代码位置、建议替代方案。
  • 要求补充测试与文档:确保可维护性。
  • 拆分 PR:如果 PR 过大,建议拆成小块。
  • 必要时同步沟通:用 call 或 pair review 提高效率。
  • 升级处理:重复出现时,与 TL/Manager 对齐规范。

26. 在设计排行榜系统(Leaderboard System)时,面试中你应该问面试官哪些关键需求问题?(功能与非功能)

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: requirement-clarification, functional, non-functional)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695df6661da553795635b2b7 | 官方: 是 | 付费: 否

答案:

TL;DR系统设计(System Design)第一步是澄清需求。你应覆盖功能需求(Functional Requirements)和非功能需求(Non-functional Requirements)(规模、性能、一致性等)。
功能需求问题(Functional Requirements)- 系统的核心用例(Use Case)是什么?

  • 是否需要全局Top 10(absolute)与相对排行(relative)?
  • 用户如何查看个人排名/分数?
  • 是否需要推送通知实时更新?
  • 是否支持全球/区域/好友圈多种榜单?
  • 是否需要历史分数和历史排行榜?
  • 榜单周期是日榜/周榜/月榜?
    非功能需求问题(Non-functional Requirements)- 预期DAU(Daily Active Users)是多少?写入QPS(Queries Per Second)多少?
  • 读写比(read:write)是多少?
  • 是否必须实时?可否允许延迟?
  • 可接受多少 downtime?是否要求高可用?
  • 一致性要求如何?可否最终一致?
  • 重点关注性能/可扩展性/可靠性哪个?

27. 如何按日/周/月配置排行榜?历史榜单数据如何做冷存储(cold storage)以降低成本?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: time-based-leaderboard, daily, weekly, monthly, cold-storage)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695dfa151da5537956361dc0 | 官方: 是 | 付费: 否

答案:

TL;DR为不同时间周期建立不同的 Sorted Set(daily/weekly/monthly)。过期或低频访问的历史 Sorted Sets 可以移动到冷存储(cold storage)(如对象存储(object storage)或归档数据库(archive database))以节省成本。高频筛选条件可以预计算以提升可扩展性。
实现方式- 创建独立 key:lb:daily:2026-01-07、lb:weekly:2026-W01、lb:monthly:2026-01。

  • 每次 score 更新时同时写入对应周期榜单。
  • 过期后将旧榜单迁移到 cold storage(如 S3/Glacier/归档 DB)。
    扩展优化- 对常用过滤器(filters)(如地区、段位)进行预计算并缓存。
  • 对历史榜单使用长 TTL 缓存/只读服务。

28. 设计一个可扩展的分布式任务调度服务时,核心功能性与非功能性需求分别有哪些?哪些需求可以作为 out-of-scope?

  • 知识点: 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design;标签: functional-requirements, non-functional-requirements, scalability, high-availability, consistency)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695dfcb61da5537956365320 | 官方: 是 | 付费: 否

答案:

TL;DR功能性需求包括提交/取消任务、分发执行、任务状态监控以及避免同一任务并发重复执行。非功能性需求关注可扩展性(scalability)(百万级任务)、高可用(high availability)(无单点、节点故障自动重调度)、低延迟(low latency)与一致性(consistency)(尽量做到 exactly-once 或最小重复)。Out-of-scope 可以包括优先级(prioritization)与任务依赖(job dependency)。
Functional Requirements- 提交 one-time 或 periodic jobs

  • 取消已提交 job
  • 将 jobs 分发到多个 worker 节点执行
  • 监控 job 状态(queued/running/completed/failed)
  • 防止同一 job 被并发重复执行
    Non-Functional Requirements- Scalability:可调度并执行百万级任务
  • High Availability:无单点故障,worker 故障可重调度
  • Latency:调度与执行延迟尽可能低
  • Consistency:确保任务结果一致,尽量做到一次执行或最小重复
    Out of Scope- 任务优先级(Job prioritization)
  • 任务依赖(Job dependencies)

29. 系统如何处理任务失败(Job failure)并实现可靠重试?为什么要使用指数退避(exponential backoff)而不是立即重试?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: retries, retry_count, max_retries, exponential-backoff, transient-failure)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695dfcb71da5537956365397 | 官方: 是 | 付费: 否

答案:

TL;DR任务失败时,worker 增加 JobTable 的 retry_count。若未超过 max_retries 则重试;超过则标记为 failed 并停止。为避免瞬时故障(如网络问题)导致频繁重复失败,应采用指数退避(exponential backoff)延迟重试(例如 1 分钟、5 分钟、10 分钟)。
失败处理策略- 失败时递增 retry_count。

  • retry_count < max_retries:重新执行。
  • retry_count ≥ max_retries:标记 failed,停止执行。
    为什么使用指数退避- 瞬时故障往往短时间内无法恢复,立即重试会放大压力。
  • 指数退避降低系统风暴(retry storm)风险。
  • 提升整体稳定性与成功率。
    示例退避策略- 第 1 次重试:1 分钟后
  • 第 2 次重试:5 分钟后
  • 第 3 次重试:10 分钟后

30. 设计一个可扩展通知服务时,功能性需求与非功能性需求分别有哪些?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: functional-requirements, non-functional-requirements, rate-limiting, retry, scheduled-delivery)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695dfe111da5537956367888 | 官方: 是 | 付费: 否

答案:

TL;DR功能性需求包括:多渠道、多类型、定时发送、限流防骚扰、失败重试;非功能性需求包括:高并发可扩展、高可用、可靠投递(至少一次/特定场景仅一次)、低延迟。
Functional Requirements- Multi-channel Support(多渠道支持):支持 Email(电子邮件)、SMS(短信)、Push(推送)、In-app(应用内)等渠道。

  • Multiple Notification Types:支持交易类(订单确认)、促销类(优惠活动)、系统告警类(密码重置/故障告警)。
  • Scheduled Delivery:支持未来某个时间点发送。
  • Rate Limiting:限制每天促销消息数量,防止 spam。
  • Retry Mechanism:发送失败可重试(短信/邮件失败等)。
    Non-Functional Requirements- Scalability(可扩展性):支持百万级通知/分钟,百万并发用户。
  • High Availability:尽量少 downtime,故障情况下仍可投递。
  • Reliability:保证至少一次投递;部分场景追求仅一次语义。
  • Low latency:尽可能快速发送以保证及时性。

31. 在通知系统的规模估算中,给定 5000 万 DAU(日活跃用户)、每人每天 5 条通知、峰值 1 分钟 100 万条,你如何计算每天通知量、峰值 QPS(每秒查询数)以及存储需求?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: scale-estimation, qps, storage-estimation, dau, peak-load)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695dfe111da553795636788b | 官方: 是 | 付费: 否

答案:

TL;DR(太长不看)每日通知量 = 5000 万 × 5 = 2.5 亿/天;峰值 QPS(每秒查询数) ≈ 100 万 / 60 ≈ 17000/秒;若平均每条通知数据 1KB(千字节),则用户数据约 50GB(千兆字节),通知日志每天约 250GB(千兆字节)。
计算过程- Notifications per day(每日通知量):50M(5000万) × 5 = 250M(2.5亿)/day(天)

  • Peak notifications per second:1M / 60 ≈ ~17,000/sec
    Storage Requirements(存储需求)(假设 1KB/条)- User data(用户数据):50M(5000万) × 1KB(千字节) = 50GB(千兆字节)
  • Daily notification data:50M × 5 × 1KB = 250GB/day

32. 用户偏好服务(User Preference Service)应该管理哪些信息?它如何实现 opt-in/opt-out(选择加入/退出)、免打扰(DND)和促销消息频率限制?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: user-preference, opt-in, opt-out, dnd, rate-limits, anti-spam)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695dfe121da5537956367909 | 官方: 是 | 付费: 否

答案:

TL;DR(太长不看)用户偏好服务负责存储用户在不同通知类型下的渠道选择、退订状态、免打扰时间段和每日限额等。入口层发送前查询偏好服务,确保合规投递,并对促销类通知执行每日频率限制。
需要管理的信息- 不同通知类型(transactional(事务性)/promotional(促销性)/systemAlert(系统告警))对应的渠道偏好。

  • opt-out(例如某用户不接收 marketing email)。
  • 免打扰(DND)设置:开始/结束时间与时区。
  • 每日限额:例如促销消息每天最多 2 条,并记录已发送数量。
  • 可选:偏好投递时间段(preferred delivery time)。
    实现方式- Opt-in/Opt-out(选择加入/退出):按渠道存储布尔标记(email(电子邮件)/sms(短信)/push(推送))。发送前过滤。
  • DND:如果在 DND 时间段内则延迟发送(交给 Scheduler)或降级处理。
  • 频率限制:维护 promotionalSentToday 并与 promotionalLimit 比较,超过则拒绝或延迟。

33. 通知系统如何处理失败与重试?为什么需要指数退避(exponential backoff)和死信队列(DLQ)?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: failure-handling, retry, exponential-backoff, dlq, provider-downtime)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695dfe121da5537956367980 | 官方: 是 | 付费: 否

答案:

TL;DR(太长不看)发送失败通常是临时问题(网络抖动或第三方宕机)。Channel Processor(渠道处理器) 会用指数退避重试,避免重试风暴;超过最大重试次数则进入 DLQ(死信队列),供管理员人工审查和补偿处理。
失败与重试机制- Channel Processor(渠道处理器) 调用第三方发送时若失败,触发重试。

  • 使用 exponential backoff:每次重试间隔递增。
  • 超过最大重试次数:写入 Dead Letter Queue (DLQ)。
    为什么需要 exponential backoff(指数退避)- 避免在第三方宕机时大量瞬时重试造成系统雪崩。
  • 提升成功率:给故障恢复留时间。
    为什么需要 DLQ(死信队列)- 隔离无法投递的“坏消息”。
  • 支持人工排查与补偿重放。

34. 通知系统(Notification System)为什么需要归档(Archiving)旧数据?归档的对象通常有哪些,归档策略(Archiving Policy)如何影响成本(Cost)与查询性能(Query Performance)?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: archiving, cold-storage, cost-optimization, logs, historical-data, time-partitioning)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695dfe131da5537956367ad0 | 官方: 是 | 付费: 否

答案:

TL;DR通知系统长期运行会产生大量历史数据(投递日志(delivery logs)、通知内容(notification content)、用户历史记录(user history)等)。归档(archiving)可以将低频数据迁移到低成本存储(low-cost storage),降低主库压力并提升查询性能(query performance);同时保留审计(audit)与合规(compliance)所需的历史记录。
为什么要归档- 历史数据持续增长,主存储(primary storage)成本上升。

  • 主库数据量过大会影响查询性能与维护。
  • 审计/合规仍需要保留历史记录。
    常见归档对象- 旧的 delivery logs(投递日志(delivery logs))
  • 历史通知内容(特别是促销活动)
  • 用户通知历史记录
    策略影响- 将旧数据迁移到低成本存储(low-cost storage)(如对象存储(object storage)/冷存储(cold storage))降低成本。
  • 主库数据量减少,实时查询更快。
  • 历史查询可能需要额外检索流程(例如从冷存储回读)。

35. 分布式计数器(distributed counter)的功能性需求(functional requirements)和非功能性需求(non-functional requirements)分别是什么?这些需求会如何影响技术选型(technology selection)?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: functional-requirements, non-functional-requirements, low-latency, availability, eventual-consistency)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695dff721da55379563694ab | 官方: 是 | 付费: 否

答案:

TL;DR功能需求包括实时展示在线人数、用户退出时计数递减、以及页面变化时发送未读通知数;非功能需求强调高可用(high availability)、最终一致(eventual consistency)但准确、可靠、可扩展和低延迟(low latency)。这意味着系统需要选择高吞吐、低延迟的数据存储(data storage)与实时通信机制(real-time communication mechanism)(如 WebSocket/SSE),并避免高写锁冲突(write lock contention)的方案。
Functional Requirements- 实时显示网站或某页面当前在线用户数。

  • 用户退出时计数器需要递减。
  • 当订阅页面有更新时,用户收到未读通知数量。
    Non-Functional Requirements- Highly Available(高可用(high availability))
  • Eventually Consistent(最终一致)
  • Accurate(准确)
  • Reliable(可靠)
  • Scalable(可扩展)
  • Low Latency(低延迟)
    对选型的影响- 最终一致(eventual consistency):允许异步复制(asynchronous replication)或 CRDT(Conflict-free Replicated Data Type,无冲突复制数据类型)。
  • 准确:不能使用概率型近似数据结构作为主计数方式。
  • 高并发:避免依赖数据库锁的写路径。
  • 低延迟:更偏向内存型/分布式 KV 或 CRDT 数据库。

36. 客户端-服务器架构(client-server architecture)面临哪些挑战?如何缓解单点故障(single point of failure)和性能瓶颈(performance bottleneck)问题?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: single-point-of-failure, bottleneck, redundancy, failover, load-balancing)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695e01081da553795636b65b | 官方: 是 | 付费: 否

答案:

TL;DRClient-Server 架构的主要挑战包括单点故障(single point of failure)与性能瓶颈(performance bottleneck)。常见缓解方式包括冗余部署(redundant deployment)、故障转移(failover)、负载均衡(load balancing)、缓存(caching)与优化,并随着系统增长引入更复杂的基础设施治理(infrastructure governance)。
主要挑战- Single Point of Failure(SPOF):服务器宕机导致所有客户端受影响。

  • 性能瓶颈:服务器承载过多请求,响应变慢甚至拒绝服务。
  • 复杂度上升:随着规模增长,扩容、监控、运维变复杂。
    缓解方案- 冗余与 Failover:多实例部署,主备切换。
  • 负载均衡:用 Load Balancer 分摊请求流量。
  • 缓存:用 CDN/Redis 缓存热点数据减少服务器压力。
  • 性能优化:数据库索引、连接池、异步处理、限流等。

37. 微服务架构(microservices architecture)的关键收益有哪些?为什么它比单体架构(monolithic architecture)更容易扩展?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: independent-scaling, fault-isolation, polyglot, team-autonomy)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695e02941da553795636f496 | 官方: 是 | 付费: 否

答案:

TL;DR微服务架构的核心收益是:团队与系统可并行扩展、服务可独立部署与扩容、故障隔离(fault isolation)更好、允许技术栈(technology stack)多样化。
关键收益- 开发规模可扩展:服务更小,可由多个小团队按服务边界(service boundary)并行开发。

  • 独立部署与扩容:可以定位“热点服务”并单独扩容,而非扩容整个系统。
  • 故障隔离:一个服务出错不一定导致整个系统不可用,修复后只需单独发布该服务。
  • 技术栈灵活:不同服务可选择最适合的语言、数据库与框架,而非“一刀切”。

38. 从零开始设计微服务架构(Microservices Architecture)时,如何进行服务拆分(Decompose)?为什么推荐按业务能力(Business Capabilities)拆分?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: decomposition, business-capability, domain-driven-design, service-boundary)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695e02941da553795636f499 | 官方: 是 | 付费: 否

答案:

TL;DR微服务拆分常用方式是按业务能力(Business Capabilities)来定义服务边界。每个服务围绕一个稳定的业务领域(Business Domain),形成更稳定的 API 边界与团队 ownership(Ownership)。
拆分思路- 识别业务能力(Business Capability):业务为用户创造价值的能力。

  • 为每个能力建立一个服务:服务负责该领域内的核心数据与逻辑。
  • 团队按领域 ownership:每个团队成为该领域专家。
    为什么按业务能力拆分- 边界更稳定:业务域(Business Domain)变化通常比技术模块(Technical Module)更可控。
  • 团队更稳定:团队与领域绑定,减少跨团队反复协调。
  • API 更清晰:领域内的数据与操作通过 API 封装对外。
    示例(电商(E-commerce))- 商品目录管理(Product Catalog Management)
  • 库存管理
  • 订单管理
  • 配送管理
  • 用户管理
  • 推荐系统
  • 评论管理

39. Couchbase Server 的核心特性有哪些?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: fast, simple, elastic, reliable, low latency, high throughput)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695f6c1ad6221b0fef04c790 | 官方: 是 | 付费: 否

答案:

核心答案Couchbase Server 的核心特性通常总结为:Fast / Simple / Elastic / Reliable。
核心特性说明- Fast(快速):强调低延迟(Latency)与高吞吐(Throughput),性能开销较低。

  • Simple(简单):易于安装、运维、扩容与使用;作为文档数据库通常不需要像传统关系数据库那样管理 schema、做复杂的规范化与调优。
  • Elastic(弹性):可在虚拟机或普通服务器(commodity servers)上分布数据与 I/O,节点规模可灵活扩展或缩减以适配业务需求。
  • Reliable(可靠):企业级稳定性,适合关键任务系统(mission-critical applications)。

40. Couchbase 默认使用哪些 TCP 端口(TCP Port)对外提供服务?各自用途是什么?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: 11210, 11211, memcached, vBucket aware, consistent hashing)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 695f6c1bd6221b0fef04c80d | 官方: 是 | 付费: 否

答案:

核心答案Couchbase 的端口(Port)可配置,默认常见端口包括 11210 与 11211:
Port 11210- 面向使用 Memcached 2.0 API 的客户端(vBucket-aware)。

  • 客户端使用 hashing 算法把 key 映射到 vBucket,再由 vBucket 映射到服务器节点。
  • 这种间接层支持 Rebalance、无停机扩缩容、复制与故障切换。
    Port 11211- 传统 Memcached 端口(Port),面向使用 Memcached 1.0 API 的客户端。
  • 客户端通常基于一致性哈希(consistent hashing)直接把 key 映射到服务器列表中的某个 server。

41. Memcached 有哪些重要特性?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: memcached, caching, performance;标签: Caching)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 6964b45fa9243c30c875acf5 | 官方: 是 | 付费: 否

答案:

Memcached 常被用作分布式缓存(Distributed Cache),文中提到的特性包括:CAS Tokens(CAS Token)、Callbacks(回调函数)、GetDelayed(延迟获取)、Binary protocol(二进制协议)、Igbinary(Igbinary 序列化格式)。它们分别与并发一致性控制(Concurrency Control)、回调机制(Callback Mechanism)、延迟获取(Delayed Retrieval)、二进制通信协议(Binary Communication Protocol)以及高效序列化(Serialization)有关,用于提升缓存访问效率与减少网络/序列化开销。

42. 如果代码里有很多未使用变量和空的 catch 块,如何提升代码质量?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: maven, pmd, code-quality;标签: Static Analysis)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: backend
  • id: 6964b45fa9243c30c875ad37 | 官方: 是 | 付费: 否

答案:

可以在 Maven 构建任务中选择运行 “Run PMD”。PMD 是源码静态分析工具(Static Analysis Tool),能识别常见错误与坏味道(Code Smell),例如不必要的对象创建(Object Creation)、未使用变量(Unused Variable)、空代码块(Empty Block)等。通过 Apache Maven PMD Plugin 在构建阶段自动执行扫描,并生成详细报告,把问题提前暴露并纳入质量门禁(Quality Gate)。

43. 最熟悉的一个项目简介、架构图(Architecture Diagram)、使用的技术(Technology Stack)、你负责哪块。

  • 知识点: 系统设计/架构 / UI/UX 设计 / 行为与软技能 (主题: system-design, architecture;标签: 项目介绍, 架构图, 职责)
  • 类型: behavioral | 难度: medium | 子类型:
  • 分类: general
  • id: 6965b95fa9243c30c8824c55 | 官方: 是 | 付费: 否

答案:

补充答案可按“背景-目标-架构(Architecture)-技术(Technology)-规模(Scale)-职责-结果-复盘”结构回答:

  • 项目背景/业务问题:项目为了解决什么痛点?服务对象是谁?
  • 目标:核心指标(性能、成本、稳定性、时效、转化等)。
  • 架构图讲解:入口层(API/Gateway)→ 服务层(核心服务、异步任务)→ 数据层(DB/Cache/消息队列/大数据组件)→ 监控告警(指标、日志、链路)。
  • 技术栈:语言/框架、存储、消息、计算(如 Spark/Hive/HBase)、CI/CD、容器与云。
  • 数据量/并发:QPS、日增量、峰值、延迟。
  • 你负责的模块:边界清晰(我负责 A:从需求到上线;B:性能优化;C:排障/监控)。
  • 产出与效果:上线后指标提升、成本下降、稳定性提升。
  • 挑战与复盘:遇到的最大问题与解决方案,后续优化方向。

44. What are the differences between junior and senior software engineer interviews at Atlassian?

Atlassian 的初级和高级软件工程师面试有什么区别?
  • 知识点: 系统设计/架构 / UI/UX 设计 / 行为与软技能 (主题: system-design, leadership;标签: Leveling, P30-P60)
  • 类型: behavioral | 难度: medium | 子类型: scenario
  • 分类: general
  • 公司: Atlassian
  • id: 6979de4fc8f1f94b6462c73a | 官方: 是 | 付费: 否

答案:

Junior(常见 P30–P40)更看重基础解题能力、代码整洁习惯、学习敏捷性(Learning Agility)与入门级系统设计思维(System Design Thinking);Senior(P50+)会深入到分布式系统(Distributed System)的韧性与架构取舍(Architectural Trade-off),期待你展现领导力(Leadership)(带人、影响力、跨团队推动)以及在不确定性下做决策的能力。

45. 请解释 CAP 定理(CAP Theorem),并举例说明在分布式系统(Distributed System)中如何做出权衡。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: distributed-systems, system-design;标签: afterpay, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: backend
  • 公司: Afterpay (Block)
  • id: 69b3791d58d557c902b97592 | 官方: 是 | 付费: 是

答案:

思路分析解释一致性(Consistency)、可用性(Availability)、分区容忍性(Partition Tolerance)三者不可兼得,然后结合实际系统举例。
参考答案CAP 定理(CAP Theorem):网络分区(Network Partition)发生时,只能在一致性(Consistency)和可用性(Availability)间选择。CP: ZooKeeper, HBase。AP: Cassandra, DynamoDB。实际中通常选择最终一致性(Eventual Consistency)。
评分要点- CAP 定理(CAP Theorem)核心理解

  • 实际系统的 CAP 分类
  • 最终一致性的实现方式
    常见追问- Afterpay BNPL(Buy Now Pay Later)的系统偏 CP 还是 AP?为什么?
  • PACELC 定理了解吗?

46. 设计一个类似 Taobao 的核心系统架构(System Architecture),需要支持高并发(High Concurrency)和低延迟(Low Latency)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: alibaba, generated)
  • 类型: technical | 难度: medium | 子类型: system-design
  • 分类: backend
  • 公司: 阿里巴巴
  • id: 69b3792a58d557c902b9818c | 官方: 是 | 付费: 是

答案:

思路分析从需求出发:用户量级(User Scale)、QPS 预估(QPS Estimation)、数据量(Data Volume)。然后设计整体架构、存储选型(Storage Selection)、缓存策略(Caching Strategy)、负载均衡(Load Balancing)。
参考答案分层架构(Layered Architecture):CDN(Content Delivery Network) → Load Balancer(负载均衡器) → API Gateway(API网关) → Microservices(微服务) → Database/Cache(数据库/缓存)。关键考虑:读写分离(Read-Write Separation)、分库分表(Database Sharding)、消息队列(Message Queue)解耦、缓存多级策略(Multi-level Caching Strategy)。
评分要点- 需求分析和容量估算(Capacity Estimation)

  • 合理的技术选型
  • 可扩展性和高可用设计
  • 数据一致性和分区容错权衡
    常见追问- 如何处理热点数据(Hot Data)?
  • 如何实现跨区域容灾?
  • 数据库如何水平扩展?

47. 设计一个分布式消息队列系统(Distributed Message Queue System),类似 Kafka,需要支持高吞吐量(High Throughput)和消息持久化(Message Persistence)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: alibaba, generated)
  • 类型: technical | 难度: medium | 子类型: system-design
  • 分类: backend
  • 公司: 阿里巴巴
  • id: 69b3792a58d557c902b98196 | 官方: 是 | 付费: 是

答案:

思路分析考虑 Topic/Partition 模型、消息存储(Message Storage)、消费者组(Consumer Group)、复制策略(Replication Strategy)。
参考答案核心设计:Topic 分 Partition,Partition 有 Leader/Follower 副本(Replica)。顺序写磁盘(Sequential Disk Write) + 零拷贝(Zero-copy)实现高吞吐。Consumer Group 保证并行消费。
评分要点- 分区(Partition)和副本(Replica)设计

  • 消息持久化和高吞吐优化
  • 消费者组协调
  • Exactly-once 语义实现
    常见追问- 如何保证消息有序?
  • 消费者 rebalance 如何处理?

48. 设计一个 URL 短链接(Short URL)服务,每天需要处理 1 亿次请求。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: alibaba, generated)
  • 类型: technical | 难度: medium | 子类型: system-design
  • 分类: backend
  • 公司: 阿里巴巴
  • id: 69b3792a58d557c902b9819c | 官方: 是 | 付费: 是

答案:

思路分析核心问题:短链生成算法(Short URL Generation Algorithm)、存储方案(Storage Solution)、重定向性能(Redirect Performance)。需估算 QPS(Queries Per Second,约 1200/s)和存储容量(Storage Capacity)。
参考答案短链生成:Base62 编码(Base62 Encoding) + 分布式 ID(Distributed ID)。存储:KV Store(Key-Value Store,Redis 缓存 + 持久化 DB)。301/302 重定向(Redirect)选择。CDN(Content Delivery Network)缓存热门链接。
评分要点- 短链生成方案对比(哈希(Hash) vs 自增 ID(Auto-increment ID) vs 预生成(Pre-generation))

  • 读写比例分析和缓存设计
  • 分析链接过期和清理策略
    常见追问- 如何防止恶意短链(Malicious Short URL)?
  • 如何实现链接点击分析?

49. 设计一个类似 TikTok 的核心系统架构(System Architecture),需要支持高并发(High Concurrency)和低延迟(Low Latency)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: bytedance, generated)
  • 类型: technical | 难度: medium | 子类型: system-design
  • 分类: backend
  • 公司: 字节跳动
  • id: 69b379a958d557c902b9e789 | 官方: 是 | 付费: 是

答案:

思路分析从需求出发:用户量级(User Scale)、QPS 预估(QPS Estimation)、数据量(Data Volume)。然后设计整体架构、存储选型(Storage Selection)、缓存策略(Caching Strategy)、负载均衡(Load Balancing)。
参考答案分层架构(Layered Architecture):CDN(Content Delivery Network) → Load Balancer(负载均衡器) → API Gateway(API网关) → Microservices(微服务) → Database/Cache(数据库/缓存)。关键考虑:读写分离(Read-Write Separation)、分库分表(Database Sharding)、消息队列(Message Queue)解耦、缓存多级策略(Multi-level Caching Strategy)。
评分要点- 需求分析和容量估算(Capacity Estimation)

  • 合理的技术选型
  • 可扩展性和高可用设计
  • 数据一致性和分区容错权衡
    常见追问- 如何处理热点数据(Hot Data)?
  • 如何实现跨区域容灾?
  • 数据库如何水平扩展?

50. 设计一个类似 Mavic Series 的核心系统架构(System Architecture),需要支持高并发(High Concurrency)和低延迟(Low Latency)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: dji, generated)
  • 类型: technical | 难度: medium | 子类型: system-design
  • 分类: backend
  • 公司: 大疆创新
  • id: 69b37a8558d557c902ba776a | 官方: 是 | 付费: 是

答案:

思路分析从需求出发:用户量级(User Scale)、QPS 预估(QPS Estimation)、数据量(Data Volume)。然后设计整体架构、存储选型(Storage Selection)、缓存策略(Caching Strategy)、负载均衡(Load Balancing)。
参考答案分层架构(Layered Architecture):CDN(Content Delivery Network) → Load Balancer(负载均衡器) → API Gateway(API网关) → Microservices(微服务) → Database/Cache(数据库/缓存)。关键考虑:读写分离(Read-Write Separation)、分库分表(Database Sharding)、消息队列(Message Queue)解耦、缓存多级策略(Multi-level Caching Strategy)。
评分要点- 需求分析和容量估算(Capacity Estimation)

  • 合理的技术选型
  • 可扩展性和高可用设计
  • 数据一致性和分区容错权衡
    常见追问- 如何处理热点数据(Hot Data)?
  • 如何实现跨区域容灾?
  • 数据库如何水平扩展?

51. 在排行榜系统(Leaderboard System)中如何进行容量评估(Capacity Evaluation)?请解释需要估算哪些指标(Traffic(流量)/Memory(内存)/Storage(存储)/Bandwidth(带宽)),以及这些估算对系统设计(System Design)有什么帮助。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: qps, storage, bandwidth, scaling)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695df6661da553795635b2d0 | 官方: 是 | 付费: 否

答案:

TL;DR容量评估(Capacity Evaluation)用于在设计前粗略计算系统规模,帮助你选择合适的存储(Storage)、缓存(Cache)、分片方式(Sharding)与架构(Architecture)。关键估算包括:QPS(Queries Per Second,每秒查询数)(读写流量)、内存占用(Memory Usage)、长期存储量(Long-term Storage)、网络带宽(Network Bandwidth)。
需要估算的指标- Traffic(流量):DAU(Daily Active Users,日活跃用户数)、写入QPS(Write QPS)、读写比(Read-Write Ratio)、峰值QPS(Peak QPS)

  • Memory(内存):单条记录大小 × 总玩家数,用于评估 Redis/缓存容量
  • Storage(存储):每日写入数据量 × 保留年限,用于评估数据库/对象存储
  • Bandwidth(带宽):Ingress/Egress,评估网络瓶颈与CDN/压缩策略
    估算的作用- 判断是否必须用 Redis/NoSQL 等高性能存储(High-performance Storage)
  • 提前规划分片/副本/多机房
  • 确定缓存层大小与淘汰策略
  • 为 SLA(延迟/可用性)提供依据

52. 排行榜系统如何通过 Write-behind Cache Pattern(写后缓存模式)提升可扩展性(Scalability)?与数据库分区(Database Partitioning)相比有什么权衡(Trade-off)?

  • 知识点: 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design;标签: write-behind, cache, scalability, durability)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695df7bb1da553795635d805 | 官方: 是 | 付费: 否

答案:

TL;DRWrite-behind 的核心是“先写缓存(Cache)、后异步写数据库(Database)”。它让读请求也直接访问缓存获取最新数据,从而降低数据库写入压力并提升实时性(Real-time);但它带来一致性(Consistency)与故障恢复(Fault Recovery)复杂度。数据库分区(Database Partitioning)可提升写吞吐(Write Throughput)与耐久性(Durability),但会增加跨分片查询(Cross-shard Query)、事务一致性(Transaction Consistency)和运维复杂度(Operational Complexity)。
Write-behind 的工作方式- 写入先落在 Redis(Sorted Set(有序集合))确保实时排名可见。

  • 异步任务将写入批量/延迟落库到 RDBMS,减少同步写压力。
  • 后续读取也优先从缓存读(read-through),避免读打到 DB。
    优点- 降低数据库写入瓶颈(Write Bottleneck)
  • 实时可见(写入后立刻可读)
  • 支持高并发和突发流量
    缺点与风险- 缓存与数据库可能短暂不一致(最终一致(Eventual Consistency))
  • 异步落库失败需要重试/补偿机制
  • 需要处理缓存丢失/数据回放/幂等写入
    与数据库分区的权衡- 分区优势:提升 DB(Database)写吞吐与数据持久性(Persistence)能力。
  • 分区代价:增加跨分片聚合与排行计算复杂度。
  • 组合方案:Redis 实时排行 + DB 分区做长期落库与分析,是常见实践。

53. 如果用 player-id 作为分片键(Shard Key),如何让“查询某玩家分数与排名”变得简单?请说明具体查询流程(Query Workflow)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: player-id-sharding, ranking, two-step-query, metadata-cache)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695dfa151da5537956361dc9 | 官方: 是 | 付费: 否

答案:

TL;DR将玩家元数据缓存(Players Cache)按 player_id 分片,可以快速定位某个玩家所在 shard,从而轻松获取该玩家 score(分数)。之后再使用 score 去查询 leaderboard cache(排行榜缓存)(按 score 分片)来计算 rank(排名),实现“两步查询(Two-step Query)”。
查询流程(Two-step Workflow)- 查询 players cache(按 player_id 分片)获取玩家的 score(分数)。

  • 带着 score 去 leaderboard cache(按 score 分片或范围分片)查询该 score 对应的排名信息。
    为什么更简单?- player_id 是确定性的路由 key,不随 score 变化。
  • 玩家分数获取是 O(1) 定位 shard。

54. 一致性哈希(Consistent Hashing)在排行榜分片(Leaderboard Sharding)中的特点是什么?为什么需要 scatter-gather(散射-聚合)?它对读性能(Read Performance)有什么影响?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: consistent-hashing, scatter-gather, rank-calculation, read-performance)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695dfa151da5537956361dd2 | 官方: 是 | 付费: 否

答案:

TL;DR一致性哈希(consistent hashing)会导致 key 在 shard 间非连续分布,因此要计算全局 TopN 或排名,需要对所有 shard 执行查询再合并(scatter-gather)。这提升了设计复杂度,并使读延迟受最慢 shard 影响。
特点- 数据 key 非连续分布到多个 shard。

  • 节点变化时减少部分迁移,但仍存在运维复杂度。
    为什么需要 scatter-gather- Top 10 分布在不同 shard,必须“scatter”查询每个 shard 的 Top candidates。
  • 再在服务端“gather”合并并排序得到最终结果。
    对读性能影响- 可并行查询多个 shard 提升平均延迟。
  • 整体延迟 = 最慢 shard 的响应时间(tail latency)。
  • 增加合并排序的 CPU 开销。

55. 在分片场景下,如何通过 scatter-gather 获取 Top 10?请说明具体步骤、并行化方式以及延迟瓶颈。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: scatter-gather, top10, parallel-queries, tail-latency)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695dfa151da5537956361dd8 | 官方: 是 | 付费: 否

答案:

TL;DRScatter-gather Top 10 的流程是:并行查询各 shard 的 Top 候选 → 合并结果 → 再排序取前 10。并行化可降低平均延迟,但最终延迟受最慢 shard 影响(tail latency)。
步骤- Scatter:服务端并行查询所有 shards,取每个 shard 的 Top players。

  • Gather:合并所有 shard 的候选结果。
  • Sort:按 score 降序排序并截取 Top 10。
    并行化- 对 shards 的查询可以并行执行(线程池/异步 IO)。
  • 减少平均响应时间。
    延迟瓶颈- 整体延迟 = 最慢 shard 的查询时间。
  • 热门 shard 可做 leader-follower 复制以缓解热点。

56. 在排行榜系统设计中,如何实现高可用(High Availability)?什么是可降级(degradable components)?为什么需要 rate limiting 与 throttling?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: high-availability, degradation, rate-limiting, throttling, criticality)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695dfa151da5537956361de4 | 官方: 是 | 付费: 否

答案:

TL;DR高可用可以通过将服务设计为可降级组件实现:当系统压力过大时,优先保证关键功能(如分数更新、榜单查询),对非关键功能(如个性化、复杂查询)进行限流与降级。必要时可关闭非关键服务以避免全局性能崩溃。
可降级组件(Degradable Components)- 系统在高负载或部分故障时仍能提供核心功能。

  • 非关键能力可降低质量或暂时不可用。
    为什么要 rate limiting 与 throttling- 避免热点请求导致延迟扩散(latency amplification)。
  • 保护下游(DB/Redis)不被压垮。
  • 防止系统进入雪崩或级联故障。
    服务分级- Critical:分数更新、TopN、rank 查询。
  • Non-critical:推送、历史查询、复杂过滤、好友圈合并等。
    扩展建议- 峰值期间对非关键功能限流。
  • 结合 autoscaling 和监控告警自动触发降级策略。

57. 如何在排行榜系统中实现低延迟(Low Latency)?为什么异步落库、客户端缓存和 CDN 会提升性能?如何通过分页降低 ZREVRANGE 的最坏情况延迟?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: low-latency, async-write, cdn, client-cache, pagination, zrevrange)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695dfa151da5537956361de7 | 官方: 是 | 付费: 否

答案:

TL;DR低延迟的关键是让请求尽量在离用户更近的地方完成:多 AZ(Availability Zone)部署减少网络延迟(Latency);异步落库(Asynchronous Persistence)减少写路径阻塞;客户端缓存(Client-Side Caching)与 CDN(Content Delivery Network)减少回源(Origin Fetch);Redis Sorted Set 保证核心查询在 O(log(n)) 级别完成。对于榜单列表(Leaderboard),应使用分页(Pagination)避免 ZREVRANGE 在返回大量数据时变成线性复杂度(Linear Complexity)。
核心手段- 多可用区/多区域部署:靠近用户减少 RTT(Round-Trip Time)。

  • 异步写入数据库:score changes 先写 Redis,再异步落库。
  • 客户端缓存:减少重复请求。
  • CDN:对热门榜单或历史榜单做边缘缓存。
    为什么分页能降低延迟ZREVRANGE 的复杂度为 O(log(n) + m),当 m 很大(例如返回整个榜单)时最坏情况下接近线性。通过分页(每页返回固定数量 m)可以将单次查询延迟(Query Latency)控制在稳定范围。
    示例:分页查询redis> ZREVRANGE leaderboard 0 49 # page 1
    redis> ZREVRANGE leaderboard 50 99 # page 2

    redis> ZREVRANGE leaderboard 50 99 # 第2页

58. 如何提高排行榜系统的可靠性(Reliability)?请说明监控(Monitoring)、缓存保护(Cache Protection)、checkpoint、主从复制(Master-Slave Replication)、快照(Snapshot)、TTL cache、限流(Rate Limiting)与熔断(Circuit Breaking)等手段。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: prometheus, grafana, checkpoint, replication, snapshot, rate-limiter, circuit-breaker)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695dfa151da5537956361ded | 官方: 是 | 付费: 否

答案:

TL;DR可靠性依赖可观测性(Observability)与容灾能力:用 Prometheus+Grafana 监控;缓存层保护下游;Redis checkpoint 持久化;leader-follower 提供故障切换(Failover);数据库快照增强恢复(Recovery);反向代理(Reverse Proxy)与 CDN 做 TTL cache;再结合限流与熔断防止级联故障(Cascading Failure);存储层副本因子(Replication Factor)至少 3 提升耐久性(Durability)。
手段清单- 监控:Prometheus 时序数据库(Time-Series Database) + Grafana dashboard。

  • 缓存保护:internal cache 防止服务被流量击穿。
  • Checkpoint:缓存服务器 checkpoint 到磁盘以容灾。
  • 主从复制:leader-follower 拓扑支持 failover。
  • 快照:关系型数据库 snapshot 增强可恢复性。
  • TTL cache:reverse proxy + CDN 支持容错读取。
  • 限流:rate limiter 防止请求过载。
  • 熔断:circuit breaker 提升容错。
  • 副本因子:存储层 replication factor ≥ 3。

59. 如何水平扩展 Scheduling Service 并确保同一任务不会被多个调度 worker 重复处理?请解释 segment 方案与 coordinator 的作用。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: horizontal-scaling, segments, coordinator, heartbeats, workload-rebalancing, single-point-of-failure)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695dfcb71da5537956365391 | 官方: 是 | 付费: 否

答案:

TL;DR当某一分钟需要处理大量任务时,单节点调度会成为瓶颈且存在单点故障(Single Point of Failure)。解决方案是引入多个 scheduling worker 并把 schedules 表的任务划分为segments(段):每个 worker 只处理指定 segment 的任务,coordinator(协调器)负责分配 segment、监控 worker 健康,并在故障或扩容时动态 rebalance(再平衡)。
为什么需要分布式调度- 高峰期(例如 50,000 jobs/min)单节点会过载导致延迟。

  • 单节点是 SPOF,故障会导致调度停摆。
    Segment 方案- 在 JobSchedulesTable 增加 segment 列(如 segment=1,2,...)。
  • 每个调度 worker 被分配处理部分 segments,避免重复。
    Coordinator 的职责- 分配 segments 给各 scheduling workers。
  • 通过 heartbeats/health checks 监控 worker。
  • 在 worker 故障、新增 worker 或流量激增时动态调整 segment 分配。
    示例查询(带 segment)SELECT * FROM JobSchedulesTable
    WHERE next_run_time = 1726110000 AND segment IN (1,2);

    WHERE next_run_time = 1726110000 AND segment IN (1,2);

60. 如何避免 coordinator 成为单点故障(SPOF)?请解释多 coordinator + leader election 的机制,以及 Raft/Paxos、Zookeeper/etcd 的作用。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: leader-election, raft, paxos, zookeeper, etcd, failover, shared-state)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695dfcb71da553795636539a | 官方: 是 | 付费: 否

答案:

TL;DR为避免 coordinator 成为 SPOF,需要部署多个 coordinator,并通过leader election(领导者选举)机制保证只有一个 active leader(活动领导者),其它为 standby(备用)。leader 失败时自动 failover(故障转移),选出新 leader 接管调度、worker 管理与健康监控。leader election 可用 Raft/Paxos 等一致性协议(Consensus Protocol),常用工具是 Zookeeper 或 etcd。同时多个 coordinator 需共享最新状态(存储在分布式数据库中)。
方案结构- 部署多个 coordinator 节点。

  • 通过 leader election 选出 active leader。
  • leader failure 后自动选举新 leader。
    Leader Election(Leader选举)- 使用一致性算法(Consensus Algorithm):Raft 或 Paxos。
  • 使用工具:Zookeeper 或 etcd 管理 leader election。
    Failover(故障转移)- leader 宕机后,其它节点检测失败并完成选举(Leader Election)。
  • 新 leader 立即接管调度与管理职责,保证系统不中断。
    Shared State(共享状态) / 数据同步(Data Synchronization)- 多个 coordinator 必须访问同一份共享状态(job scheduling 数据、worker health)。
  • 可存储在分布式数据库(如 Cassandra、DynamoDB)。

61. 为什么不推荐用关系型数据库(Relational Database)构建互联网规模的分布式计数器(Distributed Counter)?高并发写、复制拓扑(Replication Topology)与一致性要求(Consistency Requirement)会带来哪些问题?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: relational-db, locks, replication, leader-follower, leader-leader, write-congestion, spof)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695dff721da553795636952b | 官方: 是 | 付费: 否

答案:

TL;DR关系型数据库在互联网规模计数器中会遭遇写锁冲突(Write Lock Contention)、leader 写入拥塞(Leader Write Congestion)、复制延迟(Replication Lag)与跨机房幂等(Idempotency)难题。计数器是高并发写、对事务要求低但对可用性要求高的场景,关系型数据库的事务(Transaction)与磁盘写入开销反而成为瓶颈,因此不推荐作为核心计数存储。
主要问题- 锁导致写瓶颈:强一致(Strong Consistency)实现常依赖锁(mutex/read-write lock),高并发写会严重冲突。

  • 批量写入方案不可靠:本地缓存聚合再批写会引入延迟导致计数不准;服务崩溃会造成不可恢复的数据丢失。
  • 多记录写入降低写锁:虽然写更并发,但读需要全表扫描,导致读慢且存储成本上升,需要索引又会拖慢写。
  • 分片后读变慢:sharded counter 写入可分散,但读取需要对所有 shard 做 scatter-gather 求和,读延迟增加。
  • 复制拓扑问题:leader-follower 会产生 leader 写入拥塞;leader-leader 需要冲突解决服务。
  • 跨数据中心幂等难:计数更新复制时很难保证 idempotency,且事务支持对该场景并非必需。
    结论分布式计数器应优先可用性(Availability)与低延迟(Low Latency),而关系型数据库的事务、磁盘写、复制(Replication)与锁机制(Locking Mechanism)会在高并发计数场景成为系统瓶颈。

62. CRDT(Conflict-free Replicated Data Type,无冲突复制数据类型)为什么适合实现跨数据中心的分布式计数器?它如何保证最终收敛(Eventual Convergence)与去重(Deduplication)?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: crdt, eventual-consistency, multi-leader, convergence, idempotence, gossip, vector-clock)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695e00311da5537956369ef5 | 官方: 是 | 付费: 否

答案:

TL;DRCRDT 通过预定义的数学性质(交换律(Commutativity)、结合律(Associativity)、幂等性(Idempotency))保证多副本并发更新后最终自动收敛到一致状态,无需分布式锁(Distributed Lock)或中心协调(Central Coordination),因此非常适合跨数据中心、多 leader、允许网络分区(Network Partition)的分布式计数器场景。CRDT 的幂等性能够防止复制过程中重复应用同一更新导致计数错误。
为什么 CRDT 适合分布式计数器- 多 leader 写入:任意副本可写入,提供本地低延迟。

  • 容忍网络分区:断网的节点仍可接受写,恢复后异步合并。
  • 自动冲突解决:冲突语义由 CRDT 定义,自动且确定性。
  • 无需协调:支持无锁并发读写。
    CRDT 如何保证最终收敛CRDT 严格依赖以下数学性质:
  • Commutative:a b = b a
  • Associative:a (b c) = (a b) c
  • Idempotence:a * a = a
    其中幂等性保证复制过程中重复更新不会导致双计数;交换律保证更新顺序不同也能得到同样结果,从而避免 race condition(竞态条件)。
    常见冲突解决方案对比- LWW(Last-Writer-Wins,后写胜出):依赖时间戳,难同步时钟(Clock Synchronization)。
  • Quorum:等多数副本确认,增加网络延迟。
  • Merge service:逻辑复杂且容易出 bug。
  • CRDT:数学收敛,冲突语义固定但稳定可靠。

63. 如何在生产环境中修改微服务(Microservice)API 而不影响依赖它的服务?有哪些常见策略与权衡?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: backward-compatibility, api-versioning, endpoint-evolution, migration)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695e02941da553795636f51b | 官方: 是 | 付费: 否

答案:

TL;DR生产环境修改微服务 API 的核心是保持向后兼容(Backward Compatibility)并支持渐进迁移(Incremental Migration)。常见策略包括API 版本化(Versioning)与同服务新增 endpoint(端点)两类。
策略 1:API 版本化(Versioning)- 发布新版本 API,同时保留旧版本。

  • 依赖方按自己的节奏迁移。
  • 全部迁移完成后再下线旧版本。
    权衡:版本多会增加维护成本,Bug(故障)修复和新功能可能需要同时改多个版本。
    策略 2:同服务新增 endpoint(端点)(Non-breaking evolution(非破坏性演进))- 需要变更时增加新的 endpoint(端点)。
  • 所有服务都切换到新 endpoint 后,删除旧 endpoint。
    优势:维护成本更低,服务内只保留一套 API(应用程序接口)(最终)。

64. 为什么在微服务(Microservices)体系中需要 API Gateway(API网关)和 Service Discovery(服务发现)?它们分别解决什么问题?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: api-gateway, service-discovery, dynamic-instances, routing)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695e02941da553795636f521 | 官方: 是 | 付费: 否

答案:

TL;DR(摘要)随着微服务数量增长,服务实例与地址(host/port(主机/端口))动态变化、协议多样化、依赖复杂。API Gateway(API网关)提供统一入口与跨切面能力;Service Discovery(服务发现)解决动态服务定位与路由问题。
API Gateway(API网关)解决的问题- 统一入口:所有客户端通过网关访问后端服务。

  • 按客户端定制 API:不同客户端可暴露不同 API。
  • 安全与治理:鉴权、限流、日志、协议转换等。
    Service Discovery(服务发现)解决的问题- 动态寻址:服务实例数量与位置经常变化(弹性伸缩(Elastic Scaling))。
  • 自动注册与发现:避免硬编码地址。
  • 健康检查与路由:只路由到健康实例。
    常见实现- Zookeeper(动物园管理员)(可用但并非专为此设计)
  • etcd、Consul(更现代的服务发现工具)

65. 微服务为什么不是天然具备韧性(resilient(韧性))的?Bulkhead(舱壁)和 Circuit Breaker(断路器)分别是什么?解决什么问题?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: resilience, bulkhead, circuit-breaker, failure-isolation, timeouts)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695e02941da553795636f524 | 官方: 是 | 付费: 否

答案:

TL;DR(摘要)微服务天然分布式,网络超时、依赖服务故障、bug(故障)都会引发连锁失败,因此需要韧性模式保证"局部故障不拖垮全局"。Bulkhead(舱壁)用隔离防止故障扩散;Circuit Breaker(断路器)用熔断避免持续调用失败服务。
为什么微服务不天然韧性- 服务之间存在依赖链,依赖服务失败会向上传播。

  • 网络超时、重试风暴、资源耗尽可能导致级联故障。
  • 更多分布式组件意味着更多失败点。
    Bulkhead(舱壁)模式将系统划分为多个隔离的资源池(线程池/连接池等)。某一部分失败或被耗尽时,其他部分仍可继续运行,避免"拖全船下水"。
    Circuit Breaker(断路器/熔断)模式在调用外部/下游服务时包裹一个熔断器:监测失败率,超过阈值则短路直接返回错误,在一段时间内不再调用下游服务。超时后允许少量探测请求,如果成功则恢复。

66. Couchbase Server(Couchbase服务器)包含哪些功能模块?请简要说明

  • 知识点: 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design;标签: Data Manager, Cluster Manager, vBucket aware, rebalance, Erlang, C++)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695f6c1ad6221b0fef04c79e | 官方: 是 | 付费: 否

答案:

核心答案Couchbase Server(Couchbase服务器)主要包含两个功能模块(functional blocks(功能块)):Data Manager(数据管理器)与 Cluster Manager(集群管理器)。
1) Data Manager(数据管理器)- 职责:负责存储与提取应用数据,以满足数据处理需求。

  • 接口:对外暴露两个 Memcached 相关端口:一个支持非 vBucket-aware 客户端,另一个支持 vBucket-aware 客户端。
  • 实现语言:核心代码主要用 C / C++ 实现。
    2) Cluster Manager(集群管理器)- 职责:负责 Couchbase 集群中所有节点的配置编排(configuration orchestration)与运行管理(runtime management)。
  • 机制:Cluster Manager 在每个节点上运行,并选举一个节点作为协调节点(aggregation)。
  • 实现语言:大部分实现基于 Erlang/OTP。

67. 什么是 vBucket(虚拟桶)?它在 Couchbase 中有什么作用?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: vBucket, logical partition, rebalance, data distribution, indirection layer)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695f6c1ad6221b0fef04c7a3 | 官方: 是 | 付费: 否

答案:

核心答案vBucket(Virtual Bucket)是一种逻辑分区(logical partition)机制,用于把数据分布到集群中的不同节点上,并提供一层“间接映射(indirection)”以支持动态扩缩容和 Rebalance(再平衡)。
关键点- 每个 Couchbase bucket(桶)会自动被拆分成固定数量的 vBuckets(虚拟桶)。

  • vBuckets 会再映射到具体的服务器节点,从而实现数据在集群中的均匀分布。
  • 这种间接层让集群在扩容/缩容、故障切换、复制与 Rebalance 时更稳定且更少中断。

68. Couchbase 每个节点上运行的 4 个子系统(subsystem)是什么?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: watchdog, progression monitor, pattern manager, singleton supervisor, cluster head election)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695f6c1ad6221b0fef04c7d9 | 官方: 是 | 付费: 否

答案:

核心答案在 Couchbase 集群中,每个节点通常包含 4 个子系统来支持健康检查(health check)、配置同步(configuration synchronization)与主节点选举(master election):

  • Pulses:Watchdog 定期与当前集群 leader 通信,汇报健康状态(health status)。
  • Progression Monitor:监控本地数据管理执行情况,必要时重启失败进程,并把状态信息反馈给 Pulses。
  • Pattern Manager:维护和处理本地配置(如 vBucket map、intent map 等),负责接收、监控和处理配置变化。
  • Worldwide Singleton Supervisor:负责在 leader 宕机时触发重新选举,并监控“集群级别”的行为,确保集群一致性。

69. vBucket Map(虚拟桶映射)表示什么?它与 Rebalance(再平衡)有什么关系?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: vBucket map, rebalance, target map, current map, orchestrator)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 695f6c1bd6221b0fef04c7e2 | 官方: 是 | 付费: 否

答案:

核心答案vBucket Map 用于描述 vBucket 到各服务器节点的映射状态,它表示集群在一次 Rebalance(再平衡)完成后的目标分布状态。
与 Rebalance(再平衡)的关系- Rebalance 会生成Target vBucket Map(目标虚拟桶映射)与Current vBucket Map(当前虚拟桶映射)。

  • Rebalance Orchestrator 对比 current 与 target maps,决定需要创建哪些数据迁移流(如 Tap Streams)来移动数据。
  • 当 Current vBucket Map 与 Target vBucket Map 一致时,说明 Rebalance 完成。

70. 什么是 Dogpile effect(缓存雪崩/击穿)?如何预防?

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: caching, performance, reliability;标签: Cache Stampede)
  • 类型: technical | 难度: hard | 子类型:
  • 分类: backend
  • id: 6964b45fa9243c30c875acf9 | 官方: 是 | 付费: 否

答案:

Dogpile effect(也叫 cache stampede(缓存踩踏))指缓存刚过期时,大量请求同时打到后端,造成瞬时高负载甚至服务不可用。常见预防方式是使用信号量/互斥锁(semaphore lock)或“单飞”(singleflight)机制:在缓存失效后只允许一个请求去重建缓存,其余请求等待或返回旧值/降级结果,从而避免后端被并发击穿。

71. 设计一个分布式缓存系统(类似 Redis Cluster(Redis 集群)),支持数据分片(data sharding)和高可用(high availability)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: alibaba, generated)
  • 类型: technical | 难度: hard | 子类型: system-design
  • 分类: backend
  • 公司: 阿里巴巴
  • id: 69b3792a58d557c902b981a1 | 官方: 是 | 付费: 是

答案:

思路分析关键问题:一致性哈希(consistent hashing)分片、数据复制(data replication)、故障检测(failure detection)和自动故障转移(automatic failover)。
参考答案一致性哈希环(consistent hash ring)进行分片。每个分片主从复制(master-slave replication)。Gossip 协议(流言协议)进行节点发现和故障检测。客户端智能路由(smart routing)或代理模式(proxy mode)。
评分要点- 一致性哈希原理和虚拟节点(virtual node)

  • 主从复制和故障转移
  • 缓存穿透/击穿/雪崩处理
    常见追问- 如何处理热 key(hot key)问题?
  • 缓存和数据库一致性如何保证?

72. 设计一个分布式限流系统(distributed rate limiting system),支持多种限流策略(rate limiting strategies)(固定窗口(fixed window)、滑动窗口(sliding window)、令牌桶(token bucket))。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: alibaba, generated)
  • 类型: technical | 难度: hard | 子类型: system-design
  • 分类: backend
  • 公司: 阿里巴巴
  • id: 69b3792a58d557c902b981a8 | 官方: 是 | 付费: 是

答案:

思路分析集中式 vs 分布式限流(centralized vs distributed rate limiting)。不同算法的特点和适用场景(applicable scenarios)。
参考答案Redis + Lua 实现原子限流操作(atomic rate limiting operations)。固定窗口简单但有边界突刺(boundary spikes),滑动窗口更平滑(smoother),令牌桶支持突发流量(burst traffic)。分布式场景用 Redis 集中计数(centralized counting)。
评分要点- 三种限流算法(rate limiting algorithms)的对比

  • 分布式环境下的原子性保证
  • 限流粒度设计(API/用户/IP)
    常见追问- 网络分区(network partition)时限流如何处理?
  • 如何实现动态限流?

73. 设计一个实时聊天系统(real-time chat system),支持一对一和群组消息(group messages),以及消息已读状态(message read status)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: alibaba, generated)
  • 类型: technical | 难度: hard | 子类型: system-design
  • 分类: backend
  • 公司: 阿里巴巴
  • id: 69b3792a58d557c902b981ab | 官方: 是 | 付费: 是

答案:

思路分析核心挑战(core challenges):实时消息推送(real-time message push)、消息存储(message storage)、在线状态管理(online status management)、群消息扇出(group message fan-out)。
参考答案WebSocket 长连接推送(long-lived connection push),连接层无状态可水平扩展(stateless and horizontally scalable)。消息存储分会话表(conversation table)和消息表(message table)。群消息写扩散(write amplification) vs 读扩散(read amplification)策略。已读状态用 bitmap 或水位线(watermark)。
评分要点- 实时推送方案选择(real-time push solution selection)

  • 消息存储和检索设计
  • 群消息扇出策略
  • 离线消息同步
    常见追问- 如何保证消息不丢不重(message delivery guarantee)?
  • 如何支持消息撤回?

74. 设计一个分布式任务调度系统(distributed task scheduling system),支持定时任务(scheduled tasks)、延迟任务(delayed tasks)和周期任务(periodic tasks)。

  • 知识点: 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems;标签: alibaba, generated)
  • 类型: technical | 难度: hard | 子类型: system-design
  • 分类: backend
  • 公司: 阿里巴巴
  • id: 69b3792a58d557c902b981ae | 官方: 是 | 付费: 是

答案:

思路分析核心问题:任务分发(task distribution)、执行保证(execution guarantee)(至少一次(at least once)/恰好一次(exactly once))、高可用(high availability)。
参考答案时间轮(HashedWheelTimer)管理定时触发(scheduled triggering)。分布式锁(distributed lock)防止重复执行(prevent duplicate execution)。任务状态机(task state machine):pending → running → completed/failed。支持重试(retry)和死信队列(dead letter queue)。
评分要点- 调度算法选择(scheduling algorithm selection)

  • 分布式锁和幂等性
  • 故障恢复机制
    常见追问- 如何处理长时间运行的任务(long-running tasks)?
  • 如何实现任务优先级?
0

评论

博主关闭了当前页面的评论
EN