From e23ad353f60d2cc2d9e3f87fc15cf8ecff28e122 Mon Sep 17 00:00:00 2001 From: Yang Wentao Date: Thu, 30 Mar 2017 08:33:35 +0800 Subject: [PATCH 1/5] Finish basic version --- README-zh-Hant.md | 469 ++++++++++++++++++++++++++++------------------ 1 file changed, 283 insertions(+), 186 deletions(-) diff --git a/README-zh-Hant.md b/README-zh-Hant.md index defa77ef..ca826904 100644 --- a/README-zh-Hant.md +++ b/README-zh-Hant.md @@ -5,6 +5,7 @@ > * 这个 [链接](https://github.com/xitu/system-design-primer/compare/master...donnemartin:master) 用来查看本翻译与英文版是否有差别(如果你没有看到 README.md 发生变化,那就意味着这份翻译文档是最新的)。 # The System Design Primer +# 系统设计入门

@@ -12,40 +13,61 @@

## Motivation +## 目标 > Learn how to design large scale systems. > > Prep for the system design interview. +> 学习如何设计大型系统 +> +> 为系统设计面试做准备 ### Learn how to design large scale systems +### 学习如何设计大型系统 Learning how to design scalable systems will help you become a better engineer. +学习如何设计大型系统将会帮助你成为一个更好的工程师。 System design is a broad topic. There is a **vast amount of resources scattered throughout the web** on system design principles. +系统设计是一个很宽泛的话题。在互联网上,**关于系统设计原则的资源也是多如牛毛。** This repo is an **organized collection** of resources to help you learn how to build systems at scale. +这个仓库就是这些资源的**有组织的集合**,它可以帮助你学习如果基于不同尺度构建系统。 ### Learn from the open source community +### 从开源社区学习 This is an early draft of a continually updated, open source project. +这是一个不断更新的开源项目的初期的版本。 [Contributions](#contributing) are welcome! +欢迎 [贡献](#contributing) ! ### Prep for the system design interview +### 为系统设计面试做准备 In addition to coding interviews, system design is a **required component** of the **technical interview process** at many tech companies. +在很多科技公司中,除了代码面试,系统设计也是**技术面试过程**中的一个**必要环节**。 **Practice common system design interview questions** and **compare** your results with **sample solutions**: discussions, code, and diagrams. +**练习普通的系统设计面试题**并且把你的结果和**例子的答案**进行**比较**:讨论,代码和图表。 Additional topics for interview prep: +面试准备的其他主题: * [Study guide](#study-guide) * [How to approach a system design interview question](#how-to-approach-a-system-design-interview-question) * [System design interview questions, **with solutions**](#system-design-interview-questions-with-solutions) * [Object-oriented design interview questions, **with solutions**](#object-oriented-design-interview-questions-with-solutions) * [Additional system design interview questions](#additional-system-design-interview-questions) +* [学习指引](#study-guide) +* [如何回答一个系统设计面试题](#how-to-approach-a-system-design-interview-question) +* [系统设计面试题, **有答案**](#system-design-interview-questions-with-solutions) +* [面向对象设计面试题, **有答案**](#object-oriented-design-interview-questions-with-solutions) +* [其他系统设计面试题](#additional-system-design-interview-questions) ## Anki flashcards +## 抽认卡

@@ -53,170 +75,211 @@ Additional topics for interview prep:

The provided [Anki flashcard decks](https://apps.ankiweb.net/) use spaced repetition to help you retain key system design concepts. +这里提供的 [抽认卡堆](https://apps.ankiweb.net/) 使用间隔重复的方法帮助你记住系统设计的概念。 * [System design deck](resources/flash_cards/System%20Design.apkg) * [System design exercises deck](resources/flash_cards/System%20Design%20Exercises.apkg) * [Object oriented design exercises deck](resources/flash_cards/OO%20Design.apkg) +* [系统设计卡堆](resources/flash_cards/System%20Design.apkg) +* [系统设计练习卡堆](resources/flash_cards/System%20Design%20Exercises.apkg) +* [面向对象设计练习卡堆](resources/flash_cards/OO%20Design.apkg) Great for use while on-the-go. +用起来非常棒。 ## Contributing +## 贡献 > Learn from the community. +> 向社区学习。 Feel free to submit pull requests to help: +自由提交 PR 来帮助: * Fix errors * Improve sections * Add new sections +* 修复错误 +* 改善章节 +* 添加章节 Content that needs some polishing is placed [under development](#under-development). +还需要打磨的一些内容放在了 [开发中](#under-development)。 Review the [Contributing Guidelines](CONTRIBUTING.md). +查看 [贡献指导](CONTRIBUTING.md)。 ### Translations +### 翻译 Interested in **translating**? Please see the following [ticket](https://github.com/donnemartin/system-design-primer/issues/28). +对**翻译**感兴趣?请查看这个 [门票](https://github.com/donnemartin/system-design-primer/issues/28)。 ## Index of system design topics +## 系统设计主题的索引 > Summaries of various system design topics, including pros and cons. **Everything is a trade-off**. > > Each section contains links to more in-depth resources. +> 各种系统设计主题的摘要,包括优点和缺点。**每一个主题都对应一个职业**。 +> +> 每个章节都包含更深层次的资源的链接。 +


-* [System design topics: start here](#system-design-topics-start-here) - * [Step 1: Review the scalability video lecture](#step-1-review-the-scalability-video-lecture) - * [Step 2: Review the scalability article](#step-2-review-the-scalability-article) - * [Next steps](#next-steps) -* [Performance vs scalability](#performance-vs-scalability) -* [Latency vs throughput](#latency-vs-throughput) -* [Availability vs consistency](#availability-vs-consistency) - * [CAP theorem](#cap-theorem) - * [CP - consistency and partition tolerance](#cp---consistency-and-partition-tolerance) - * [AP - availability and partition tolerance](#ap---availability-and-partition-tolerance) -* [Consistency patterns](#consistency-patterns) - * [Weak consistency](#weak-consistency) - * [Eventual consistency](#eventual-consistency) - * [Strong consistency](#strong-consistency) -* [Availability patterns](#availability-patterns) - * [Fail-over](#fail-over) - * [Replication](#replication) -* [Domain name system](#domain-name-system) -* [Content delivery network](#content-delivery-network) - * [Push CDNs](#push-cdns) - * [Pull CDNs](#pull-cdns) -* [Load balancer](#load-balancer) - * [Active-passive](#active-passive) - * [Active-active](#active-active) - * [Layer 4 load balancing](#layer-4-load-balancing) - * [Layer 7 load balancing](#layer-7-load-balancing) - * [Horizontal scaling](#horizontal-scaling) -* [Reverse proxy (web server)](#reverse-proxy-web-server) - * [Load balancer vs reverse proxy](#load-balancer-vs-reverse-proxy) -* [Application layer](#application-layer) - * [Microservices](#microservices) - * [Service discovery](#service-discovery) -* [Database](#database) - * [Relational database management system (RDBMS)](#relational-database-management-system-rdbms) - * [Master-slave replication](#master-slave-replication) - * [Master-master replication](#master-master-replication) - * [Federation](#federation) - * [Sharding](#sharding) - * [Denormalization](#denormalization) - * [SQL tuning](#sql-tuning) +* [系统设计主题:从这里开始](#system-design-topics-start-here) + * [第一步:查阅拓展性的视频讲座](#step-1-review-the-scalability-video-lecture) + * [第二步: 查阅拓展性的文章](#step-2-review-the-scalability-article) + * [接下来的步骤](#next-steps) +* [性能 vs 拓展性](#performance-vs-scalability) +* [延迟 vs 吞吐量](#latency-vs-throughput) +* [可用性 vs 一致性](#availability-vs-consistency) + * [CAP 理论](#cap-theorem) + * [CP - 一致性和分区容错性](#cp---consistency-and-partition-tolerance) + * [AP - 可用性和分区容错性](#ap---availability-and-partition-tolerance) +* [一致模式](#consistency-patterns) + * [弱一致性](#weak-consistency) + * [最终一致性](#eventual-consistency) + * [强一致](#strong-consistency) +* [可用模式](#availability-patterns) + * [容灾](#fail-over) + * [复制集](#replication) +* [域名系统](#domain-name-system) +* [CDN](#content-delivery-network) + * [推送 CDNs](#push-cdns) + * [拉取 CDNs](#pull-cdns) +* [负载均衡](#load-balancer) + * [主动-被动](#active-passive) + * [主动-主动](#active-active) + * [4 层负载均衡](#layer-4-load-balancing) + * [7 层负载均衡](#layer-7-load-balancing) + * [水平拓展](#horizontal-scaling) +* [反向代理(web 服务)](#reverse-proxy-web-server) + * [负载均衡 vs 反向代理](#load-balancer-vs-reverse-proxy) +* [应用层](#application-layer) + * [微服务](#microservices) + * [服务发现](#service-discovery) +* [数据库](#database) + * [关系型数据库管理系统 (RDBMS)](#relational-database-management-system-rdbms) + * [Master-slave 复制集](#master-slave-replication) + * [Master-master 复制集](#master-master-replication) + * [联合](#federation) + * [分片](#sharding) + * [反规则化](#denormalization) + * [SQL 笔试题](#sql-tuning) * [NoSQL](#nosql) - * [Key-value store](#key-value-store) - * [Document store](#document-store) - * [Wide column store](#wide-column-store) - * [Graph Database](#graph-database) - * [SQL or NoSQL](#sql-or-nosql) -* [Cache](#cache) - * [Client caching](#client-caching) - * [CDN caching](#cdn-caching) - * [Web server caching](#web-server-caching) - * [Database caching](#database-caching) - * [Application caching](#application-caching) - * [Caching at the database query level](#caching-at-the-database-query-level) - * [Caching at the object level](#caching-at-the-object-level) - * [When to update the cache](#when-to-update-the-cache) - * [Cache-aside](#cache-aside) - * [Write-through](#write-through) - * [Write-behind (write-back)](#write-behind-write-back) - * [Refresh-ahead](#refresh-ahead) -* [Asynchronism](#asynchronism) - * [Message queues](#message-queues) - * [Task queues](#task-queues) - * [Back pressure](#back-pressure) -* [Communication](#communication) - * [Transmission control protocol (TCP)](#transmission-control-protocol-tcp) - * [User datagram protocol (UDP)](#user-datagram-protocol-udp) - * [Remote procedure call (RPC)](#remote-procedure-call-rpc) - * [Representational state transfer (REST)](#representational-state-transfer-rest) -* [Security](#security) -* [Appendix](#appendix) - * [Powers of two table](#powers-of-two-table) - * [Latency numbers every programmer should know](#latency-numbers-every-programmer-should-know) - * [Additional system design interview questions](#additional-system-design-interview-questions) - * [Real world architectures](#real-world-architectures) - * [Company architectures](#company-architectures) - * [Company engineering blogs](#company-engineering-blogs) -* [Under development](#under-development) -* [Credits](#credits) -* [Contact info](#contact-info) -* [License](#license) + * [Key-value 存储](#key-value-store) + * [文档存储](#document-store) + * [宽列存储](#wide-column-store) + * [图表数据库](#graph-database) + * [SQL 还是 NoSQL](#sql-or-nosql) +* [缓存](#cache) + * [客户端缓存](#client-caching) + * [CDN 缓存](#cdn-caching) + * [Web 服务缓存](#web-server-caching) + * [数据库缓存](#database-caching) + * [应用缓存](#application-caching) + * [在数据库查询层缓存](#caching-at-the-database-query-level) + * [对象缓存](#caching-at-the-object-level) + * [何时更新缓存](#when-to-update-the-cache) + * [隐式缓存](#cache-aside) + * [直接写入](#write-through) + * [回调写入](#write-behind-write-back) + * [自动更新](#refresh-ahead) +* [异步](#asynchronism) + * [消息队列](#message-queues) + * [任务队列](#task-queues) + * [背压机制](#back-pressure) +* [通讯](#communication) + * [传输控制协议 (TCP)](#transmission-control-protocol-tcp) + * [用户数据报协议 (UDP)](#user-datagram-protocol-udp) + * [远程控制调用 (RPC)](#remote-procedure-call-rpc) + * [表述性状态转移 (REST)](#representational-state-transfer-rest) +* [网络安全](#security) +* [附录](#appendix) + * [两张表的威力](#powers-of-two-table) + * [每一位程序员应该知道的数字误差](#latency-numbers-every-programmer-should-know) + * [其他系统设计面试题](#additional-system-design-interview-questions) + * [真实架构](#real-world-architectures) + * [公司架构](#company-architectures) + * [公司工程博客](#company-engineering-blogs) +* [开发中](#under-development) +* [致谢](#credits) +* [联系方式](#contact-info) +* [许可](#license) ## Study guide +## 学习指引 > Suggested topics to review based on your interview timeline (short, medium, long). +> 基于你面试的时间线(短,中,长)去回顾那些推荐的主题。 ![Imgur](http://i.imgur.com/OfVllex.png) **Q: For interviews, do I need to know everything here?** +**问:对于面试来说,我需要知道这里的所有知识点吗?** **A: No, you don't need to know everything here to prepare for the interview**. +**答:不,如果只是为了准备面试的话,你并不需要知道指导的知识点。** What you are asked in an interview depends on variables such as: +在一场面试中你会被问到什么取决于下面这些因素: * How much experience you have * What your technical background is * What positions you are interviewing for * Which companies you are interviewing with * Luck +* 你的经验 +* 你的技术背景 +* 你面试的职位 +* 你面试的公司 +* 运气 More experienced candidates are generally expected to know more about system design. Architects or team leads might be expected to know more than individual contributors. Top tech companies are likely to have one or more design interview rounds. +那些有经验的候选人通常会被期望了解更多的系统设计的知识。架构师或者团队负责人则会被期望了解更多除了个人贡献之外的知识。顶级的科技公司通常也会有一次或者更多的系统设计面试。 Start broad and go deeper in a few areas. It helps to know a little about various key system design topics. Adjust the following guide based on your timeline, experience, what positions you are interviewing for, and which companies you are interviewing with. +面试会很宽泛的展开并在几个领域深入。这回帮助你了解一些关于系统设计的不同的主题。基于你的时间线,经验,面试的职位和面试的公司对下面的指导做出适当的调整。 * **Short timeline** - Aim for **breadth** with system design topics. Practice by solving **some** interview questions. +* **短期** - 以系统设计主题的**广度**为目标。通过解决**一些**面试题来练习。 * **Medium timeline** - Aim for **breadth** and **some depth** with system design topics. Practice by solving **many** interview questions. +* **中期** - 以系统设计主题的**广度**和**初级深度**为目标。通过解决**很多**面试题来练习。 * **Long timeline** - Aim for **breadth** and **more depth** with system design topics. Practice by solving **most** interview questions. +* **长期** - 以系统设计主题的**广度**和**高级深度**为目标。通过解决**大部分**面试题来联系。 -| | Short | Medium | Long | -|---|---|---|---| -| Read through the [System design topics](#index-of-system-design-topics) to get a broad understanding of how systems work | :+1: | :+1: | :+1: | -| Read through a few articles in the [Company engineering blogs](#company-engineering-blogs) for the companies you are interviewing with | :+1: | :+1: | :+1: | -| Read through a few [Real world architectures](#real-world-architectures) | :+1: | :+1: | :+1: | -| Review [How to approach a system design interview question](#how-to-approach-a-system-design-interview-question) | :+1: | :+1: | :+1: | -| Work through [System design interview questions with solutions](#system-design-interview-questions-with-solutions) | Some | Many | Most | -| Work through [Object-oriented design interview questions with solutions](#object-oriented-design-interview-questions-with-solutions) | Some | Many | Most | -| Review [Additional system design interview questions](#additional-system-design-interview-questions) | Some | Many | Most | +| | 短期 | 中期 | 长期 | +| ---------------------------------------- | ---- | ---- | ---- | +| 阅读 [系统设计主题](#index-of-system-design-topics) 以获得一个关于系统如何工作的宽泛的认识 | :+1: | :+1: | :+1: | +| 阅读一些你要面试的 [公司工程博客](#company-engineering-blogs) 的文章 | :+1: | :+1: | :+1: | +| 阅读 [真实世界的架构](#real-world-architectures) | :+1: | :+1: | :+1: | +| 复习 [如何处理一个系统设计面试题](#how-to-approach-a-system-design-interview-question) | :+1: | :+1: | :+1: | +| 完成 [系统设计面试题和答案](#system-design-interview-questions-with-solutions) | 一些 | 很多 | 大部分 | +| 完成 [面向对象设计面试题和答案](#object-oriented-design-interview-questions-with-solutions) | 一些 | 很多 | 大部分 | +| 复习 [其他系统设计面试题和答案](#additional-system-design-interview-questions) | 一些 | 很多 | 大部分 | ## How to approach a system design interview question +## 如何处理一个系统设计面试题 > How to tackle a system design interview question. +> 如何处理一个系统设计面试题。 The system design interview is an **open-ended conversation**. You are expected to lead it. +系统设计面试是一个**开放式的对话**。他们期望你去主导这个对话。 You can use the following steps to guide the discussion. To help solidify this process, work through the [System design interview questions with solutions](#system-design-interview-questions-with-solutions) section using the following steps. +你可以使用下面的步骤来指引讨论。为了巩固这个过程,请使用下面的步骤完成 [系统设计面试题和答案](#system-design-interview-questions-with-solutions) 这个章节。 ### Step 1: Outline use cases, constraints, and assumptions +### 第一步:描述使用场景,约束和假设 Gather requirements and scope the problem. Ask questions to clarify use cases and constraints. Discuss assumptions. +把所有需要的东西聚集在一起,审视问题。不停的提问,以至于我们可以明确使用场景和约束。讨论假设。 * Who is going to use it? * How are they going to use it? @@ -226,117 +289,151 @@ Gather requirements and scope the problem. Ask questions to clarify use cases a * How much data do we expect to handle? * How many requests per second do we expect? * What is the expected read to write ratio? +* 谁会使用它? +* 他们会怎样使用它? +* 有多少用户? +* 系统的作用是什么? +* 系统的输入输出分别是什么? +* 我们希望处理多少数据? +* 我们希望每秒钟处理多少请求? +* 我们希望的读写比率? ### Step 2: Create a high level design +### 第二步:创造一个高级的设计 Outline a high level design with all important components. +使用所有重要的组件来描绘出一个高级的设计。 * Sketch the main components and connections * Justify your ideas +* 画出主要的组件和连接 +* 证明你的想法 ### Step 3: Design core components +### 第三步:设计核心组件 Dive into details for each core component. For example, if you were asked to [design a url shortening service](solutions/system_design/pastebin/README.md), discuss: +对每一个核心组件进行详细深入的分析。举例来说,如果你背问到 [设计一个 url 缩写服务](solutions/system_design/pastebin/README.md),开始讨论: * Generating and storing a hash of the full url - * [MD5](solutions/system_design/pastebin/README.md) and [Base62](solutions/system_design/pastebin/README.md) - * Hash collisions - * SQL or NoSQL - * Database schema +* 生成并储存一个完整 url 的 hash + * [MD5](solutions/system_design/pastebin/README.md) 和 [Base62](solutions/system_design/pastebin/README.md) + * Hash 碰撞 + * SQL 还是 NoSQL + * 数据库模型 * Translating a hashed url to the full url - * Database lookup +* 将一个 hashed url 翻译成完整的 url + * 数据库查找 * API and object-oriented design +* API 和面向对象设计 ### Step 4: Scale the design +### 第四步:度量设计 Identify and address bottlenecks, given the constraints. For example, do you need the following to address scalability issues? +确认和处理瓶颈以及一些限制。举例来说就是你需要下面的这些来完成拓展性的议题吗? * Load balancer * Horizontal scaling * Caching * Database sharding +* 负载均衡 +* 水平拓展 +* 缓存 +* 数据库分片 Discuss potential solutions and trade-offs. Everything is a trade-off. Address bottlenecks using [principles of scalable system design](#index-of-system-design-topics). +论述可能的解决办法和代价。每件事情需要取舍。可以使用 [可拓展系统的设计原则](#index-of-system-design-topics) 来处理瓶颈。 ### Back-of-the-envelope calculations +### 信封背面的计算 You might be asked to do some estimates by hand. Refer to the [Appendix](#appendix) for the following resources: +你或许会被要求通过手算进行一些估算。涉及到的 [附录](#appendix) 涉及到的是下面的这些资源: -* [Use back of the envelope calculations](http://highscalability.com/blog/2011/1/26/google-pro-tip-use-back-of-the-envelope-calculations-to-choo.html) -* [Powers of two table](#powers-of-two-table) -* [Latency numbers every programmer should know](#latency-numbers-every-programmer-should-know) +* [使用信封的背面做计算](http://highscalability.com/blog/2011/1/26/google-pro-tip-use-back-of-the-envelope-calculations-to-choo.html) +* [两张表的威力](#powers-of-two-table) +* [每一位程序员都应该知道的数字误差](#latency-numbers-every-programmer-should-know) ### Source(s) and further reading +### 源码以及查看更多 Check out the following links to get a better idea of what to expect: +查看下面的链接以获得我们期望的更好的想法: -* [How to ace a systems design interview](https://www.palantir.com/2011/10/how-to-rock-a-systems-design-interview/) -* [The system design interview](http://www.hiredintech.com/system-design) -* [Intro to Architecture and Systems Design Interviews](https://www.youtube.com/watch?v=ZgdS0EUmn70) +* [怎样通过一个系统设计面试](https://www.palantir.com/2011/10/how-to-rock-a-systems-design-interview/) +* [系统设计面试](http://www.hiredintech.com/system-design) +* [系统架构与设计面试简介](https://www.youtube.com/watch?v=ZgdS0EUmn70) ## System design interview questions with solutions +## 系统设计面试题和答案 > Common system design interview questions with sample discussions, code, and diagrams. > > Solutions linked to content in the `solutions/` folder. +> 普通的系统设计面试题和相关事例的论述,代码和图表。 +> +> 答案链接到 `solutions/` 文件夹中的内容中。 +> +| 问题 | | +| ---------------------------------------- | ---------------------------------------- | +| 设计 Pastebin.com (或者 Bit.ly) | [答案](solutions/system_design/pastebin/README.md) | +| 设计 Twitter 时间线和搜索 (或者 Facebook feed 和搜索) | [答案](solutions/system_design/twitter/README.md) | +| 设计一个网页爬虫 | [答案](solutions/system_design/web_crawler/README.md) | +| 设计 Mint.com | [答案](solutions/system_design/mint/README.md) | +| 为一个社交网络设计数据结构 | [答案](solutions/system_design/social_graph/README.md) | +| 为搜索引擎设计一个 key-value 储存 | [答案](solutions/system_design/query_cache/README.md) | +| 通过分类特性设计 Amazon 的销售排名 | [答案](solutions/system_design/sales_rank/README.md) | +| 在 AWS 上设计一个百万用户级别的系统 | [答案](solutions/system_design/scaling_aws/README.md) | +| 添加一个系统设计问题 | [贡献](#contributing) | -| Question | | -|---|---| -| Design Pastebin.com (or Bit.ly) | [Solution](solutions/system_design/pastebin/README.md) | -| Design the Twitter timeline (or Facebook feed)
Design Twitter search (or Facebook search) | [Solution](solutions/system_design/twitter/README.md) | -| Design a web crawler | [Solution](solutions/system_design/web_crawler/README.md) | -| Design Mint.com | [Solution](solutions/system_design/mint/README.md) | -| Design the data structures for a social network | [Solution](solutions/system_design/social_graph/README.md) | -| Design a key-value store for a search engine | [Solution](solutions/system_design/query_cache/README.md) | -| Design Amazon's sales ranking by category feature | [Solution](solutions/system_design/sales_rank/README.md) | -| Design a system that scales to millions of users on AWS | [Solution](solutions/system_design/scaling_aws/README.md) | -| Add a system design question | [Contribute](#contributing) | +### 设计 Pastebin.com (或者 Bit.ly) -### Design Pastebin.com (or Bit.ly) - -[View exercise and solution](solutions/system_design/pastebin/README.md) +[查看练习和答案](solutions/system_design/pastebin/README.md) ![Imgur](http://i.imgur.com/4edXG0T.png) -### Design the Twitter timeline and search (or Facebook feed and search) +### 设计 Twitter 时间线和搜索 (或者 Facebook feed 和搜索) -[View exercise and solution](solutions/system_design/twitter/README.md) +[查看练习和答案](solutions/system_design/twitter/README.md) ![Imgur](http://i.imgur.com/jrUBAF7.png) -### Design a web crawler +### 设计一个网页爬虫 -[View exercise and solution](solutions/system_design/web_crawler/README.md) +[查看练习和答案](solutions/system_design/web_crawler/README.md) ![Imgur](http://i.imgur.com/bWxPtQA.png) -### Design Mint.com +### 设计 Mint.com -[View exercise and solution](solutions/system_design/mint/README.md) +[查看练习和答案](solutions/system_design/mint/README.md) ![Imgur](http://i.imgur.com/V5q57vU.png) -### Design the data structures for a social network +### 为一个社交网络设计数据结构 -[View exercise and solution](solutions/system_design/social_graph/README.md) +[查看练习和答案](solutions/system_design/social_graph/README.md) ![Imgur](http://i.imgur.com/cdCv5g7.png) -### Design a key-value store for a search engine +### 为搜索引擎设计一个 key-value 储存 -[View exercise and solution](solutions/system_design/query_cache/README.md) +[查看练习和答案](solutions/system_design/query_cache/README.md) ![Imgur](http://i.imgur.com/4j99mhe.png) ### Design Amazon's sales ranking by category feature +### 通过分类特性设计 Amazon 的销售排名 -[View exercise and solution](solutions/system_design/sales_rank/README.md) +[查看练习和答案](solutions/system_design/sales_rank/README.md) ![Imgur](http://i.imgur.com/MzExP06.png) ### Design a system that scales to millions of users on AWS +### 在 AWS 上设计一个百万用户级别的系统 -[View exercise and solution](solutions/system_design/scaling_aws/README.md) +[查看练习和答案](solutions/system_design/scaling_aws/README.md) ![Imgur](http://i.imgur.com/jj3A5N8.png) @@ -348,16 +445,16 @@ Check out the following links to get a better idea of what to expect: >**Note: This section is under development** -| Question | | -|---|---| -| Design a hash map | [Solution](solutions/object_oriented_design/hash_table/hash_map.ipynb) | -| Design a least recently used cache | [Solution](solutions/object_oriented_design/lru_cache/lru_cache.ipynb) | -| Design a call center | [Solution](solutions/object_oriented_design/call_center/call_center.ipynb) | -| Design a deck of cards | [Solution](solutions/object_oriented_design/deck_of_cards/deck_of_cards.ipynb) | -| Design a parking lot | [Solution](solutions/object_oriented_design/parking_lot/parking_lot.ipynb) | -| Design a chat server | [Solution](solutions/object_oriented_design/online_chat/online_chat.ipynb) | -| Design a circular array | [Contribute](#contributing) | -| Add an object-oriented design question | [Contribute](#contributing) | +| Question | | +| -------------------------------------- | ---------------------------------------- | +| Design a hash map | [Solution](solutions/object_oriented_design/hash_table/hash_map.ipynb) | +| Design a least recently used cache | [Solution](solutions/object_oriented_design/lru_cache/lru_cache.ipynb) | +| Design a call center | [Solution](solutions/object_oriented_design/call_center/call_center.ipynb) | +| Design a deck of cards | [Solution](solutions/object_oriented_design/deck_of_cards/deck_of_cards.ipynb) | +| Design a parking lot | [Solution](solutions/object_oriented_design/parking_lot/parking_lot.ipynb) | +| Design a chat server | [Solution](solutions/object_oriented_design/online_chat/online_chat.ipynb) | +| Design a circular array | [Contribute](#contributing) | +| Add an object-oriented design question | [Contribute](#contributing) | ## System design topics: start here @@ -1326,13 +1423,13 @@ HTTP is a method for encoding and transporting data between a client and a serve A basic HTTP request consists of a verb (method) and a resource (endpoint). Below are common HTTP verbs: -| Verb | Description | Idempotent* | Safe | Cacheable | -|---|---|---|---|---| -| GET | Reads a resource | Yes | Yes | Yes | -| POST | Creates a resource or trigger a process that handles data | No | No | Yes if response contains freshness info | -| PUT | Creates or replace a resource | Yes | No | No | -| PATCH | Partially updates a resource | No | No | Yes if response contains freshness info | -| DELETE | Deletes a resource | Yes | No | No | +| Verb | Description | Idempotent* | Safe | Cacheable | +| ------ | ---------------------------------------- | ----------- | ---- | --------------------------------------- | +| GET | Reads a resource | Yes | Yes | Yes | +| POST | Creates a resource or trigger a process that handles data | No | No | Yes if response contains freshness info | +| PUT | Creates or replace a resource | Yes | No | No | +| PATCH | Partially updates a resource | No | No | Yes if response contains freshness info | +| DELETE | Deletes a resource | Yes | No | No | *Can be called many times without different outcomes. @@ -1474,15 +1571,15 @@ REST is focused on exposing data. It minimizes the coupling between client/serv ### RPC and REST calls comparison -| Operation | RPC | REST | -|---|---|---| -| Signup | **POST** /signup | **POST** /persons | -| Resign | **POST** /resign
{
"personid": "1234"
} | **DELETE** /persons/1234 | -| Read a person | **GET** /readPerson?personid=1234 | **GET** /persons/1234 | -| Read a person’s items list | **GET** /readUsersItemsList?personid=1234 | **GET** /persons/1234/items | +| Operation | RPC | REST | +| ------------------------------- | ---------------------------------------- | ---------------------------------------- | +| Signup | **POST** /signup | **POST** /persons | +| Resign | **POST** /resign
{
"personid": "1234"
} | **DELETE** /persons/1234 | +| Read a person | **GET** /readPerson?personid=1234 | **GET** /persons/1234 | +| Read a person’s items list | **GET** /readUsersItemsList?personid=1234 | **GET** /persons/1234/items | | Add an item to a person’s items | **POST** /addItemToUsersItemsList
{
"personid": "1234";
"itemid": "456"
} | **POST** /persons/1234/items
{
"itemid": "456"
} | -| Update an item | **POST** /modifyItem
{
"itemid": "456";
"key": "value"
} | **PUT** /items/456
{
"key": "value"
} | -| Delete an item | **POST** /removeItem
{
"itemid": "456"
} | **DELETE** /items/456 | +| Update an item | **POST** /modifyItem
{
"itemid": "456";
"key": "value"
} | **PUT** /items/456
{
"key": "value"
} | +| Delete an item | **POST** /removeItem
{
"itemid": "456"
} | **DELETE** /items/456 |

Source: Do you really know why you prefer REST over RPC @@ -1590,16 +1687,16 @@ Handy metrics based on numbers above: > Common system design interview questions, with links to resources on how to solve each. -| Question | Reference(s) | -|---|---| -| Design a file sync service like Dropbox | [youtube.com](https://www.youtube.com/watch?v=PE4gwstWhmc) | -| Design a search engine like Google | [queue.acm.org](http://queue.acm.org/detail.cfm?id=988407)
[stackexchange.com](http://programmers.stackexchange.com/questions/38324/interview-question-how-would-you-implement-google-search)
[ardendertat.com](http://www.ardendertat.com/2012/01/11/implementing-search-engines/)
[stanford.edu](http://infolab.stanford.edu/~backrub/google.html) | +| Question | Reference(s) | +| ---------------------------------------- | ---------------------------------------- | +| Design a file sync service like Dropbox | [youtube.com](https://www.youtube.com/watch?v=PE4gwstWhmc) | +| Design a search engine like Google | [queue.acm.org](http://queue.acm.org/detail.cfm?id=988407)
[stackexchange.com](http://programmers.stackexchange.com/questions/38324/interview-question-how-would-you-implement-google-search)
[ardendertat.com](http://www.ardendertat.com/2012/01/11/implementing-search-engines/)
[stanford.edu](http://infolab.stanford.edu/~backrub/google.html) | | Design a scalable web crawler like Google | [quora.com](https://www.quora.com/How-can-I-build-a-web-crawler-from-scratch) | -| Design Google docs | [code.google.com](https://code.google.com/p/google-mobwrite/)
[neil.fraser.name](https://neil.fraser.name/writing/sync/) | -| Design a key-value store like Redis | [slideshare.net](http://www.slideshare.net/dvirsky/introduction-to-redis) | -| Design a cache system like Memcached | [slideshare.net](http://www.slideshare.net/oemebamo/introduction-to-memcached) | +| Design Google docs | [code.google.com](https://code.google.com/p/google-mobwrite/)
[neil.fraser.name](https://neil.fraser.name/writing/sync/) | +| Design a key-value store like Redis | [slideshare.net](http://www.slideshare.net/dvirsky/introduction-to-redis) | +| Design a cache system like Memcached | [slideshare.net](http://www.slideshare.net/oemebamo/introduction-to-memcached) | | Design a recommendation system like Amazon's | [hulu.com](http://tech.hulu.com/blog/2011/09/19/recommendation-system.html)
[ijcai13.org](http://ijcai13.org/files/tutorial_slides/td3.pdf) | -| Design a tinyurl system like Bitly | [n00tc0d3r.blogspot.com](http://n00tc0d3r.blogspot.com/) | +| Design a tinyurl system like Bitly | [n00tc0d3r.blogspot.com](http://n00tc0d3r.blogspot.com/) | | Design a chat app like WhatsApp | [highscalability.com](http://highscalability.com/blog/2014/2/26/the-whatsapp-architecture-facebook-bought-for-19-billion.html) | Design a picture sharing system like Instagram | [highscalability.com](http://highscalability.com/flickr-architecture)
[highscalability.com](http://highscalability.com/blog/2011/12/6/instagram-architecture-14-million-users-terabytes-of-photos.html) | | Design the Facebook news feed function | [quora.com](http://www.quora.com/What-are-best-practices-for-building-something-like-a-News-Feed)
[quora.com](http://www.quora.com/Activity-Streams/What-are-the-scaling-issues-to-keep-in-mind-while-developing-a-social-network-feed)
[slideshare.net](http://www.slideshare.net/danmckinley/etsy-activity-feeds-architecture) | @@ -1631,14 +1728,14 @@ Handy metrics based on numbers above: * Study what problems are solved by each component, where it works, where it doesn't * Review the lessons learned -|Type | System | Reference(s) | -|---|---|---| +| Type | System | Reference(s) | +| --------------- | ---------------------------------------- | ---------------------------------------- | | Data processing | **MapReduce** - Distributed data processing from Google | [research.google.com](http://static.googleusercontent.com/media/research.google.com/zh-CN/us/archive/mapreduce-osdi04.pdf) | | Data processing | **Spark** - Distributed data processing from Databricks | [slideshare.net](http://www.slideshare.net/AGrishchenko/apache-spark-architecture) | | Data processing | **Storm** - Distributed data processing from Twitter | [slideshare.net](http://www.slideshare.net/previa/storm-16094009) | -| | | | -| Data store | **Bigtable** - Distributed column-oriented database from Google | [harvard.edu](http://www.read.seas.harvard.edu/~kohler/class/cs239-w08/chang06bigtable.pdf) | -| Data store | **HBase** - Open source implementation of Bigtable | [slideshare.net](http://www.slideshare.net/alexbaranau/intro-to-hbase) | +| | | | +| Data store | **Bigtable** - Distributed column-oriented database from Google | [harvard.edu](http://www.read.seas.harvard.edu/~kohler/class/cs239-w08/chang06bigtable.pdf) | +| Data store | **HBase** - Open source implementation of Bigtable | [slideshare.net](http://www.slideshare.net/alexbaranau/intro-to-hbase) | | Data store | **Cassandra** - Distributed column-oriented database from Facebook | [slideshare.net](http://www.slideshare.net/planetcassandra/cassandra-introduction-features-30103666) | Data store | **DynamoDB** - Document-oriented database from Amazon | [harvard.edu](http://www.read.seas.harvard.edu/~kohler/class/cs239-w08/decandia07dynamo.pdf) | | Data store | **MongoDB** - Document-oriented database | [slideshare.net](http://www.slideshare.net/mdirolf/introduction-to-mongodb) | @@ -1657,30 +1754,30 @@ Handy metrics based on numbers above: ### Company architectures -| Company | Reference(s) | -|---|---| -| Amazon | [Amazon architecture](http://highscalability.com/amazon-architecture) | -| Cinchcast | [Producing 1,500 hours of audio every day](http://highscalability.com/blog/2012/7/16/cinchcast-architecture-producing-1500-hours-of-audio-every-d.html) | -| DataSift | [Realtime datamining At 120,000 tweets per second](http://highscalability.com/blog/2011/11/29/datasift-architecture-realtime-datamining-at-120000-tweets-p.html) | -| DropBox | [How we've scaled Dropbox](https://www.youtube.com/watch?v=PE4gwstWhmc) | -| ESPN | [Operating At 100,000 duh nuh nuhs per second](http://highscalability.com/blog/2013/11/4/espns-architecture-at-scale-operating-at-100000-duh-nuh-nuhs.html) | -| Google | [Google architecture](http://highscalability.com/google-architecture) | -| Instagram | [14 million users, terabytes of photos](http://highscalability.com/blog/2011/12/6/instagram-architecture-14-million-users-terabytes-of-photos.html)
[What powers Instagram](http://instagram-engineering.tumblr.com/post/13649370142/what-powers-instagram-hundreds-of-instances) | -| Justin.tv | [Justin.Tv's live video broadcasting architecture](http://highscalability.com/blog/2010/3/16/justintvs-live-video-broadcasting-architecture.html) | -| Facebook | [Scaling memcached at Facebook](https://cs.uwaterloo.ca/~brecht/courses/854-Emerging-2014/readings/key-value/fb-memcached-nsdi-2013.pdf)
[TAO: Facebook’s distributed data store for the social graph](https://cs.uwaterloo.ca/~brecht/courses/854-Emerging-2014/readings/data-store/tao-facebook-distributed-datastore-atc-2013.pdf)
[Facebook’s photo storage](https://www.usenix.org/legacy/event/osdi10/tech/full_papers/Beaver.pdf) | -| Flickr | [Flickr architecture](http://highscalability.com/flickr-architecture) | -| Mailbox | [From 0 to one million users in 6 weeks](http://highscalability.com/blog/2013/6/18/scaling-mailbox-from-0-to-one-million-users-in-6-weeks-and-1.html) | -| Pinterest | [From 0 To 10s of billions of page views a month](http://highscalability.com/blog/2013/4/15/scaling-pinterest-from-0-to-10s-of-billions-of-page-views-a.html)
[18 million visitors, 10x growth, 12 employees](http://highscalability.com/blog/2012/5/21/pinterest-architecture-update-18-million-visitors-10x-growth.html) | -| Playfish | [50 million monthly users and growing](http://highscalability.com/blog/2010/9/21/playfishs-social-gaming-architecture-50-million-monthly-user.html) | -| PlentyOfFish | [PlentyOfFish architecture](http://highscalability.com/plentyoffish-architecture) | -| Salesforce | [How they handle 1.3 billion transactions a day](http://highscalability.com/blog/2013/9/23/salesforce-architecture-how-they-handle-13-billion-transacti.html) | +| Company | Reference(s) | +| -------------- | ---------------------------------------- | +| Amazon | [Amazon architecture](http://highscalability.com/amazon-architecture) | +| Cinchcast | [Producing 1,500 hours of audio every day](http://highscalability.com/blog/2012/7/16/cinchcast-architecture-producing-1500-hours-of-audio-every-d.html) | +| DataSift | [Realtime datamining At 120,000 tweets per second](http://highscalability.com/blog/2011/11/29/datasift-architecture-realtime-datamining-at-120000-tweets-p.html) | +| DropBox | [How we've scaled Dropbox](https://www.youtube.com/watch?v=PE4gwstWhmc) | +| ESPN | [Operating At 100,000 duh nuh nuhs per second](http://highscalability.com/blog/2013/11/4/espns-architecture-at-scale-operating-at-100000-duh-nuh-nuhs.html) | +| Google | [Google architecture](http://highscalability.com/google-architecture) | +| Instagram | [14 million users, terabytes of photos](http://highscalability.com/blog/2011/12/6/instagram-architecture-14-million-users-terabytes-of-photos.html)
[What powers Instagram](http://instagram-engineering.tumblr.com/post/13649370142/what-powers-instagram-hundreds-of-instances) | +| Justin.tv | [Justin.Tv's live video broadcasting architecture](http://highscalability.com/blog/2010/3/16/justintvs-live-video-broadcasting-architecture.html) | +| Facebook | [Scaling memcached at Facebook](https://cs.uwaterloo.ca/~brecht/courses/854-Emerging-2014/readings/key-value/fb-memcached-nsdi-2013.pdf)
[TAO: Facebook’s distributed data store for the social graph](https://cs.uwaterloo.ca/~brecht/courses/854-Emerging-2014/readings/data-store/tao-facebook-distributed-datastore-atc-2013.pdf)
[Facebook’s photo storage](https://www.usenix.org/legacy/event/osdi10/tech/full_papers/Beaver.pdf) | +| Flickr | [Flickr architecture](http://highscalability.com/flickr-architecture) | +| Mailbox | [From 0 to one million users in 6 weeks](http://highscalability.com/blog/2013/6/18/scaling-mailbox-from-0-to-one-million-users-in-6-weeks-and-1.html) | +| Pinterest | [From 0 To 10s of billions of page views a month](http://highscalability.com/blog/2013/4/15/scaling-pinterest-from-0-to-10s-of-billions-of-page-views-a.html)
[18 million visitors, 10x growth, 12 employees](http://highscalability.com/blog/2012/5/21/pinterest-architecture-update-18-million-visitors-10x-growth.html) | +| Playfish | [50 million monthly users and growing](http://highscalability.com/blog/2010/9/21/playfishs-social-gaming-architecture-50-million-monthly-user.html) | +| PlentyOfFish | [PlentyOfFish architecture](http://highscalability.com/plentyoffish-architecture) | +| Salesforce | [How they handle 1.3 billion transactions a day](http://highscalability.com/blog/2013/9/23/salesforce-architecture-how-they-handle-13-billion-transacti.html) | | Stack Overflow | [Stack Overflow architecture](http://highscalability.com/blog/2009/8/5/stack-overflow-architecture.html) | -| TripAdvisor | [40M visitors, 200M dynamic page views, 30TB data](http://highscalability.com/blog/2011/6/27/tripadvisor-architecture-40m-visitors-200m-dynamic-page-view.html) | -| Tumblr | [15 billion page views a month](http://highscalability.com/blog/2012/2/13/tumblr-architecture-15-billion-page-views-a-month-and-harder.html) | -| Twitter | [Making Twitter 10000 percent faster](http://highscalability.com/scaling-twitter-making-twitter-10000-percent-faster)
[Storing 250 million tweets a day using MySQL](http://highscalability.com/blog/2011/12/19/how-twitter-stores-250-million-tweets-a-day-using-mysql.html)
[150M active users, 300K QPS, a 22 MB/S firehose](http://highscalability.com/blog/2013/7/8/the-architecture-twitter-uses-to-deal-with-150m-active-users.html)
[Timelines at scale](https://www.infoq.com/presentations/Twitter-Timeline-Scalability)
[Big and small data at Twitter](https://www.youtube.com/watch?v=5cKTP36HVgI)
[Operations at Twitter: scaling beyond 100 million users](https://www.youtube.com/watch?v=z8LU0Cj6BOU) | -| Uber | [How Uber scales their real-time market platform](http://highscalability.com/blog/2015/9/14/how-uber-scales-their-real-time-market-platform.html) | -| WhatsApp | [The WhatsApp architecture Facebook bought for $19 billion](http://highscalability.com/blog/2014/2/26/the-whatsapp-architecture-facebook-bought-for-19-billion.html) | -| YouTube | [YouTube scalability](https://www.youtube.com/watch?v=w5WVu624fY8)
[YouTube architecture](http://highscalability.com/youtube-architecture) | +| TripAdvisor | [40M visitors, 200M dynamic page views, 30TB data](http://highscalability.com/blog/2011/6/27/tripadvisor-architecture-40m-visitors-200m-dynamic-page-view.html) | +| Tumblr | [15 billion page views a month](http://highscalability.com/blog/2012/2/13/tumblr-architecture-15-billion-page-views-a-month-and-harder.html) | +| Twitter | [Making Twitter 10000 percent faster](http://highscalability.com/scaling-twitter-making-twitter-10000-percent-faster)
[Storing 250 million tweets a day using MySQL](http://highscalability.com/blog/2011/12/19/how-twitter-stores-250-million-tweets-a-day-using-mysql.html)
[150M active users, 300K QPS, a 22 MB/S firehose](http://highscalability.com/blog/2013/7/8/the-architecture-twitter-uses-to-deal-with-150m-active-users.html)
[Timelines at scale](https://www.infoq.com/presentations/Twitter-Timeline-Scalability)
[Big and small data at Twitter](https://www.youtube.com/watch?v=5cKTP36HVgI)
[Operations at Twitter: scaling beyond 100 million users](https://www.youtube.com/watch?v=z8LU0Cj6BOU) | +| Uber | [How Uber scales their real-time market platform](http://highscalability.com/blog/2015/9/14/how-uber-scales-their-real-time-market-platform.html) | +| WhatsApp | [The WhatsApp architecture Facebook bought for $19 billion](http://highscalability.com/blog/2014/2/26/the-whatsapp-architecture-facebook-bought-for-19-billion.html) | +| YouTube | [YouTube scalability](https://www.youtube.com/watch?v=w5WVu624fY8)
[YouTube architecture](http://highscalability.com/youtube-architecture) | ### Company engineering blogs From 23852ebc55d552f33f76f368bd77f58ea6444bdf Mon Sep 17 00:00:00 2001 From: Yang Wentao Date: Thu, 30 Mar 2017 08:43:16 +0800 Subject: [PATCH 2/5] Remove english section --- README-zh-Hant.md | 87 +++-------------------------------------------- 1 file changed, 4 insertions(+), 83 deletions(-) diff --git a/README-zh-Hant.md b/README-zh-Hant.md index ca826904..a3dbc0c5 100644 --- a/README-zh-Hant.md +++ b/README-zh-Hant.md @@ -4,7 +4,6 @@ > * 校对者: > * 这个 [链接](https://github.com/xitu/system-design-primer/compare/master...donnemartin:master) 用来查看本翻译与英文版是否有差别(如果你没有看到 README.md 发生变化,那就意味着这份翻译文档是最新的)。 -# The System Design Primer # 系统设计入门

@@ -12,61 +11,40 @@

-## Motivation -## 目标 +## 目的 -> Learn how to design large scale systems. -> -> Prep for the system design interview. > 学习如何设计大型系统 > > 为系统设计面试做准备 -### Learn how to design large scale systems ### 学习如何设计大型系统 -Learning how to design scalable systems will help you become a better engineer. 学习如何设计大型系统将会帮助你成为一个更好的工程师。 -System design is a broad topic. There is a **vast amount of resources scattered throughout the web** on system design principles. 系统设计是一个很宽泛的话题。在互联网上,**关于系统设计原则的资源也是多如牛毛。** -This repo is an **organized collection** of resources to help you learn how to build systems at scale. 这个仓库就是这些资源的**有组织的集合**,它可以帮助你学习如果基于不同尺度构建系统。 -### Learn from the open source community ### 从开源社区学习 -This is an early draft of a continually updated, open source project. 这是一个不断更新的开源项目的初期的版本。 -[Contributions](#contributing) are welcome! 欢迎 [贡献](#contributing) ! -### Prep for the system design interview ### 为系统设计面试做准备 -In addition to coding interviews, system design is a **required component** of the **technical interview process** at many tech companies. 在很多科技公司中,除了代码面试,系统设计也是**技术面试过程**中的一个**必要环节**。 -**Practice common system design interview questions** and **compare** your results with **sample solutions**: discussions, code, and diagrams. **练习普通的系统设计面试题**并且把你的结果和**例子的答案**进行**比较**:讨论,代码和图表。 -Additional topics for interview prep: 面试准备的其他主题: -* [Study guide](#study-guide) -* [How to approach a system design interview question](#how-to-approach-a-system-design-interview-question) -* [System design interview questions, **with solutions**](#system-design-interview-questions-with-solutions) -* [Object-oriented design interview questions, **with solutions**](#object-oriented-design-interview-questions-with-solutions) -* [Additional system design interview questions](#additional-system-design-interview-questions) * [学习指引](#study-guide) * [如何回答一个系统设计面试题](#how-to-approach-a-system-design-interview-question) * [系统设计面试题, **有答案**](#system-design-interview-questions-with-solutions) * [面向对象设计面试题, **有答案**](#object-oriented-design-interview-questions-with-solutions) * [其他系统设计面试题](#additional-system-design-interview-questions) -## Anki flashcards ## 抽认卡

@@ -74,53 +52,34 @@ Additional topics for interview prep:

-The provided [Anki flashcard decks](https://apps.ankiweb.net/) use spaced repetition to help you retain key system design concepts. 这里提供的 [抽认卡堆](https://apps.ankiweb.net/) 使用间隔重复的方法帮助你记住系统设计的概念。 -* [System design deck](resources/flash_cards/System%20Design.apkg) -* [System design exercises deck](resources/flash_cards/System%20Design%20Exercises.apkg) -* [Object oriented design exercises deck](resources/flash_cards/OO%20Design.apkg) * [系统设计卡堆](resources/flash_cards/System%20Design.apkg) * [系统设计练习卡堆](resources/flash_cards/System%20Design%20Exercises.apkg) * [面向对象设计练习卡堆](resources/flash_cards/OO%20Design.apkg) -Great for use while on-the-go. 用起来非常棒。 -## Contributing ## 贡献 -> Learn from the community. > 向社区学习。 -Feel free to submit pull requests to help: 自由提交 PR 来帮助: -* Fix errors -* Improve sections -* Add new sections * 修复错误 * 改善章节 * 添加章节 -Content that needs some polishing is placed [under development](#under-development). 还需要打磨的一些内容放在了 [开发中](#under-development)。 -Review the [Contributing Guidelines](CONTRIBUTING.md). 查看 [贡献指导](CONTRIBUTING.md)。 -### Translations ### 翻译 -Interested in **translating**? Please see the following [ticket](https://github.com/donnemartin/system-design-primer/issues/28). 对**翻译**感兴趣?请查看这个 [门票](https://github.com/donnemartin/system-design-primer/issues/28)。 -## Index of system design topics ## 系统设计主题的索引 -> Summaries of various system design topics, including pros and cons. **Everything is a trade-off**. -> -> Each section contains links to more in-depth resources. > 各种系统设计主题的摘要,包括优点和缺点。**每一个主题都对应一个职业**。 > > 每个章节都包含更深层次的资源的链接。 @@ -212,45 +171,30 @@ Interested in **translating**? Please see the following [ticket](https://github * [联系方式](#contact-info) * [许可](#license) -## Study guide ## 学习指引 -> Suggested topics to review based on your interview timeline (short, medium, long). -> 基于你面试的时间线(短,中,长)去回顾那些推荐的主题。 +> 基于你面试的时间线(短,中,长)去复习那些推荐的主题。 ![Imgur](http://i.imgur.com/OfVllex.png) -**Q: For interviews, do I need to know everything here?** **问:对于面试来说,我需要知道这里的所有知识点吗?** -**A: No, you don't need to know everything here to prepare for the interview**. -**答:不,如果只是为了准备面试的话,你并不需要知道指导的知识点。** +**答:不,如果只是为了准备面试的话,你并不需要知道所有的知识点。** -What you are asked in an interview depends on variables such as: 在一场面试中你会被问到什么取决于下面这些因素: -* How much experience you have -* What your technical background is -* What positions you are interviewing for -* Which companies you are interviewing with -* Luck * 你的经验 * 你的技术背景 * 你面试的职位 * 你面试的公司 * 运气 -More experienced candidates are generally expected to know more about system design. Architects or team leads might be expected to know more than individual contributors. Top tech companies are likely to have one or more design interview rounds. 那些有经验的候选人通常会被期望了解更多的系统设计的知识。架构师或者团队负责人则会被期望了解更多除了个人贡献之外的知识。顶级的科技公司通常也会有一次或者更多的系统设计面试。 -Start broad and go deeper in a few areas. It helps to know a little about various key system design topics. Adjust the following guide based on your timeline, experience, what positions you are interviewing for, and which companies you are interviewing with. 面试会很宽泛的展开并在几个领域深入。这回帮助你了解一些关于系统设计的不同的主题。基于你的时间线,经验,面试的职位和面试的公司对下面的指导做出适当的调整。 -* **Short timeline** - Aim for **breadth** with system design topics. Practice by solving **some** interview questions. * **短期** - 以系统设计主题的**广度**为目标。通过解决**一些**面试题来练习。 -* **Medium timeline** - Aim for **breadth** and **some depth** with system design topics. Practice by solving **many** interview questions. * **中期** - 以系统设计主题的**广度**和**初级深度**为目标。通过解决**很多**面试题来练习。 -* **Long timeline** - Aim for **breadth** and **more depth** with system design topics. Practice by solving **most** interview questions. * **长期** - 以系统设计主题的**广度**和**高级深度**为目标。通过解决**大部分**面试题来联系。 | | 短期 | 中期 | 长期 | @@ -263,32 +207,18 @@ Start broad and go deeper in a few areas. It helps to know a little about vario | 完成 [面向对象设计面试题和答案](#object-oriented-design-interview-questions-with-solutions) | 一些 | 很多 | 大部分 | | 复习 [其他系统设计面试题和答案](#additional-system-design-interview-questions) | 一些 | 很多 | 大部分 | -## How to approach a system design interview question ## 如何处理一个系统设计面试题 -> How to tackle a system design interview question. > 如何处理一个系统设计面试题。 -The system design interview is an **open-ended conversation**. You are expected to lead it. 系统设计面试是一个**开放式的对话**。他们期望你去主导这个对话。 -You can use the following steps to guide the discussion. To help solidify this process, work through the [System design interview questions with solutions](#system-design-interview-questions-with-solutions) section using the following steps. 你可以使用下面的步骤来指引讨论。为了巩固这个过程,请使用下面的步骤完成 [系统设计面试题和答案](#system-design-interview-questions-with-solutions) 这个章节。 -### Step 1: Outline use cases, constraints, and assumptions ### 第一步:描述使用场景,约束和假设 -Gather requirements and scope the problem. Ask questions to clarify use cases and constraints. Discuss assumptions. 把所有需要的东西聚集在一起,审视问题。不停的提问,以至于我们可以明确使用场景和约束。讨论假设。 -* Who is going to use it? -* How are they going to use it? -* How many users are there? -* What does the system do? -* What are the inputs and outputs of the system? -* How much data do we expect to handle? -* How many requests per second do we expect? -* What is the expected read to write ratio? * 谁会使用它? * 他们会怎样使用它? * 有多少用户? @@ -298,33 +228,24 @@ Gather requirements and scope the problem. Ask questions to clarify use cases a * 我们希望每秒钟处理多少请求? * 我们希望的读写比率? -### Step 2: Create a high level design ### 第二步:创造一个高级的设计 -Outline a high level design with all important components. 使用所有重要的组件来描绘出一个高级的设计。 -* Sketch the main components and connections -* Justify your ideas * 画出主要的组件和连接 * 证明你的想法 -### Step 3: Design core components ### 第三步:设计核心组件 -Dive into details for each core component. For example, if you were asked to [design a url shortening service](solutions/system_design/pastebin/README.md), discuss: 对每一个核心组件进行详细深入的分析。举例来说,如果你背问到 [设计一个 url 缩写服务](solutions/system_design/pastebin/README.md),开始讨论: -* Generating and storing a hash of the full url * 生成并储存一个完整 url 的 hash * [MD5](solutions/system_design/pastebin/README.md) 和 [Base62](solutions/system_design/pastebin/README.md) * Hash 碰撞 * SQL 还是 NoSQL * 数据库模型 -* Translating a hashed url to the full url * 将一个 hashed url 翻译成完整的 url * 数据库查找 -* API and object-oriented design * API 和面向对象设计 ### Step 4: Scale the design @@ -373,7 +294,7 @@ Check out the following links to get a better idea of what to expect: > Solutions linked to content in the `solutions/` folder. > 普通的系统设计面试题和相关事例的论述,代码和图表。 > -> 答案链接到 `solutions/` 文件夹中的内容中。 +> 答案会链接到 `solutions/` 文件夹中的内容。 > | 问题 | | | ---------------------------------------- | ---------------------------------------- | From a6fd957c8d84d88205e43aeb52c152ab12e8253b Mon Sep 17 00:00:00 2001 From: Yang Wentao Date: Tue, 4 Apr 2017 16:45:18 +0800 Subject: [PATCH 3/5] Improve wording and delete redundant eng-section --- README-zh-Hant.md | 64 ++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/README-zh-Hant.md b/README-zh-Hant.md index a3dbc0c5..fbaa1d64 100644 --- a/README-zh-Hant.md +++ b/README-zh-Hant.md @@ -35,14 +35,14 @@ 在很多科技公司中,除了代码面试,系统设计也是**技术面试过程**中的一个**必要环节**。 -**练习普通的系统设计面试题**并且把你的结果和**例子的答案**进行**比较**:讨论,代码和图表。 +**练习普通的系统设计面试题**并且把你的结果和**例子的解答**进行**比较**:讨论,代码和图表。 面试准备的其他主题: * [学习指引](#study-guide) * [如何回答一个系统设计面试题](#how-to-approach-a-system-design-interview-question) -* [系统设计面试题, **有答案**](#system-design-interview-questions-with-solutions) -* [面向对象设计面试题, **有答案**](#object-oriented-design-interview-questions-with-solutions) +* [系统设计面试题, **含解答**](#system-design-interview-questions-with-solutions) +* [面向对象设计面试题, **含解答**](#object-oriented-design-interview-questions-with-solutions) * [其他系统设计面试题](#additional-system-design-interview-questions) ## 抽认卡 @@ -203,9 +203,9 @@ | 阅读一些你要面试的 [公司工程博客](#company-engineering-blogs) 的文章 | :+1: | :+1: | :+1: | | 阅读 [真实世界的架构](#real-world-architectures) | :+1: | :+1: | :+1: | | 复习 [如何处理一个系统设计面试题](#how-to-approach-a-system-design-interview-question) | :+1: | :+1: | :+1: | -| 完成 [系统设计面试题和答案](#system-design-interview-questions-with-solutions) | 一些 | 很多 | 大部分 | -| 完成 [面向对象设计面试题和答案](#object-oriented-design-interview-questions-with-solutions) | 一些 | 很多 | 大部分 | -| 复习 [其他系统设计面试题和答案](#additional-system-design-interview-questions) | 一些 | 很多 | 大部分 | +| 完成 [系统设计面试题和解答](#system-design-interview-questions-with-solutions) | 一些 | 很多 | 大部分 | +| 完成 [面向对象设计面试题和解答](#object-oriented-design-interview-questions-with-solutions) | 一些 | 很多 | 大部分 | +| 复习 [其他系统设计面试题和解答](#additional-system-design-interview-questions) | 一些 | 很多 | 大部分 | ## 如何处理一个系统设计面试题 @@ -213,7 +213,7 @@ 系统设计面试是一个**开放式的对话**。他们期望你去主导这个对话。 -你可以使用下面的步骤来指引讨论。为了巩固这个过程,请使用下面的步骤完成 [系统设计面试题和答案](#system-design-interview-questions-with-solutions) 这个章节。 +你可以使用下面的步骤来指引讨论。为了巩固这个过程,请使用下面的步骤完成 [系统设计面试题和解答](#system-design-interview-questions-with-solutions) 这个章节。 ### 第一步:描述使用场景,约束和假设 @@ -251,110 +251,96 @@ ### Step 4: Scale the design ### 第四步:度量设计 -Identify and address bottlenecks, given the constraints. For example, do you need the following to address scalability issues? 确认和处理瓶颈以及一些限制。举例来说就是你需要下面的这些来完成拓展性的议题吗? -* Load balancer -* Horizontal scaling -* Caching -* Database sharding * 负载均衡 * 水平拓展 * 缓存 * 数据库分片 -Discuss potential solutions and trade-offs. Everything is a trade-off. Address bottlenecks using [principles of scalable system design](#index-of-system-design-topics). 论述可能的解决办法和代价。每件事情需要取舍。可以使用 [可拓展系统的设计原则](#index-of-system-design-topics) 来处理瓶颈。 -### Back-of-the-envelope calculations ### 信封背面的计算 -You might be asked to do some estimates by hand. Refer to the [Appendix](#appendix) for the following resources: 你或许会被要求通过手算进行一些估算。涉及到的 [附录](#appendix) 涉及到的是下面的这些资源: * [使用信封的背面做计算](http://highscalability.com/blog/2011/1/26/google-pro-tip-use-back-of-the-envelope-calculations-to-choo.html) * [两张表的威力](#powers-of-two-table) * [每一位程序员都应该知道的数字误差](#latency-numbers-every-programmer-should-know) -### Source(s) and further reading ### 源码以及查看更多 -Check out the following links to get a better idea of what to expect: 查看下面的链接以获得我们期望的更好的想法: * [怎样通过一个系统设计面试](https://www.palantir.com/2011/10/how-to-rock-a-systems-design-interview/) * [系统设计面试](http://www.hiredintech.com/system-design) * [系统架构与设计面试简介](https://www.youtube.com/watch?v=ZgdS0EUmn70) -## System design interview questions with solutions -## 系统设计面试题和答案 +## 系统设计面试题和解答 -> Common system design interview questions with sample discussions, code, and diagrams. -> -> Solutions linked to content in the `solutions/` folder. > 普通的系统设计面试题和相关事例的论述,代码和图表。 > -> 答案会链接到 `solutions/` 文件夹中的内容。 +> 与内容有关的解答在 `solutions/` 文件夹中。 > | 问题 | | | ---------------------------------------- | ---------------------------------------- | -| 设计 Pastebin.com (或者 Bit.ly) | [答案](solutions/system_design/pastebin/README.md) | -| 设计 Twitter 时间线和搜索 (或者 Facebook feed 和搜索) | [答案](solutions/system_design/twitter/README.md) | -| 设计一个网页爬虫 | [答案](solutions/system_design/web_crawler/README.md) | -| 设计 Mint.com | [答案](solutions/system_design/mint/README.md) | -| 为一个社交网络设计数据结构 | [答案](solutions/system_design/social_graph/README.md) | -| 为搜索引擎设计一个 key-value 储存 | [答案](solutions/system_design/query_cache/README.md) | -| 通过分类特性设计 Amazon 的销售排名 | [答案](solutions/system_design/sales_rank/README.md) | -| 在 AWS 上设计一个百万用户级别的系统 | [答案](solutions/system_design/scaling_aws/README.md) | +| 设计 Pastebin.com (或者 Bit.ly) | [解答](solutions/system_design/pastebin/README.md) | +| 设计 Twitter 时间线和搜索 (或者 Facebook feed 和搜索) | [解答](solutions/system_design/twitter/README.md) | +| 设计一个网页爬虫 | [解答](solutions/system_design/web_crawler/README.md) | +| 设计 Mint.com | [解答](solutions/system_design/mint/README.md) | +| 为一个社交网络设计数据结构 | [解答](solutions/system_design/social_graph/README.md) | +| 为搜索引擎设计一个 key-value 储存 | [解答](solutions/system_design/query_cache/README.md) | +| 通过分类特性设计 Amazon 的销售排名 | [解答](solutions/system_design/sales_rank/README.md) | +| 在 AWS 上设计一个百万用户级别的系统 | [解答](solutions/system_design/scaling_aws/README.md) | | 添加一个系统设计问题 | [贡献](#contributing) | ### 设计 Pastebin.com (或者 Bit.ly) -[查看练习和答案](solutions/system_design/pastebin/README.md) +[查看练习和解答](solutions/system_design/pastebin/README.md) ![Imgur](http://i.imgur.com/4edXG0T.png) ### 设计 Twitter 时间线和搜索 (或者 Facebook feed 和搜索) -[查看练习和答案](solutions/system_design/twitter/README.md) +[查看练习和解答](solutions/system_design/twitter/README.md) ![Imgur](http://i.imgur.com/jrUBAF7.png) ### 设计一个网页爬虫 -[查看练习和答案](solutions/system_design/web_crawler/README.md) +[查看练习和解答](solutions/system_design/web_crawler/README.md) ![Imgur](http://i.imgur.com/bWxPtQA.png) ### 设计 Mint.com -[查看练习和答案](solutions/system_design/mint/README.md) +[查看练习和解答](solutions/system_design/mint/README.md) ![Imgur](http://i.imgur.com/V5q57vU.png) ### 为一个社交网络设计数据结构 -[查看练习和答案](solutions/system_design/social_graph/README.md) +[查看练习和解答](solutions/system_design/social_graph/README.md) ![Imgur](http://i.imgur.com/cdCv5g7.png) ### 为搜索引擎设计一个 key-value 储存 -[查看练习和答案](solutions/system_design/query_cache/README.md) +[查看练习和解答](solutions/system_design/query_cache/README.md) ![Imgur](http://i.imgur.com/4j99mhe.png) ### Design Amazon's sales ranking by category feature ### 通过分类特性设计 Amazon 的销售排名 -[查看练习和答案](solutions/system_design/sales_rank/README.md) +[查看练习和解答](solutions/system_design/sales_rank/README.md) ![Imgur](http://i.imgur.com/MzExP06.png) ### Design a system that scales to millions of users on AWS ### 在 AWS 上设计一个百万用户级别的系统 -[查看练习和答案](solutions/system_design/scaling_aws/README.md) +[查看练习和解答](solutions/system_design/scaling_aws/README.md) ![Imgur](http://i.imgur.com/jj3A5N8.png) From 1c16c0ffa2698a5c38c9e9625f0afd65a2b2514c Mon Sep 17 00:00:00 2001 From: Yang Wentao Date: Sat, 8 Apr 2017 12:03:04 +0800 Subject: [PATCH 4/5] Revise as first reviewer --- README-zh-Hant.md | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/README-zh-Hant.md b/README-zh-Hant.md index fbaa1d64..5b66c427 100644 --- a/README-zh-Hant.md +++ b/README-zh-Hant.md @@ -13,9 +13,9 @@ ## 目的 -> 学习如何设计大型系统 +> 学习如何设计大型系统。 > -> 为系统设计面试做准备 +> 为系统设计面试做准备。 ### 学习如何设计大型系统 @@ -23,7 +23,7 @@ 系统设计是一个很宽泛的话题。在互联网上,**关于系统设计原则的资源也是多如牛毛。** -这个仓库就是这些资源的**有组织的集合**,它可以帮助你学习如果基于不同尺度构建系统。 +这个仓库就是这些资源的**有组织的集合**,它可以帮助你学习如何构建可扩展的系统。 ### 从开源社区学习 @@ -35,7 +35,7 @@ 在很多科技公司中,除了代码面试,系统设计也是**技术面试过程**中的一个**必要环节**。 -**练习普通的系统设计面试题**并且把你的结果和**例子的解答**进行**比较**:讨论,代码和图表。 +**练习普通的系统设计面试题**并且把你的结果和**例子的解答**进行**对照**:讨论,代码和图表。 面试准备的其他主题: @@ -64,7 +64,7 @@ > 向社区学习。 -自由提交 PR 来帮助: +欢迎提交 PR 提供帮助: * 修复错误 * 改善章节 @@ -80,7 +80,7 @@ ## 系统设计主题的索引 -> 各种系统设计主题的摘要,包括优点和缺点。**每一个主题都对应一个职业**。 +> 各种系统设计主题的摘要,包括优点和缺点。**每一个主题都面临着取舍和权衡**。 > > 每个章节都包含更深层次的资源的链接。 @@ -91,29 +91,29 @@

* [系统设计主题:从这里开始](#system-design-topics-start-here) - * [第一步:查阅拓展性的视频讲座](#step-1-review-the-scalability-video-lecture) - * [第二步: 查阅拓展性的文章](#step-2-review-the-scalability-article) + * [第一步:回顾可扩展性的视频讲座](#step-1-review-the-scalability-video-lecture) + * [第二步: 回顾可扩展性的文章](#step-2-review-the-scalability-article) * [接下来的步骤](#next-steps) -* [性能 vs 拓展性](#performance-vs-scalability) -* [延迟 vs 吞吐量](#latency-vs-throughput) -* [可用性 vs 一致性](#availability-vs-consistency) +* [性能与拓展性](#performance-vs-scalability) +* [延迟与吞吐量](#latency-vs-throughput) +* [可用性与一致性](#availability-vs-consistency) * [CAP 理论](#cap-theorem) * [CP - 一致性和分区容错性](#cp---consistency-and-partition-tolerance) * [AP - 可用性和分区容错性](#ap---availability-and-partition-tolerance) * [一致模式](#consistency-patterns) * [弱一致性](#weak-consistency) * [最终一致性](#eventual-consistency) - * [强一致](#strong-consistency) + * [强一致性](#strong-consistency) * [可用模式](#availability-patterns) - * [容灾](#fail-over) - * [复制集](#replication) + * [故障转移](#fail-over) + * [复制](#replication) * [域名系统](#domain-name-system) * [CDN](#content-delivery-network) - * [推送 CDNs](#push-cdns) - * [拉取 CDNs](#pull-cdns) -* [负载均衡](#load-balancer) - * [主动-被动](#active-passive) - * [主动-主动](#active-active) + * [CDN 推送](#push-cdns) + * [CDN 拉取](#pull-cdns) +* [负载均衡器](#load-balancer) + * [工作到备用切换(active-passive)](#active-passive) + * [双工作切换(active-active)](#active-active) * [4 层负载均衡](#layer-4-load-balancing) * [7 层负载均衡](#layer-7-load-balancing) * [水平拓展](#horizontal-scaling) @@ -248,7 +248,6 @@ * 数据库查找 * API 和面向对象设计 -### Step 4: Scale the design ### 第四步:度量设计 确认和处理瓶颈以及一些限制。举例来说就是你需要下面的这些来完成拓展性的议题吗? @@ -330,14 +329,12 @@ ![Imgur](http://i.imgur.com/4j99mhe.png) -### Design Amazon's sales ranking by category feature ### 通过分类特性设计 Amazon 的销售排名 [查看练习和解答](solutions/system_design/sales_rank/README.md) ![Imgur](http://i.imgur.com/MzExP06.png) -### Design a system that scales to millions of users on AWS ### 在 AWS 上设计一个百万用户级别的系统 [查看练习和解答](solutions/system_design/scaling_aws/README.md) From 8f95fe88e3cb74b4f0ef0ea0261108785c9995f0 Mon Sep 17 00:00:00 2001 From: Yang Wentao Date: Sat, 8 Apr 2017 16:56:45 +0800 Subject: [PATCH 5/5] Revise as second reviewer --- README-zh-Hant.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README-zh-Hant.md b/README-zh-Hant.md index 5b66c427..085713da 100644 --- a/README-zh-Hant.md +++ b/README-zh-Hant.md @@ -67,16 +67,16 @@ 欢迎提交 PR 提供帮助: * 修复错误 -* 改善章节 +* 完善章节 * 添加章节 -还需要打磨的一些内容放在了 [开发中](#under-development)。 +一些还需要完善的内容放在了[开发中](#under-development)。 查看 [贡献指导](CONTRIBUTING.md)。 ### 翻译 -对**翻译**感兴趣?请查看这个 [门票](https://github.com/donnemartin/system-design-primer/issues/28)。 +对**翻译**感兴趣?请查看这个 [链接](https://github.com/donnemartin/system-design-primer/issues/28)。 ## 系统设计主题的索引 @@ -134,21 +134,21 @@ * [Key-value 存储](#key-value-store) * [文档存储](#document-store) * [宽列存储](#wide-column-store) - * [图表数据库](#graph-database) + * [图数据库](#graph-database) * [SQL 还是 NoSQL](#sql-or-nosql) * [缓存](#cache) * [客户端缓存](#client-caching) * [CDN 缓存](#cdn-caching) - * [Web 服务缓存](#web-server-caching) + * [Web 服务器缓存](#web-server-caching) * [数据库缓存](#database-caching) * [应用缓存](#application-caching) - * [在数据库查询层缓存](#caching-at-the-database-query-level) - * [对象缓存](#caching-at-the-object-level) + * [数据库查询级别的缓存](#caching-at-the-database-query-level) + * [对象级别的缓存](#caching-at-the-object-level) * [何时更新缓存](#when-to-update-the-cache) - * [隐式缓存](#cache-aside) - * [直接写入](#write-through) - * [回调写入](#write-behind-write-back) - * [自动更新](#refresh-ahead) + * [缓存模式](#cache-aside) + * [直写模式](#write-through) + * [回写模式](#write-behind-write-back) + * [刷新](#refresh-ahead) * [异步](#asynchronism) * [消息队列](#message-queues) * [任务队列](#task-queues) @@ -237,7 +237,7 @@ ### 第三步:设计核心组件 -对每一个核心组件进行详细深入的分析。举例来说,如果你背问到 [设计一个 url 缩写服务](solutions/system_design/pastebin/README.md),开始讨论: +对每一个核心组件进行详细深入的分析。举例来说,如果你被问到 [设计一个 url 缩写服务](solutions/system_design/pastebin/README.md),开始讨论: * 生成并储存一个完整 url 的 hash * [MD5](solutions/system_design/pastebin/README.md) 和 [Base62](solutions/system_design/pastebin/README.md) @@ -267,7 +267,7 @@ * [两张表的威力](#powers-of-two-table) * [每一位程序员都应该知道的数字误差](#latency-numbers-every-programmer-should-know) -### 源码以及查看更多 +### 相关资源和延伸阅读 查看下面的链接以获得我们期望的更好的想法: