From 47a065c12682c16978db1f8276c76d8e9b6a3356 Mon Sep 17 00:00:00 2001 From: Ido777 Date: Wed, 30 Apr 2025 11:18:28 +0300 Subject: [PATCH] Update the solutions notebooks and README files to reflect new GitHub repository links for source, ensuring consistency across the documentation. --- .../call_center/call_center.ipynb | 2 +- .../circular_array/circular_array.ipynb | 2 +- .../deck_of_cards/deck_of_cards.ipynb | 2 +- .../hash_table/hash_map.ipynb | 2 +- .../lru_cache/lru_cache.ipynb | 2 +- .../online_chat/online_chat.ipynb | 2 +- .../parking_lot/parking_lot.ipynb | 2 +- .../system_design/mint/README-zh-Hans.md | 104 ++++++++--------- solutions/system_design/mint/README.md | 106 ++++++++--------- .../system_design/pastebin/README-zh-Hans.md | 100 ++++++++-------- solutions/system_design/pastebin/README.md | 100 ++++++++-------- .../query_cache/README-zh-Hans.md | 88 +++++++------- solutions/system_design/query_cache/README.md | 88 +++++++------- .../sales_rank/README-zh-Hans.md | 94 +++++++-------- solutions/system_design/sales_rank/README.md | 96 +++++++-------- .../scaling_aws/README-zh-Hans.md | 110 +++++++++--------- solutions/system_design/scaling_aws/README.md | 110 +++++++++--------- .../social_graph/README-zh-Hans.md | 92 +++++++-------- .../system_design/social_graph/README.md | 92 +++++++-------- .../system_design/twitter/README-zh-Hans.md | 96 +++++++-------- solutions/system_design/twitter/README.md | 98 ++++++++-------- .../web_crawler/README-zh-Hans.md | 94 +++++++-------- solutions/system_design/web_crawler/README.md | 94 +++++++-------- 23 files changed, 788 insertions(+), 788 deletions(-) diff --git a/solutions/object_oriented_design/call_center/call_center.ipynb b/solutions/object_oriented_design/call_center/call_center.ipynb index 33272905..df7ddda4 100644 --- a/solutions/object_oriented_design/call_center/call_center.ipynb +++ b/solutions/object_oriented_design/call_center/call_center.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)." + "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/ido777/system-design-primer-update)." ] }, { diff --git a/solutions/object_oriented_design/circular_array/circular_array.ipynb b/solutions/object_oriented_design/circular_array/circular_array.ipynb index 73df2a9a..8e6c5cac 100644 --- a/solutions/object_oriented_design/circular_array/circular_array.ipynb +++ b/solutions/object_oriented_design/circular_array/circular_array.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook was prepared by [Abhijeet Antin](https://github.com/abhijeet14antin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)." + "This notebook was prepared by [Abhijeet Antin](https://github.com/abhijeet14antin). Source and license info is on [GitHub](https://github.com/ido777/system-design-primer-update)." ] }, { diff --git a/solutions/object_oriented_design/deck_of_cards/deck_of_cards.ipynb b/solutions/object_oriented_design/deck_of_cards/deck_of_cards.ipynb index 1a9bc1c5..dbeb9e85 100644 --- a/solutions/object_oriented_design/deck_of_cards/deck_of_cards.ipynb +++ b/solutions/object_oriented_design/deck_of_cards/deck_of_cards.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)." + "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/ido777/system-design-primer-update)." ] }, { diff --git a/solutions/object_oriented_design/hash_table/hash_map.ipynb b/solutions/object_oriented_design/hash_table/hash_map.ipynb index 92713d94..516b0afe 100644 --- a/solutions/object_oriented_design/hash_table/hash_map.ipynb +++ b/solutions/object_oriented_design/hash_table/hash_map.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)." + "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/ido777/system-design-primer-update)." ] }, { diff --git a/solutions/object_oriented_design/lru_cache/lru_cache.ipynb b/solutions/object_oriented_design/lru_cache/lru_cache.ipynb index cd91da11..96283c1e 100644 --- a/solutions/object_oriented_design/lru_cache/lru_cache.ipynb +++ b/solutions/object_oriented_design/lru_cache/lru_cache.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)." + "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/ido777/system-design-primer-update)." ] }, { diff --git a/solutions/object_oriented_design/online_chat/online_chat.ipynb b/solutions/object_oriented_design/online_chat/online_chat.ipynb index e7067ebf..ad7b9d52 100644 --- a/solutions/object_oriented_design/online_chat/online_chat.ipynb +++ b/solutions/object_oriented_design/online_chat/online_chat.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)." + "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/ido777/system-design-primer-update)." ] }, { diff --git a/solutions/object_oriented_design/parking_lot/parking_lot.ipynb b/solutions/object_oriented_design/parking_lot/parking_lot.ipynb index 4613b79b..d77b44ba 100644 --- a/solutions/object_oriented_design/parking_lot/parking_lot.ipynb +++ b/solutions/object_oriented_design/parking_lot/parking_lot.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/system-design-primer)." + "This notebook was prepared by [Donne Martin](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/ido777/system-design-primer-update)." ] }, { diff --git a/solutions/system_design/mint/README-zh-Hans.md b/solutions/system_design/mint/README-zh-Hans.md index 58467bc6..13d0953e 100644 --- a/solutions/system_design/mint/README-zh-Hans.md +++ b/solutions/system_design/mint/README-zh-Hans.md @@ -1,6 +1,6 @@ # 设计 Mint.com -**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题索引)中的有关部分,以避免重复的内容。您可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** +**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题索引)中的有关部分,以避免重复的内容。您可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** ## 第一步:简述用例与约束条件 @@ -88,9 +88,9 @@ ### 用例:用户连接到一个财务账户 -我们可以将 1000 万用户的信息存储在一个[关系数据库](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms)中。我们应该讨论一下[选择SQL或NoSQL之间的用例和权衡](https://github.com/donnemartin/system-design-primer#sql-or-nosql)了。 +我们可以将 1000 万用户的信息存储在一个[关系数据库](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms)中。我们应该讨论一下[选择SQL或NoSQL之间的用例和权衡](https://github.com/ido777/system-design-primer-update#sql-or-nosql)了。 -* **客户端** 作为一个[反向代理](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server),发送请求到 **Web 服务器** +* **客户端** 作为一个[反向代理](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server),发送请求到 **Web 服务器** * **Web 服务器** 转发请求到 **账户API** 服务器 * **账户API** 服务器将新输入的账户信息更新到 **SQL数据库** 的`accounts`表 @@ -110,9 +110,9 @@ PRIMARY KEY(id) FOREIGN KEY(user_id) REFERENCES users(id) ``` -我们将在`id`,`user_id`和`created_at`等字段上创建一个[索引](https://github.com/donnemartin/system-design-primer#use-good-indices)以加速查找(对数时间而不是扫描整个表)并保持数据在内存中。从内存中顺序读取 1 MB数据花费大约250毫秒,而从SSD读取是其4倍,从磁盘读取是其80倍。1 +我们将在`id`,`user_id`和`created_at`等字段上创建一个[索引](https://github.com/ido777/system-design-primer-update#use-good-indices)以加速查找(对数时间而不是扫描整个表)并保持数据在内存中。从内存中顺序读取 1 MB数据花费大约250毫秒,而从SSD读取是其4倍,从磁盘读取是其80倍。1 -我们将使用公开的[**REST API**](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest): +我们将使用公开的[**REST API**](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest): ``` $ curl -X POST --data '{ "user_id": "foo", "account_url": "bar", \ @@ -120,7 +120,7 @@ $ curl -X POST --data '{ "user_id": "foo", "account_url": "bar", \ https://mint.com/api/v1/account ``` -对于内部通信,我们可以使用[远程过程调用](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc)。 +对于内部通信,我们可以使用[远程过程调用](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc)。 接下来,服务从账户中提取交易。 @@ -137,7 +137,7 @@ $ curl -X POST --data '{ "user_id": "foo", "account_url": "bar", \ * **客户端**向 **Web服务器** 发送请求 * **Web服务器** 将请求转发到 **帐户API** 服务器 * **帐户API** 服务器将job放在 **队列** 中,如 [Amazon SQS](https://aws.amazon.com/sqs/) 或者 [RabbitMQ](https://www.rabbitmq.com/) - * 提取交易可能需要一段时间,我们可能希望[与队列异步](https://github.com/donnemartin/system-design-primer#asynchronism)地来做,虽然这会引入额外的复杂度。 + * 提取交易可能需要一段时间,我们可能希望[与队列异步](https://github.com/ido777/system-design-primer-update#asynchronism)地来做,虽然这会引入额外的复杂度。 * **交易提取服务** 执行如下操作: * 从 **Queue** 中拉取并从金融机构中提取给定用户的交易,将结果作为原始日志文件存储在 **对象存储区**。 * 使用 **分类服务** 来分类每个交易 @@ -160,7 +160,7 @@ PRIMARY KEY(id) FOREIGN KEY(user_id) REFERENCES users(id) ``` -我们将在 `id`,`user_id`,和 `created_at`字段上创建[索引](https://github.com/donnemartin/system-design-primer#use-good-indices)。 +我们将在 `id`,`user_id`,和 `created_at`字段上创建[索引](https://github.com/ido777/system-design-primer-update#use-good-indices)。 `monthly_spending`表应该具有如下结构: @@ -174,7 +174,7 @@ PRIMARY KEY(id) FOREIGN KEY(user_id) REFERENCES users(id) ``` -我们将在`id`,`user_id`字段上创建[索引](https://github.com/donnemartin/system-design-primer#use-good-indices)。 +我们将在`id`,`user_id`字段上创建[索引](https://github.com/ido777/system-design-primer-update#use-good-indices)。 #### 分类服务 @@ -337,20 +337,20 @@ class SpendingByCategory(MRJob): 我们将会介绍一些组件来完成设计,并解决架构扩张问题。内置的负载均衡器将不做讨论以节省篇幅。 -**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及可选的替代方案。 +**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及可选的替代方案。 -* [DNS](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#域名系统) -* [负载均衡器](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#负载均衡器) -* [水平拓展](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#水平扩展) -* [反向代理(web 服务器)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器) -* [API 服务(应用层)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用层) -* [缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存) -* [关系型数据库管理系统 (RDBMS)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms) -* [SQL 故障主从切换](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#故障切换) -* [主从复制](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#主从复制) -* [异步](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#异步) -* [一致性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#一致性模式) -* [可用性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#可用性模式) +* [DNS](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#域名系统) +* [负载均衡器](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#负载均衡器) +* [水平拓展](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#水平扩展) +* [反向代理(web 服务器)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器) +* [API 服务(应用层)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用层) +* [缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存) +* [关系型数据库管理系统 (RDBMS)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms) +* [SQL 故障主从切换](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#故障切换) +* [主从复制](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#主从复制) +* [异步](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#异步) +* [一致性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#一致性模式) +* [可用性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#可用性模式) 我们将增加一个额外的用例:**用户** 访问摘要和交易数据。 @@ -366,7 +366,7 @@ class SpendingByCategory(MRJob): * 如果URL在 **SQL 数据库**中,获取该内容 * 以其内容更新 **内存缓存** -参考 [何时更新缓存](https://github.com/donnemartin/system-design-primer#when-to-update-the-cache) 中权衡和替代的内容。以上方法描述了 [cache-aside缓存模式](https://github.com/donnemartin/system-design-primer#cache-aside). +参考 [何时更新缓存](https://github.com/ido777/system-design-primer-update#when-to-update-the-cache) 中权衡和替代的内容。以上方法描述了 [cache-aside缓存模式](https://github.com/ido777/system-design-primer-update#cache-aside). 我们可以使用诸如 Amazon Redshift 或者 Google BigQuery 等数据仓库解决方案,而不是将`monthly_spending`聚合表保留在 **SQL 数据库** 中。 @@ -376,10 +376,10 @@ class SpendingByCategory(MRJob): *平均* 200 次交易写入每秒(峰值时更高)对于单个 **SQL 写入主-从服务** 来说可能是棘手的。我们可能需要考虑其它的 SQL 性能拓展技术: -* [联合](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#联合) -* [分片](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#分片) -* [非规范化](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#非规范化) -* [SQL 调优](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-调优) +* [联合](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#联合) +* [分片](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#分片) +* [非规范化](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#非规范化) +* [SQL 调优](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-调优) 我们也可以考虑将一些数据移至 **NoSQL 数据库**。 @@ -389,50 +389,50 @@ class SpendingByCategory(MRJob): #### NoSQL -* [键-值存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#键-值存储) -* [文档类型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#文档类型存储) -* [列型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#列型存储) -* [图数据库](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#图数据库) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql) +* [键-值存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#键-值存储) +* [文档类型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#文档类型存储) +* [列型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#列型存储) +* [图数据库](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#图数据库) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql) ### 缓存 * 在哪缓存 - * [客户端缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#客户端缓存) - * [CDN 缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#cdn-缓存) - * [Web 服务器缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#web-服务器缓存) - * [数据库缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库缓存) - * [应用缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用缓存) + * [客户端缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#客户端缓存) + * [CDN 缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#cdn-缓存) + * [Web 服务器缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#web-服务器缓存) + * [数据库缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库缓存) + * [应用缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用缓存) * 什么需要缓存 - * [数据库查询级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库查询级别的缓存) - * [对象级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#对象级别的缓存) + * [数据库查询级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库查询级别的缓存) + * [对象级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#对象级别的缓存) * 何时更新缓存 - * [缓存模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存模式) - * [直写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#直写模式) - * [回写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#回写模式) - * [刷新](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#刷新) + * [缓存模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存模式) + * [直写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#直写模式) + * [回写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#回写模式) + * [刷新](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#刷新) ### 异步与微服务 -* [消息队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#消息队列) -* [任务队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#任务队列) -* [背压](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#背压) -* [微服务](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#微服务) +* [消息队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#消息队列) +* [任务队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#任务队列) +* [背压](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#背压) +* [微服务](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#微服务) ### 通信 * 可权衡选择的方案: - * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest) - * 服务器内部通信 - [RPC](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc) -* [服务发现](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#服务发现) + * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest) + * 服务器内部通信 - [RPC](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc) +* [服务发现](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#服务发现) ### 安全性 -请参阅[「安全」](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#安全)一章。 +请参阅[「安全」](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#安全)一章。 ### 延迟数值 -请参阅[「每个程序员都应该知道的延迟数」](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 +请参阅[「每个程序员都应该知道的延迟数」](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 ### 持续探讨 diff --git a/solutions/system_design/mint/README.md b/solutions/system_design/mint/README.md index 1ec31674..215ee7e9 100644 --- a/solutions/system_design/mint/README.md +++ b/solutions/system_design/mint/README.md @@ -1,6 +1,6 @@ # Design Mint.com -*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* +*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* ## Step 1: Outline use cases and constraints @@ -88,9 +88,9 @@ Handy conversion guide: ### Use case: User connects to a financial account -We could store info on the 10 million users in a [relational database](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms). We should discuss the [use cases and tradeoffs between choosing SQL or NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql). +We could store info on the 10 million users in a [relational database](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms). We should discuss the [use cases and tradeoffs between choosing SQL or NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql). -* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) +* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * The **Web Server** forwards the request to the **Accounts API** server * The **Accounts API** server updates the **SQL Database** `accounts` table with the newly entered account info @@ -110,9 +110,9 @@ PRIMARY KEY(id) FOREIGN KEY(user_id) REFERENCES users(id) ``` -We'll create an [index](https://github.com/donnemartin/system-design-primer#use-good-indices) on `id`, `user_id `, and `created_at` to speed up lookups (log-time instead of scanning the entire table) and to keep the data in memory. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 +We'll create an [index](https://github.com/ido777/system-design-primer-update#use-good-indices) on `id`, `user_id `, and `created_at` to speed up lookups (log-time instead of scanning the entire table) and to keep the data in memory. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 -We'll use a public [**REST API**](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest): +We'll use a public [**REST API**](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest): ``` $ curl -X POST --data '{ "user_id": "foo", "account_url": "bar", \ @@ -120,7 +120,7 @@ $ curl -X POST --data '{ "user_id": "foo", "account_url": "bar", \ https://mint.com/api/v1/account ``` -For internal communications, we could use [Remote Procedure Calls](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc). +For internal communications, we could use [Remote Procedure Calls](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc). Next, the service extracts transactions from the account. @@ -137,7 +137,7 @@ Data flow: * The **Client** sends a request to the **Web Server** * The **Web Server** forwards the request to the **Accounts API** server * The **Accounts API** server places a job on a **Queue** such as [Amazon SQS](https://aws.amazon.com/sqs/) or [RabbitMQ](https://www.rabbitmq.com/) - * Extracting transactions could take awhile, we'd probably want to do this [asynchronously with a queue](https://github.com/donnemartin/system-design-primer#asynchronism), although this introduces additional complexity + * Extracting transactions could take awhile, we'd probably want to do this [asynchronously with a queue](https://github.com/ido777/system-design-primer-update#asynchronism), although this introduces additional complexity * The **Transaction Extraction Service** does the following: * Pulls from the **Queue** and extracts transactions for the given account from the financial institution, storing the results as raw log files in the **Object Store** * Uses the **Category Service** to categorize each transaction @@ -160,7 +160,7 @@ PRIMARY KEY(id) FOREIGN KEY(user_id) REFERENCES users(id) ``` -We'll create an [index](https://github.com/donnemartin/system-design-primer#use-good-indices) on `id`, `user_id `, and `created_at`. +We'll create an [index](https://github.com/ido777/system-design-primer-update#use-good-indices) on `id`, `user_id `, and `created_at`. The `monthly_spending` table could have the following structure: @@ -174,7 +174,7 @@ PRIMARY KEY(id) FOREIGN KEY(user_id) REFERENCES users(id) ``` -We'll create an [index](https://github.com/donnemartin/system-design-primer#use-good-indices) on `id` and `user_id `. +We'll create an [index](https://github.com/ido777/system-design-primer-update#use-good-indices) on `id` and `user_id `. #### Category service @@ -337,21 +337,21 @@ It's important to discuss what bottlenecks you might encounter with the initial We'll introduce some components to complete the design and to address scalability issues. Internal load balancers are not shown to reduce clutter. -*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: +*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: -* [DNS](https://github.com/donnemartin/system-design-primer#domain-name-system) -* [CDN](https://github.com/donnemartin/system-design-primer#content-delivery-network) -* [Load balancer](https://github.com/donnemartin/system-design-primer#load-balancer) -* [Horizontal scaling](https://github.com/donnemartin/system-design-primer#horizontal-scaling) -* [Web server (reverse proxy)](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) -* [API server (application layer)](https://github.com/donnemartin/system-design-primer#application-layer) -* [Cache](https://github.com/donnemartin/system-design-primer#cache) -* [Relational database management system (RDBMS)](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) -* [SQL write master-slave failover](https://github.com/donnemartin/system-design-primer#fail-over) -* [Master-slave replication](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [Asynchronism](https://github.com/donnemartin/system-design-primer#asynchronism) -* [Consistency patterns](https://github.com/donnemartin/system-design-primer#consistency-patterns) -* [Availability patterns](https://github.com/donnemartin/system-design-primer#availability-patterns) +* [DNS](https://github.com/ido777/system-design-primer-update#domain-name-system) +* [CDN](https://github.com/ido777/system-design-primer-update#content-delivery-network) +* [Load balancer](https://github.com/ido777/system-design-primer-update#load-balancer) +* [Horizontal scaling](https://github.com/ido777/system-design-primer-update#horizontal-scaling) +* [Web server (reverse proxy)](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) +* [API server (application layer)](https://github.com/ido777/system-design-primer-update#application-layer) +* [Cache](https://github.com/ido777/system-design-primer-update#cache) +* [Relational database management system (RDBMS)](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) +* [SQL write master-slave failover](https://github.com/ido777/system-design-primer-update#fail-over) +* [Master-slave replication](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [Asynchronism](https://github.com/ido777/system-design-primer-update#asynchronism) +* [Consistency patterns](https://github.com/ido777/system-design-primer-update#consistency-patterns) +* [Availability patterns](https://github.com/ido777/system-design-primer-update#availability-patterns) We'll add an additional use case: **User** accesses summaries and transactions. @@ -367,7 +367,7 @@ User sessions, aggregate stats by category, and recent transactions could be pla * If the url is in the **SQL Database**, fetches the contents * Updates the **Memory Cache** with the contents -Refer to [When to update the cache](https://github.com/donnemartin/system-design-primer#when-to-update-the-cache) for tradeoffs and alternatives. The approach above describes [cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside). +Refer to [When to update the cache](https://github.com/ido777/system-design-primer-update#when-to-update-the-cache) for tradeoffs and alternatives. The approach above describes [cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside). Instead of keeping the `monthly_spending` aggregate table in the **SQL Database**, we could create a separate **Analytics Database** using a data warehousing solution such as Amazon Redshift or Google BigQuery. @@ -377,10 +377,10 @@ To address the 200 *average* read requests per second (higher at peak), traffic 2,000 *average* transaction writes per second (higher at peak) might be tough for a single **SQL Write Master-Slave**. We might need to employ additional SQL scaling patterns: -* [Federation](https://github.com/donnemartin/system-design-primer#federation) -* [Sharding](https://github.com/donnemartin/system-design-primer#sharding) -* [Denormalization](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL Tuning](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [Federation](https://github.com/ido777/system-design-primer-update#federation) +* [Sharding](https://github.com/ido777/system-design-primer-update#sharding) +* [Denormalization](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL Tuning](https://github.com/ido777/system-design-primer-update#sql-tuning) We should also consider moving some data to a **NoSQL Database**. @@ -390,50 +390,50 @@ We should also consider moving some data to a **NoSQL Database**. #### NoSQL -* [Key-value store](https://github.com/donnemartin/system-design-primer#key-value-store) -* [Document store](https://github.com/donnemartin/system-design-primer#document-store) -* [Wide column store](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [Graph database](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [Key-value store](https://github.com/ido777/system-design-primer-update#key-value-store) +* [Document store](https://github.com/ido777/system-design-primer-update#document-store) +* [Wide column store](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [Graph database](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### Caching * Where to cache - * [Client caching](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN caching](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web server caching](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [Database caching](https://github.com/donnemartin/system-design-primer#database-caching) - * [Application caching](https://github.com/donnemartin/system-design-primer#application-caching) + * [Client caching](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN caching](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web server caching](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [Database caching](https://github.com/ido777/system-design-primer-update#database-caching) + * [Application caching](https://github.com/ido777/system-design-primer-update#application-caching) * What to cache - * [Caching at the database query level](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [Caching at the object level](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [Caching at the database query level](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [Caching at the object level](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * When to update the cache - * [Cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside) - * [Write-through](https://github.com/donnemartin/system-design-primer#write-through) - * [Write-behind (write-back)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [Refresh ahead](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [Cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside) + * [Write-through](https://github.com/ido777/system-design-primer-update#write-through) + * [Write-behind (write-back)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [Refresh ahead](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### Asynchronism and microservices -* [Message queues](https://github.com/donnemartin/system-design-primer#message-queues) -* [Task queues](https://github.com/donnemartin/system-design-primer#task-queues) -* [Back pressure](https://github.com/donnemartin/system-design-primer#back-pressure) -* [Microservices](https://github.com/donnemartin/system-design-primer#microservices) +* [Message queues](https://github.com/ido777/system-design-primer-update#message-queues) +* [Task queues](https://github.com/ido777/system-design-primer-update#task-queues) +* [Back pressure](https://github.com/ido777/system-design-primer-update#back-pressure) +* [Microservices](https://github.com/ido777/system-design-primer-update#microservices) ### Communications * Discuss tradeoffs: - * External communication with clients - [HTTP APIs following REST](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * Internal communications - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [Service discovery](https://github.com/donnemartin/system-design-primer#service-discovery) + * External communication with clients - [HTTP APIs following REST](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * Internal communications - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [Service discovery](https://github.com/ido777/system-design-primer-update#service-discovery) ### Security -Refer to the [security section](https://github.com/donnemartin/system-design-primer#security). +Refer to the [security section](https://github.com/ido777/system-design-primer-update#security). ### Latency numbers -See [Latency numbers every programmer should know](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know). +See [Latency numbers every programmer should know](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know). ### Ongoing diff --git a/solutions/system_design/pastebin/README-zh-Hans.md b/solutions/system_design/pastebin/README-zh-Hans.md index d2946e97..bf6764ee 100644 --- a/solutions/system_design/pastebin/README-zh-Hans.md +++ b/solutions/system_design/pastebin/README-zh-Hans.md @@ -1,6 +1,6 @@ # 设计 Pastebin.com (或者 Bit.ly) -**注意: 为了避免重复,当前文档会直接链接到[系统设计主题](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)的相关区域,请参考链接内容以获得综合的讨论点、权衡和替代方案。** +**注意: 为了避免重复,当前文档会直接链接到[系统设计主题](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)的相关区域,请参考链接内容以获得综合的讨论点、权衡和替代方案。** **设计 Bit.ly** - 是一个类似的问题,区别是 pastebin 需要存储的是 paste 的内容,而不是原始的未短化的 url。 @@ -87,13 +87,13 @@ ### 用例:用户输入一段文本,然后得到一个随机生成的链接 -我们可以用一个 [关系型数据库](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms)作为一个大的哈希表,用来把生成的 url 映射到一个包含 paste 文件的文件服务器和路径上。 +我们可以用一个 [关系型数据库](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms)作为一个大的哈希表,用来把生成的 url 映射到一个包含 paste 文件的文件服务器和路径上。 -为了避免托管一个文件服务器,我们可以用一个托管的**对象存储**,比如 Amazon 的 S3 或者[NoSQL 文档类型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#文档类型存储)。 +为了避免托管一个文件服务器,我们可以用一个托管的**对象存储**,比如 Amazon 的 S3 或者[NoSQL 文档类型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#文档类型存储)。 -作为一个大的哈希表的关系型数据库的替代方案,我们可以用[NoSQL 键值存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#键-值存储)。我们需要讨论[选择 SQL 或 NoSQL 之间的权衡](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql)。下面的讨论是使用关系型数据库方法。 +作为一个大的哈希表的关系型数据库的替代方案,我们可以用[NoSQL 键值存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#键-值存储)。我们需要讨论[选择 SQL 或 NoSQL 之间的权衡](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql)。下面的讨论是使用关系型数据库方法。 -* **客户端** 发送一个创建 paste 的请求到作为一个[反向代理](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器)启动的 **Web 服务器**。 +* **客户端** 发送一个创建 paste 的请求到作为一个[反向代理](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器)启动的 **Web 服务器**。 * **Web 服务器** 转发请求给 **写接口** 服务器 * **写接口** 服务器执行如下操作: * 生成一个唯一的 url @@ -116,7 +116,7 @@ paste_path varchar(255) NOT NULL PRIMARY KEY(shortlink) ``` -我们将在 `shortlink` 字段和 `created_at` 字段上创建一个[数据库索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#使用正确的索引),用来提高查询的速度(避免因为扫描全表导致的长时间查询)并将数据保存在内存中,从内存里面顺序读取 1MB 的数据需要大概 250 微秒,而从 SSD 上读取则需要花费 4 倍的时间,从硬盘上则需要花费 80 倍的时间。 1 +我们将在 `shortlink` 字段和 `created_at` 字段上创建一个[数据库索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#使用正确的索引),用来提高查询的速度(避免因为扫描全表导致的长时间查询)并将数据保存在内存中,从内存里面顺序读取 1MB 的数据需要大概 250 微秒,而从 SSD 上读取则需要花费 4 倍的时间,从硬盘上则需要花费 80 倍的时间。 1 为了生成唯一的 url,我们可以: @@ -146,7 +146,7 @@ def base_encode(num, base=62): url = base_encode(md5(ip_address+timestamp))[:URL_LENGTH] ``` -我们将会用一个公开的 [**REST 风格接口**](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest): +我们将会用一个公开的 [**REST 风格接口**](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest): ```shell $ curl -X POST --data '{"expiration_length_in_minutes":"60", \"paste_contents":"Hello World!"}' https://pastebin.com/api/v1/paste @@ -160,7 +160,7 @@ Response: } ``` -用于内部通信,我们可以用 [RPC](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc)。 +用于内部通信,我们可以用 [RPC](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc)。 ### 用例:用户输入一个 paste 的 url 后可以看到它存储的内容 @@ -243,20 +243,20 @@ class HitCounts(MRJob): 我们将介绍一些组件来完成设计,并解决可伸缩性问题。内部的负载平衡器并不能减少杂乱。 -**为了避免重复的讨论**, 参考以下[系统设计主题](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)获取主要讨论要点、权衡和替代方案: +**为了避免重复的讨论**, 参考以下[系统设计主题](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)获取主要讨论要点、权衡和替代方案: -* [DNS](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#域名系统) -* [CDN](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#内容分发网络cdn) -* [负载均衡器](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#负载均衡器) -* [水平扩展](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#水平扩展) -* [反向代理(web 服务器)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器) -* [应用层](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用层) -* [缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存) -* [关系型数据库管理系统 (RDBMS)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms) -* [SQL write master-slave failover](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#故障切换) -* [主从复制](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#主从复制) -* [一致性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#一致性模式) -* [可用性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#可用性模式) +* [DNS](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#域名系统) +* [CDN](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#内容分发网络cdn) +* [负载均衡器](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#负载均衡器) +* [水平扩展](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#水平扩展) +* [反向代理(web 服务器)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器) +* [应用层](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用层) +* [缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存) +* [关系型数据库管理系统 (RDBMS)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms) +* [SQL write master-slave failover](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#故障切换) +* [主从复制](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#主从复制) +* [一致性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#一致性模式) +* [可用性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#可用性模式) **分析存储数据库** 可以用比如 Amazon Redshift 或者 Google BigQuery 这样的数据仓库解决方案。 @@ -266,10 +266,10 @@ class HitCounts(MRJob): 对于单个 **SQL Write Master-Slave**,*平均* 每秒 4paste 写入 (峰值更高) 应该是可以做到的。否则,我们需要使用额外的 SQL 扩展模式: -* [联合](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#联合) -* [分片](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#分片) -* [非规范化](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#非规范化) -* [SQL 调优](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#SQL调优) +* [联合](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#联合) +* [分片](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#分片) +* [非规范化](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#非规范化) +* [SQL 调优](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#SQL调优) 我们还应该考虑将一些数据移动到 **NoSQL 数据库**。 @@ -279,50 +279,50 @@ class HitCounts(MRJob): ### NoSQL -* [键值存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#键-值存储) -* [文档存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#文档类型存储) -* [列型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#列型存储) -* [图数据库](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#图数据库) -* [sql 还是 nosql](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql) +* [键值存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#键-值存储) +* [文档存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#文档类型存储) +* [列型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#列型存储) +* [图数据库](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#图数据库) +* [sql 还是 nosql](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql) ### 缓存 * 在哪缓存 - * [客户端缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#客户端缓存) - * [CDN 缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#cdn-缓存) - * [Web 服务器缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#web-服务器缓存) - * [数据库缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库缓存) - * [应用缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用缓存) + * [客户端缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#客户端缓存) + * [CDN 缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#cdn-缓存) + * [Web 服务器缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#web-服务器缓存) + * [数据库缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库缓存) + * [应用缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用缓存) * 缓存什么 - * [数据库查询级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库查询级别的缓存) - * [对象级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#对象级别的缓存) + * [数据库查询级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库查询级别的缓存) + * [对象级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#对象级别的缓存) * 何时更新缓存 - * [缓存模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存模式) - * [直写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#直写模式) - * [回写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#回写模式) - * [刷新](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#刷新) + * [缓存模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存模式) + * [直写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#直写模式) + * [回写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#回写模式) + * [刷新](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#刷新) ### 异步和微服务 -* [消息队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#消息队列) -* [任务队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#任务队列) -* [背压](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#背压) -* [微服务](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#微服务) +* [消息队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#消息队列) +* [任务队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#任务队列) +* [背压](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#背压) +* [微服务](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#微服务) ### 通信 * 讨论权衡: - * 跟客户端之间的外部通信 - [HTTP APIs following REST](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest) - * 内部通信 - [RPC](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc) -* [服务发现](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#服务发现) + * 跟客户端之间的外部通信 - [HTTP APIs following REST](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest) + * 内部通信 - [RPC](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc) +* [服务发现](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#服务发现) ### 安全 -参考[安全](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#安全)。 +参考[安全](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#安全)。 ### 延迟数字 -见[每个程序员都应该知道的延迟数](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 +见[每个程序员都应该知道的延迟数](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 ### 持续进行 diff --git a/solutions/system_design/pastebin/README.md b/solutions/system_design/pastebin/README.md index 2d87ddcc..06268c30 100644 --- a/solutions/system_design/pastebin/README.md +++ b/solutions/system_design/pastebin/README.md @@ -1,6 +1,6 @@ # Design Pastebin.com (or Bit.ly) -*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* +*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* **Design Bit.ly** - is a similar question, except pastebin requires storing the paste contents instead of the original unshortened url. @@ -87,13 +87,13 @@ Handy conversion guide: ### Use case: User enters a block of text and gets a randomly generated link -We could use a [relational database](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) as a large hash table, mapping the generated url to a file server and path containing the paste file. +We could use a [relational database](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) as a large hash table, mapping the generated url to a file server and path containing the paste file. -Instead of managing a file server, we could use a managed **Object Store** such as Amazon S3 or a [NoSQL document store](https://github.com/donnemartin/system-design-primer#document-store). +Instead of managing a file server, we could use a managed **Object Store** such as Amazon S3 or a [NoSQL document store](https://github.com/ido777/system-design-primer-update#document-store). -An alternative to a relational database acting as a large hash table, we could use a [NoSQL key-value store](https://github.com/donnemartin/system-design-primer#key-value-store). We should discuss the [tradeoffs between choosing SQL or NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql). The following discussion uses the relational database approach. +An alternative to a relational database acting as a large hash table, we could use a [NoSQL key-value store](https://github.com/ido777/system-design-primer-update#key-value-store). We should discuss the [tradeoffs between choosing SQL or NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql). The following discussion uses the relational database approach. -* The **Client** sends a create paste request to the **Web Server**, running as a [reverse proxy](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) +* The **Client** sends a create paste request to the **Web Server**, running as a [reverse proxy](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * The **Web Server** forwards the request to the **Write API** server * The **Write API** server does the following: * Generates a unique url @@ -116,7 +116,7 @@ paste_path varchar(255) NOT NULL PRIMARY KEY(shortlink) ``` -Setting the primary key to be based on the `shortlink` column creates an [index](https://github.com/donnemartin/system-design-primer#use-good-indices) that the database uses to enforce uniqueness. We'll create an additional index on `created_at` to speed up lookups (log-time instead of scanning the entire table) and to keep the data in memory. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 +Setting the primary key to be based on the `shortlink` column creates an [index](https://github.com/ido777/system-design-primer-update#use-good-indices) that the database uses to enforce uniqueness. We'll create an additional index on `created_at` to speed up lookups (log-time instead of scanning the entire table) and to keep the data in memory. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 To generate the unique url, we could: @@ -146,7 +146,7 @@ def base_encode(num, base=62): url = base_encode(md5(ip_address+timestamp))[:URL_LENGTH] ``` -We'll use a public [**REST API**](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest): +We'll use a public [**REST API**](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest): ``` $ curl -X POST --data '{ "expiration_length_in_minutes": "60", \ @@ -161,7 +161,7 @@ Response: } ``` -For internal communications, we could use [Remote Procedure Calls](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc). +For internal communications, we could use [Remote Procedure Calls](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc). ### Use case: User enters a paste's url and views the contents @@ -245,20 +245,20 @@ It's important to discuss what bottlenecks you might encounter with the initial We'll introduce some components to complete the design and to address scalability issues. Internal load balancers are not shown to reduce clutter. -*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: +*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: -* [DNS](https://github.com/donnemartin/system-design-primer#domain-name-system) -* [CDN](https://github.com/donnemartin/system-design-primer#content-delivery-network) -* [Load balancer](https://github.com/donnemartin/system-design-primer#load-balancer) -* [Horizontal scaling](https://github.com/donnemartin/system-design-primer#horizontal-scaling) -* [Web server (reverse proxy)](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) -* [API server (application layer)](https://github.com/donnemartin/system-design-primer#application-layer) -* [Cache](https://github.com/donnemartin/system-design-primer#cache) -* [Relational database management system (RDBMS)](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) -* [SQL write master-slave failover](https://github.com/donnemartin/system-design-primer#fail-over) -* [Master-slave replication](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [Consistency patterns](https://github.com/donnemartin/system-design-primer#consistency-patterns) -* [Availability patterns](https://github.com/donnemartin/system-design-primer#availability-patterns) +* [DNS](https://github.com/ido777/system-design-primer-update#domain-name-system) +* [CDN](https://github.com/ido777/system-design-primer-update#content-delivery-network) +* [Load balancer](https://github.com/ido777/system-design-primer-update#load-balancer) +* [Horizontal scaling](https://github.com/ido777/system-design-primer-update#horizontal-scaling) +* [Web server (reverse proxy)](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) +* [API server (application layer)](https://github.com/ido777/system-design-primer-update#application-layer) +* [Cache](https://github.com/ido777/system-design-primer-update#cache) +* [Relational database management system (RDBMS)](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) +* [SQL write master-slave failover](https://github.com/ido777/system-design-primer-update#fail-over) +* [Master-slave replication](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [Consistency patterns](https://github.com/ido777/system-design-primer-update#consistency-patterns) +* [Availability patterns](https://github.com/ido777/system-design-primer-update#availability-patterns) The **Analytics Database** could use a data warehousing solution such as Amazon Redshift or Google BigQuery. @@ -268,10 +268,10 @@ To address the 40 *average* read requests per second (higher at peak), traffic f 4 *average* paste writes per second (with higher at peak) should be do-able for a single **SQL Write Master-Slave**. Otherwise, we'll need to employ additional SQL scaling patterns: -* [Federation](https://github.com/donnemartin/system-design-primer#federation) -* [Sharding](https://github.com/donnemartin/system-design-primer#sharding) -* [Denormalization](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL Tuning](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [Federation](https://github.com/ido777/system-design-primer-update#federation) +* [Sharding](https://github.com/ido777/system-design-primer-update#sharding) +* [Denormalization](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL Tuning](https://github.com/ido777/system-design-primer-update#sql-tuning) We should also consider moving some data to a **NoSQL Database**. @@ -281,50 +281,50 @@ We should also consider moving some data to a **NoSQL Database**. #### NoSQL -* [Key-value store](https://github.com/donnemartin/system-design-primer#key-value-store) -* [Document store](https://github.com/donnemartin/system-design-primer#document-store) -* [Wide column store](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [Graph database](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [Key-value store](https://github.com/ido777/system-design-primer-update#key-value-store) +* [Document store](https://github.com/ido777/system-design-primer-update#document-store) +* [Wide column store](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [Graph database](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### Caching * Where to cache - * [Client caching](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN caching](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web server caching](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [Database caching](https://github.com/donnemartin/system-design-primer#database-caching) - * [Application caching](https://github.com/donnemartin/system-design-primer#application-caching) + * [Client caching](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN caching](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web server caching](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [Database caching](https://github.com/ido777/system-design-primer-update#database-caching) + * [Application caching](https://github.com/ido777/system-design-primer-update#application-caching) * What to cache - * [Caching at the database query level](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [Caching at the object level](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [Caching at the database query level](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [Caching at the object level](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * When to update the cache - * [Cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside) - * [Write-through](https://github.com/donnemartin/system-design-primer#write-through) - * [Write-behind (write-back)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [Refresh ahead](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [Cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside) + * [Write-through](https://github.com/ido777/system-design-primer-update#write-through) + * [Write-behind (write-back)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [Refresh ahead](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### Asynchronism and microservices -* [Message queues](https://github.com/donnemartin/system-design-primer#message-queues) -* [Task queues](https://github.com/donnemartin/system-design-primer#task-queues) -* [Back pressure](https://github.com/donnemartin/system-design-primer#back-pressure) -* [Microservices](https://github.com/donnemartin/system-design-primer#microservices) +* [Message queues](https://github.com/ido777/system-design-primer-update#message-queues) +* [Task queues](https://github.com/ido777/system-design-primer-update#task-queues) +* [Back pressure](https://github.com/ido777/system-design-primer-update#back-pressure) +* [Microservices](https://github.com/ido777/system-design-primer-update#microservices) ### Communications * Discuss tradeoffs: - * External communication with clients - [HTTP APIs following REST](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * Internal communications - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [Service discovery](https://github.com/donnemartin/system-design-primer#service-discovery) + * External communication with clients - [HTTP APIs following REST](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * Internal communications - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [Service discovery](https://github.com/ido777/system-design-primer-update#service-discovery) ### Security -Refer to the [security section](https://github.com/donnemartin/system-design-primer#security). +Refer to the [security section](https://github.com/ido777/system-design-primer-update#security). ### Latency numbers -See [Latency numbers every programmer should know](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know). +See [Latency numbers every programmer should know](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know). ### Ongoing diff --git a/solutions/system_design/query_cache/README-zh-Hans.md b/solutions/system_design/query_cache/README-zh-Hans.md index c6f4be75..f0ffa1bb 100644 --- a/solutions/system_design/query_cache/README-zh-Hans.md +++ b/solutions/system_design/query_cache/README-zh-Hans.md @@ -1,6 +1,6 @@ # 设计一个键-值缓存来存储最近 web 服务查询的结果 -**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)中的有关部分,以避免重复的内容。你可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** +**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)中的有关部分,以避免重复的内容。你可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** ## 第一步:简述用例与约束条件 @@ -66,11 +66,11 @@ ### 用例:用户发送了一次请求,命中了缓存 -常用的查询可以由例如 Redis 或者 Memcached 之类的**内存缓存**提供支持,以减少数据读取延迟,并且避免**反向索引服务**以及**文档服务**的过载。从内存读取 1 MB 连续数据大约要花 250 微秒,而从 SSD 读取同样大小的数据要花费 4 倍的时间,从机械硬盘读取需要花费 80 倍以上的时间。1 +常用的查询可以由例如 Redis 或者 Memcached 之类的**内存缓存**提供支持,以减少数据读取延迟,并且避免**反向索引服务**以及**文档服务**的过载。从内存读取 1 MB 连续数据大约要花 250 微秒,而从 SSD 读取同样大小的数据要花费 4 倍的时间,从机械硬盘读取需要花费 80 倍以上的时间。1 由于缓存容量有限,我们将使用 LRU(近期最少使用算法)来控制缓存的过期。 -* **客户端**向运行[反向代理](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器)的 **Web 服务器**发送一个请求 +* **客户端**向运行[反向代理](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器)的 **Web 服务器**发送一个请求 * 这个 **Web 服务器**将请求转发给**查询 API** 服务 * **查询 API** 服务将会做这些事情: * 分析查询 @@ -206,7 +206,7 @@ class Cache(object): 解决这些问题的最直接的方法,就是为缓存记录设置一个它在被更新前能留在缓存中的最长时间,这个时间简称为存活时间(TTL)。 -参考 [「何时更新缓存」](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#何时更新缓存)来了解其权衡取舍及替代方案。以上方法在[缓存模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存模式)一章中详细地进行了描述。 +参考 [「何时更新缓存」](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#何时更新缓存)来了解其权衡取舍及替代方案。以上方法在[缓存模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存模式)一章中详细地进行了描述。 ## 第四步:架构扩展 @@ -222,16 +222,16 @@ class Cache(object): 我们将会介绍一些组件来完成设计,并解决架构扩张问题。内置的负载均衡器将不做讨论以节省篇幅。 -**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及可选的替代方案。 +**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及可选的替代方案。 -* [DNS](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#域名系统) -* [负载均衡器](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#负载均衡器) -* [水平拓展](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#水平扩展) -* [反向代理(web 服务器)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器) -* [API 服务(应用层)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用层) -* [缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存) -* [一致性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#一致性模式) -* [可用性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#可用性模式) +* [DNS](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#域名系统) +* [负载均衡器](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#负载均衡器) +* [水平拓展](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#水平扩展) +* [反向代理(web 服务器)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器) +* [API 服务(应用层)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用层) +* [缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存) +* [一致性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#一致性模式) +* [可用性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#可用性模式) ### 将内存缓存扩大到多台机器 @@ -239,7 +239,7 @@ class Cache(object): * **缓存集群中的每一台机器都有自己的缓存** - 简单,但是它会降低缓存命中率。 * **缓存集群中的每一台机器都有缓存的拷贝** - 简单,但是它的内存使用效率太低了。 -* **对缓存进行[分片](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#分片),分别部署在缓存集群中的所有机器中** - 更加复杂,但是它是最佳的选择。我们可以使用哈希,用查询语句 `machine = hash(query)` 来确定哪台机器有需要缓存。当然我们也可以使用[一致性哈希](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#正在完善中)。 +* **对缓存进行[分片](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#分片),分别部署在缓存集群中的所有机器中** - 更加复杂,但是它是最佳的选择。我们可以使用哈希,用查询语句 `machine = hash(query)` 来确定哪台机器有需要缓存。当然我们也可以使用[一致性哈希](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#正在完善中)。 ## 其它要点 @@ -247,58 +247,58 @@ class Cache(object): ### SQL 缩放模式 -* [读取复制](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#主从复制) -* [联合](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#联合) -* [分片](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#分片) -* [非规范化](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#非规范化) -* [SQL 调优](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-调优) +* [读取复制](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#主从复制) +* [联合](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#联合) +* [分片](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#分片) +* [非规范化](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#非规范化) +* [SQL 调优](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-调优) #### NoSQL -* [键-值存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#键-值存储) -* [文档类型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#文档类型存储) -* [列型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#列型存储) -* [图数据库](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#图数据库) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql) +* [键-值存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#键-值存储) +* [文档类型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#文档类型存储) +* [列型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#列型存储) +* [图数据库](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#图数据库) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql) ### 缓存 * 在哪缓存 - * [客户端缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#客户端缓存) - * [CDN 缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#cdn-缓存) - * [Web 服务器缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#web-服务器缓存) - * [数据库缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库缓存) - * [应用缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用缓存) + * [客户端缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#客户端缓存) + * [CDN 缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#cdn-缓存) + * [Web 服务器缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#web-服务器缓存) + * [数据库缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库缓存) + * [应用缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用缓存) * 什么需要缓存 - * [数据库查询级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库查询级别的缓存) - * [对象级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#对象级别的缓存) + * [数据库查询级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库查询级别的缓存) + * [对象级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#对象级别的缓存) * 何时更新缓存 - * [缓存模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存模式) - * [直写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#直写模式) - * [回写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#回写模式) - * [刷新](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#刷新) + * [缓存模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存模式) + * [直写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#直写模式) + * [回写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#回写模式) + * [刷新](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#刷新) ### 异步与微服务 -* [消息队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#消息队列) -* [任务队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#任务队列) -* [背压](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#背压) -* [微服务](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#微服务) +* [消息队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#消息队列) +* [任务队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#任务队列) +* [背压](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#背压) +* [微服务](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#微服务) ### 通信 * 可权衡选择的方案: - * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest) - * 服务器内部通信 - [RPC](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc) -* [服务发现](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#服务发现) + * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest) + * 服务器内部通信 - [RPC](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc) +* [服务发现](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#服务发现) ### 安全性 -请参阅[「安全」](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#安全)一章。 +请参阅[「安全」](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#安全)一章。 ### 延迟数值 -请参阅[「每个程序员都应该知道的延迟数」](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 +请参阅[「每个程序员都应该知道的延迟数」](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 ### 持续探讨 diff --git a/solutions/system_design/query_cache/README.md b/solutions/system_design/query_cache/README.md index 032adf34..7f6ae936 100644 --- a/solutions/system_design/query_cache/README.md +++ b/solutions/system_design/query_cache/README.md @@ -1,6 +1,6 @@ # Design a key-value cache to save the results of the most recent web server queries -*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* +*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* ## Step 1: Outline use cases and constraints @@ -66,11 +66,11 @@ Handy conversion guide: ### Use case: User sends a request resulting in a cache hit -Popular queries can be served from a **Memory Cache** such as Redis or Memcached to reduce read latency and to avoid overloading the **Reverse Index Service** and **Document Service**. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 +Popular queries can be served from a **Memory Cache** such as Redis or Memcached to reduce read latency and to avoid overloading the **Reverse Index Service** and **Document Service**. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 Since the cache has limited capacity, we'll use a least recently used (LRU) approach to expire older entries. -* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) +* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * The **Web Server** forwards the request to the **Query API** server * The **Query API** server does the following: * Parses the query @@ -206,7 +206,7 @@ The cache should be updated when: The most straightforward way to handle these cases is to simply set a max time that a cached entry can stay in the cache before it is updated, usually referred to as time to live (TTL). -Refer to [When to update the cache](https://github.com/donnemartin/system-design-primer#when-to-update-the-cache) for tradeoffs and alternatives. The approach above describes [cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside). +Refer to [When to update the cache](https://github.com/ido777/system-design-primer-update#when-to-update-the-cache) for tradeoffs and alternatives. The approach above describes [cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside). ## Step 4: Scale the design @@ -222,16 +222,16 @@ It's important to discuss what bottlenecks you might encounter with the initial We'll introduce some components to complete the design and to address scalability issues. Internal load balancers are not shown to reduce clutter. -*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: +*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: -* [DNS](https://github.com/donnemartin/system-design-primer#domain-name-system) -* [Load balancer](https://github.com/donnemartin/system-design-primer#load-balancer) -* [Horizontal scaling](https://github.com/donnemartin/system-design-primer#horizontal-scaling) -* [Web server (reverse proxy)](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) -* [API server (application layer)](https://github.com/donnemartin/system-design-primer#application-layer) -* [Cache](https://github.com/donnemartin/system-design-primer#cache) -* [Consistency patterns](https://github.com/donnemartin/system-design-primer#consistency-patterns) -* [Availability patterns](https://github.com/donnemartin/system-design-primer#availability-patterns) +* [DNS](https://github.com/ido777/system-design-primer-update#domain-name-system) +* [Load balancer](https://github.com/ido777/system-design-primer-update#load-balancer) +* [Horizontal scaling](https://github.com/ido777/system-design-primer-update#horizontal-scaling) +* [Web server (reverse proxy)](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) +* [API server (application layer)](https://github.com/ido777/system-design-primer-update#application-layer) +* [Cache](https://github.com/ido777/system-design-primer-update#cache) +* [Consistency patterns](https://github.com/ido777/system-design-primer-update#consistency-patterns) +* [Availability patterns](https://github.com/ido777/system-design-primer-update#availability-patterns) ### Expanding the Memory Cache to many machines @@ -239,7 +239,7 @@ To handle the heavy request load and the large amount of memory needed, we'll sc * **Each machine in the cache cluster has its own cache** - Simple, although it will likely result in a low cache hit rate. * **Each machine in the cache cluster has a copy of the cache** - Simple, although it is an inefficient use of memory. -* **The cache is [sharded](https://github.com/donnemartin/system-design-primer#sharding) across all machines in the cache cluster** - More complex, although it is likely the best option. We could use hashing to determine which machine could have the cached results of a query using `machine = hash(query)`. We'll likely want to use [consistent hashing](https://github.com/donnemartin/system-design-primer#under-development). +* **The cache is [sharded](https://github.com/ido777/system-design-primer-update#sharding) across all machines in the cache cluster** - More complex, although it is likely the best option. We could use hashing to determine which machine could have the cached results of a query using `machine = hash(query)`. We'll likely want to use [consistent hashing](https://github.com/ido777/system-design-primer-update#under-development). ## Additional talking points @@ -247,58 +247,58 @@ To handle the heavy request load and the large amount of memory needed, we'll sc ### SQL scaling patterns -* [Read replicas](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [Federation](https://github.com/donnemartin/system-design-primer#federation) -* [Sharding](https://github.com/donnemartin/system-design-primer#sharding) -* [Denormalization](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL Tuning](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [Read replicas](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [Federation](https://github.com/ido777/system-design-primer-update#federation) +* [Sharding](https://github.com/ido777/system-design-primer-update#sharding) +* [Denormalization](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL Tuning](https://github.com/ido777/system-design-primer-update#sql-tuning) #### NoSQL -* [Key-value store](https://github.com/donnemartin/system-design-primer#key-value-store) -* [Document store](https://github.com/donnemartin/system-design-primer#document-store) -* [Wide column store](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [Graph database](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [Key-value store](https://github.com/ido777/system-design-primer-update#key-value-store) +* [Document store](https://github.com/ido777/system-design-primer-update#document-store) +* [Wide column store](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [Graph database](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### Caching * Where to cache - * [Client caching](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN caching](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web server caching](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [Database caching](https://github.com/donnemartin/system-design-primer#database-caching) - * [Application caching](https://github.com/donnemartin/system-design-primer#application-caching) + * [Client caching](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN caching](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web server caching](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [Database caching](https://github.com/ido777/system-design-primer-update#database-caching) + * [Application caching](https://github.com/ido777/system-design-primer-update#application-caching) * What to cache - * [Caching at the database query level](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [Caching at the object level](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [Caching at the database query level](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [Caching at the object level](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * When to update the cache - * [Cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside) - * [Write-through](https://github.com/donnemartin/system-design-primer#write-through) - * [Write-behind (write-back)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [Refresh ahead](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [Cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside) + * [Write-through](https://github.com/ido777/system-design-primer-update#write-through) + * [Write-behind (write-back)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [Refresh ahead](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### Asynchronism and microservices -* [Message queues](https://github.com/donnemartin/system-design-primer#message-queues) -* [Task queues](https://github.com/donnemartin/system-design-primer#task-queues) -* [Back pressure](https://github.com/donnemartin/system-design-primer#back-pressure) -* [Microservices](https://github.com/donnemartin/system-design-primer#microservices) +* [Message queues](https://github.com/ido777/system-design-primer-update#message-queues) +* [Task queues](https://github.com/ido777/system-design-primer-update#task-queues) +* [Back pressure](https://github.com/ido777/system-design-primer-update#back-pressure) +* [Microservices](https://github.com/ido777/system-design-primer-update#microservices) ### Communications * Discuss tradeoffs: - * External communication with clients - [HTTP APIs following REST](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * Internal communications - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [Service discovery](https://github.com/donnemartin/system-design-primer#service-discovery) + * External communication with clients - [HTTP APIs following REST](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * Internal communications - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [Service discovery](https://github.com/ido777/system-design-primer-update#service-discovery) ### Security -Refer to the [security section](https://github.com/donnemartin/system-design-primer#security). +Refer to the [security section](https://github.com/ido777/system-design-primer-update#security). ### Latency numbers -See [Latency numbers every programmer should know](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know). +See [Latency numbers every programmer should know](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know). ### Ongoing diff --git a/solutions/system_design/sales_rank/README-zh-Hans.md b/solutions/system_design/sales_rank/README-zh-Hans.md index 960f9258..5d8ffce1 100644 --- a/solutions/system_design/sales_rank/README-zh-Hans.md +++ b/solutions/system_design/sales_rank/README-zh-Hans.md @@ -1,6 +1,6 @@ # 为 Amazon 设计分类售卖排行 -**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)中的有关部分,以避免重复的内容。你可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** +**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)中的有关部分,以避免重复的内容。你可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** ## 第一步:简述用例与约束条件 @@ -95,7 +95,7 @@ t5 product4 category1 1 5.00 5 6 ... ``` -**售卖排行服务** 需要用到 **MapReduce**,并使用 **售卖 API** 服务进行日志记录,同时将结果写入 **SQL 数据库**中的总表 `sales_rank` 中。我们也可以讨论一下[究竟是用 SQL 还是用 NoSQL](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql)。 +**售卖排行服务** 需要用到 **MapReduce**,并使用 **售卖 API** 服务进行日志记录,同时将结果写入 **SQL 数据库**中的总表 `sales_rank` 中。我们也可以讨论一下[究竟是用 SQL 还是用 NoSQL](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql)。 我们需要通过以下步骤使用 **MapReduce**: @@ -197,15 +197,15 @@ FOREIGN KEY(category_id) REFERENCES Categories(id) FOREIGN KEY(product_id) REFERENCES Products(id) ``` -我们会以 `id`、`category_id` 与 `product_id` 创建一个 [索引](https://github.com/donnemartin/system-design-primer#use-good-indices)以加快查询速度(只需要使用读取日志的时间,不再需要每次都扫描整个数据表)并让数据常驻内存。从内存读取 1 MB 连续数据大约要花 250 微秒,而从 SSD 读取同样大小的数据要花费 4 倍的时间,从机械硬盘读取需要花费 80 倍以上的时间。1 +我们会以 `id`、`category_id` 与 `product_id` 创建一个 [索引](https://github.com/ido777/system-design-primer-update#use-good-indices)以加快查询速度(只需要使用读取日志的时间,不再需要每次都扫描整个数据表)并让数据常驻内存。从内存读取 1 MB 连续数据大约要花 250 微秒,而从 SSD 读取同样大小的数据要花费 4 倍的时间,从机械硬盘读取需要花费 80 倍以上的时间。1 ### 用例:用户需要根据分类浏览上周中最受欢迎的商品 -* **客户端**向运行[反向代理](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器)的 **Web 服务器**发送一个请求 +* **客户端**向运行[反向代理](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器)的 **Web 服务器**发送一个请求 * 这个 **Web 服务器**将请求转发给**查询 API** 服务 * The **查询 API** 服务将从 **SQL 数据库**的 `sales_rank` 表中读取数据 -我们可以调用一个公共的 [REST API](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest): +我们可以调用一个公共的 [REST API](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest): ``` $ curl https://amazon.com/api/v1/popular?category_id=1234 @@ -234,7 +234,7 @@ $ curl https://amazon.com/api/v1/popular?category_id=1234 }, ``` -而对于服务器内部的通信,我们可以使用 [RPC](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc)。 +而对于服务器内部的通信,我们可以使用 [RPC](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc)。 ## 第四步:架构扩展 @@ -250,19 +250,19 @@ $ curl https://amazon.com/api/v1/popular?category_id=1234 我们将会介绍一些组件来完成设计,并解决架构扩张问题。内置的负载均衡器将不做讨论以节省篇幅。 -**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及可选的替代方案。 +**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及可选的替代方案。 -* [DNS](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#域名系统) -* [负载均衡器](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#负载均衡器) -* [水平拓展](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#水平扩展) -* [反向代理(web 服务器)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器) -* [API 服务(应用层)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用层) -* [缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存) -* [关系型数据库管理系统 (RDBMS)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms) -* [SQL 故障主从切换](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#故障切换) -* [主从复制](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#主从复制) -* [一致性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#一致性模式) -* [可用性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#可用性模式) +* [DNS](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#域名系统) +* [负载均衡器](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#负载均衡器) +* [水平拓展](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#水平扩展) +* [反向代理(web 服务器)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器) +* [API 服务(应用层)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用层) +* [缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存) +* [关系型数据库管理系统 (RDBMS)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms) +* [SQL 故障主从切换](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#故障切换) +* [主从复制](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#主从复制) +* [一致性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#一致性模式) +* [可用性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#可用性模式) **分析数据库** 可以用现成的数据仓储系统,例如使用 Amazon Redshift 或者 Google BigQuery 的解决方案。 @@ -274,10 +274,10 @@ $ curl https://amazon.com/api/v1/popular?category_id=1234 SQL 缩放模式包括: -* [联合](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#联合) -* [分片](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#分片) -* [非规范化](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#非规范化) -* [SQL 调优](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-调优) +* [联合](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#联合) +* [分片](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#分片) +* [非规范化](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#非规范化) +* [SQL 调优](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-调优) 我们也可以考虑将一些数据移至 **NoSQL 数据库**。 @@ -287,50 +287,50 @@ SQL 缩放模式包括: #### NoSQL -* [键-值存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#键-值存储) -* [文档类型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#文档类型存储) -* [列型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#列型存储) -* [图数据库](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#图数据库) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql) +* [键-值存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#键-值存储) +* [文档类型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#文档类型存储) +* [列型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#列型存储) +* [图数据库](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#图数据库) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql) ### 缓存 * 在哪缓存 - * [客户端缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#客户端缓存) - * [CDN 缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#cdn-缓存) - * [Web 服务器缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#web-服务器缓存) - * [数据库缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库缓存) - * [应用缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用缓存) + * [客户端缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#客户端缓存) + * [CDN 缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#cdn-缓存) + * [Web 服务器缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#web-服务器缓存) + * [数据库缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库缓存) + * [应用缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用缓存) * 什么需要缓存 - * [数据库查询级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库查询级别的缓存) - * [对象级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#对象级别的缓存) + * [数据库查询级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库查询级别的缓存) + * [对象级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#对象级别的缓存) * 何时更新缓存 - * [缓存模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存模式) - * [直写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#直写模式) - * [回写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#回写模式) - * [刷新](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#刷新) + * [缓存模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存模式) + * [直写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#直写模式) + * [回写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#回写模式) + * [刷新](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#刷新) ### 异步与微服务 -* [消息队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#消息队列) -* [任务队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#任务队列) -* [背压](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#背压) -* [微服务](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#微服务) +* [消息队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#消息队列) +* [任务队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#任务队列) +* [背压](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#背压) +* [微服务](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#微服务) ### 通信 * 可权衡选择的方案: - * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest) - * 服务器内部通信 - [RPC](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc) -* [服务发现](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#服务发现) + * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest) + * 服务器内部通信 - [RPC](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc) +* [服务发现](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#服务发现) ### 安全性 -请参阅[「安全」](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#安全)一章。 +请参阅[「安全」](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#安全)一章。 ### 延迟数值 -请参阅[「每个程序员都应该知道的延迟数」](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 +请参阅[「每个程序员都应该知道的延迟数」](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 ### 持续探讨 diff --git a/solutions/system_design/sales_rank/README.md b/solutions/system_design/sales_rank/README.md index 71ad1c7d..58a30e8f 100644 --- a/solutions/system_design/sales_rank/README.md +++ b/solutions/system_design/sales_rank/README.md @@ -1,6 +1,6 @@ # Design Amazon's sales rank by category feature -*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* +*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* ## Step 1: Outline use cases and constraints @@ -95,7 +95,7 @@ t5 product4 category1 1 5.00 5 6 ... ``` -The **Sales Rank Service** could use **MapReduce**, using the **Sales API** server log files as input and writing the results to an aggregate table `sales_rank` in a **SQL Database**. We should discuss the [use cases and tradeoffs between choosing SQL or NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql). +The **Sales Rank Service** could use **MapReduce**, using the **Sales API** server log files as input and writing the results to an aggregate table `sales_rank` in a **SQL Database**. We should discuss the [use cases and tradeoffs between choosing SQL or NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql). We'll use a multi-step **MapReduce**: @@ -196,15 +196,15 @@ FOREIGN KEY(category_id) REFERENCES Categories(id) FOREIGN KEY(product_id) REFERENCES Products(id) ``` -We'll create an [index](https://github.com/donnemartin/system-design-primer#use-good-indices) on `id `, `category_id`, and `product_id` to speed up lookups (log-time instead of scanning the entire table) and to keep the data in memory. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 +We'll create an [index](https://github.com/ido777/system-design-primer-update#use-good-indices) on `id `, `category_id`, and `product_id` to speed up lookups (log-time instead of scanning the entire table) and to keep the data in memory. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 ### Use case: User views the past week's most popular products by category -* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) +* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * The **Web Server** forwards the request to the **Read API** server * The **Read API** server reads from the **SQL Database** `sales_rank` table -We'll use a public [**REST API**](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest): +We'll use a public [**REST API**](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest): ``` $ curl https://amazon.com/api/v1/popular?category_id=1234 @@ -233,7 +233,7 @@ Response: }, ``` -For internal communications, we could use [Remote Procedure Calls](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc). +For internal communications, we could use [Remote Procedure Calls](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc). ## Step 4: Scale the design @@ -249,20 +249,20 @@ It's important to discuss what bottlenecks you might encounter with the initial We'll introduce some components to complete the design and to address scalability issues. Internal load balancers are not shown to reduce clutter. -*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: +*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: -* [DNS](https://github.com/donnemartin/system-design-primer#domain-name-system) -* [CDN](https://github.com/donnemartin/system-design-primer#content-delivery-network) -* [Load balancer](https://github.com/donnemartin/system-design-primer#load-balancer) -* [Horizontal scaling](https://github.com/donnemartin/system-design-primer#horizontal-scaling) -* [Web server (reverse proxy)](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) -* [API server (application layer)](https://github.com/donnemartin/system-design-primer#application-layer) -* [Cache](https://github.com/donnemartin/system-design-primer#cache) -* [Relational database management system (RDBMS)](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) -* [SQL write master-slave failover](https://github.com/donnemartin/system-design-primer#fail-over) -* [Master-slave replication](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [Consistency patterns](https://github.com/donnemartin/system-design-primer#consistency-patterns) -* [Availability patterns](https://github.com/donnemartin/system-design-primer#availability-patterns) +* [DNS](https://github.com/ido777/system-design-primer-update#domain-name-system) +* [CDN](https://github.com/ido777/system-design-primer-update#content-delivery-network) +* [Load balancer](https://github.com/ido777/system-design-primer-update#load-balancer) +* [Horizontal scaling](https://github.com/ido777/system-design-primer-update#horizontal-scaling) +* [Web server (reverse proxy)](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) +* [API server (application layer)](https://github.com/ido777/system-design-primer-update#application-layer) +* [Cache](https://github.com/ido777/system-design-primer-update#cache) +* [Relational database management system (RDBMS)](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) +* [SQL write master-slave failover](https://github.com/ido777/system-design-primer-update#fail-over) +* [Master-slave replication](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [Consistency patterns](https://github.com/ido777/system-design-primer-update#consistency-patterns) +* [Availability patterns](https://github.com/ido777/system-design-primer-update#availability-patterns) The **Analytics Database** could use a data warehousing solution such as Amazon Redshift or Google BigQuery. @@ -274,10 +274,10 @@ To address the 40,000 *average* read requests per second (higher at peak), traff SQL scaling patterns include: -* [Federation](https://github.com/donnemartin/system-design-primer#federation) -* [Sharding](https://github.com/donnemartin/system-design-primer#sharding) -* [Denormalization](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL Tuning](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [Federation](https://github.com/ido777/system-design-primer-update#federation) +* [Sharding](https://github.com/ido777/system-design-primer-update#sharding) +* [Denormalization](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL Tuning](https://github.com/ido777/system-design-primer-update#sql-tuning) We should also consider moving some data to a **NoSQL Database**. @@ -287,50 +287,50 @@ We should also consider moving some data to a **NoSQL Database**. #### NoSQL -* [Key-value store](https://github.com/donnemartin/system-design-primer#key-value-store) -* [Document store](https://github.com/donnemartin/system-design-primer#document-store) -* [Wide column store](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [Graph database](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [Key-value store](https://github.com/ido777/system-design-primer-update#key-value-store) +* [Document store](https://github.com/ido777/system-design-primer-update#document-store) +* [Wide column store](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [Graph database](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### Caching * Where to cache - * [Client caching](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN caching](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web server caching](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [Database caching](https://github.com/donnemartin/system-design-primer#database-caching) - * [Application caching](https://github.com/donnemartin/system-design-primer#application-caching) + * [Client caching](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN caching](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web server caching](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [Database caching](https://github.com/ido777/system-design-primer-update#database-caching) + * [Application caching](https://github.com/ido777/system-design-primer-update#application-caching) * What to cache - * [Caching at the database query level](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [Caching at the object level](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [Caching at the database query level](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [Caching at the object level](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * When to update the cache - * [Cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside) - * [Write-through](https://github.com/donnemartin/system-design-primer#write-through) - * [Write-behind (write-back)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [Refresh ahead](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [Cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside) + * [Write-through](https://github.com/ido777/system-design-primer-update#write-through) + * [Write-behind (write-back)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [Refresh ahead](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### Asynchronism and microservices -* [Message queues](https://github.com/donnemartin/system-design-primer#message-queues) -* [Task queues](https://github.com/donnemartin/system-design-primer#task-queues) -* [Back pressure](https://github.com/donnemartin/system-design-primer#back-pressure) -* [Microservices](https://github.com/donnemartin/system-design-primer#microservices) +* [Message queues](https://github.com/ido777/system-design-primer-update#message-queues) +* [Task queues](https://github.com/ido777/system-design-primer-update#task-queues) +* [Back pressure](https://github.com/ido777/system-design-primer-update#back-pressure) +* [Microservices](https://github.com/ido777/system-design-primer-update#microservices) ### Communications * Discuss tradeoffs: - * External communication with clients - [HTTP APIs following REST](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * Internal communications - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [Service discovery](https://github.com/donnemartin/system-design-primer#service-discovery) + * External communication with clients - [HTTP APIs following REST](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * Internal communications - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [Service discovery](https://github.com/ido777/system-design-primer-update#service-discovery) ### Security -Refer to the [security section](https://github.com/donnemartin/system-design-primer#security). +Refer to the [security section](https://github.com/ido777/system-design-primer-update#security). ### Latency numbers -See [Latency numbers every programmer should know](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know). +See [Latency numbers every programmer should know](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know). ### Ongoing diff --git a/solutions/system_design/scaling_aws/README-zh-Hans.md b/solutions/system_design/scaling_aws/README-zh-Hans.md index c071c70e..1be46670 100644 --- a/solutions/system_design/scaling_aws/README-zh-Hans.md +++ b/solutions/system_design/scaling_aws/README-zh-Hans.md @@ -1,6 +1,6 @@ # 在 AWS 上设计支持百万级到千万级用户的系统 -**注释:为了避免重复,这篇文章的链接直接关联到 [系统设计主题](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) 的相关章节。为一讨论要点、折中方案和可选方案做参考。** +**注释:为了避免重复,这篇文章的链接直接关联到 [系统设计主题](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) 的相关章节。为一讨论要点、折中方案和可选方案做参考。** ## 第 1 步:用例和约束概要 @@ -83,7 +83,7 @@ * **Web 服务器** 在 EC2 上 * 存储用户数据 - * [**MySQL 数据库**](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) + * [**MySQL 数据库**](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) 运用 **纵向扩展**: @@ -96,7 +96,7 @@ **折中方案, 可选方案, 和其他细节:** -* **纵向扩展** 的可选方案是 [**横向扩展**](https://github.com/donnemartin/system-design-primer#horizontal-scaling) +* **纵向扩展** 的可选方案是 [**横向扩展**](https://github.com/ido777/system-design-primer-update#horizontal-scaling) #### 自 SQL 开始,但认真考虑 NoSQL @@ -104,8 +104,8 @@ **折中方案, 可选方案, 和其他细节:** -* 查阅 [关系型数据库管理系统 (RDBMS)](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) 章节 -* 讨论使用 [SQL 或 NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) 的原因 +* 查阅 [关系型数据库管理系统 (RDBMS)](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) 章节 +* 讨论使用 [SQL 或 NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) 的原因 #### 分配公共静态 IP @@ -118,7 +118,7 @@ **折中方案, 可选方案, 和其他细节:** -* 查阅 [域名系统](https://github.com/donnemartin/system-design-primer#domain-name-system) 章节 +* 查阅 [域名系统](https://github.com/ido777/system-design-primer-update#domain-name-system) 章节 #### 安全的 Web 服务器 @@ -131,7 +131,7 @@ **折中方案, 可选方案, 和其他细节:** -* 查阅 [安全](https://github.com/donnemartin/system-design-primer#security) 章节 +* 查阅 [安全](https://github.com/ido777/system-design-primer-update#security) 章节 ## 第 4 步:扩展设计 @@ -187,7 +187,7 @@ **折中方案, 可选方案, 和其他细节:** -* 查阅 [安全](https://github.com/donnemartin/system-design-primer#security) 章节 +* 查阅 [安全](https://github.com/ido777/system-design-primer-update#security) 章节 ### 用户+++ @@ -201,18 +201,18 @@ * 下面的目标试图用 **Web服务器** 解决扩展问题 * 基于 **基准/负载测试** 和 **分析**,你可能只需要实现其中的一两个技术 -* 使用 [**横向扩展**](https://github.com/donnemartin/system-design-primer#horizontal-scaling) 来处理增加的负载和单点故障 - * 添加 [**负载均衡器**](https://github.com/donnemartin/system-design-primer#load-balancer) 例如 Amazon 的 ELB 或 HAProxy +* 使用 [**横向扩展**](https://github.com/ido777/system-design-primer-update#horizontal-scaling) 来处理增加的负载和单点故障 + * 添加 [**负载均衡器**](https://github.com/ido777/system-design-primer-update#load-balancer) 例如 Amazon 的 ELB 或 HAProxy * ELB 是高可用的 - * 如果你正在配置自己的 **负载均衡器**, 在多个可用区域中设置多台服务器用于 [双活](https://github.com/donnemartin/system-design-primer#active-active) 或 [主被](https://github.com/donnemartin/system-design-primer#active-passive) 将提高可用性 + * 如果你正在配置自己的 **负载均衡器**, 在多个可用区域中设置多台服务器用于 [双活](https://github.com/ido777/system-design-primer-update#active-active) 或 [主被](https://github.com/ido777/system-design-primer-update#active-passive) 将提高可用性 * 终止在 **负载平衡器** 上的SSL,以减少后端服务器上的计算负载,并简化证书管理 * 在多个可用区域中使用多台 **Web服务器** - * 在多个可用区域的 [**主-从 故障转移**](https://github.com/donnemartin/system-design-primer#master-slave-replication) 模式中使用多个 **MySQL** 实例来改进冗余 -* 分离 **Web 服务器** 和 [**应用服务器**](https://github.com/donnemartin/system-design-primer#application-layer) + * 在多个可用区域的 [**主-从 故障转移**](https://github.com/ido777/system-design-primer-update#master-slave-replication) 模式中使用多个 **MySQL** 实例来改进冗余 +* 分离 **Web 服务器** 和 [**应用服务器**](https://github.com/ido777/system-design-primer-update#application-layer) * 独立扩展和配置每一层 - * **Web 服务器** 可以作为 [**反向代理**](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) + * **Web 服务器** 可以作为 [**反向代理**](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * 例如, 你可以添加 **应用服务器** 处理 **读 API** 而另外一些处理 **写 API** -* 将静态(和一些动态)内容转移到 [**内容分发网络 (CDN)**](https://github.com/donnemartin/system-design-primer#content-delivery-network) 例如 CloudFront 以减少负载和延迟 +* 将静态(和一些动态)内容转移到 [**内容分发网络 (CDN)**](https://github.com/ido777/system-design-primer-update#content-delivery-network) 例如 CloudFront 以减少负载和延迟 **折中方案, 可选方案, 和其他细节:** @@ -232,13 +232,13 @@ * 下面的目标试图解决 **MySQL数据库** 的伸缩性问题 * * 基于 **基准/负载测试** 和 **分析**,你可能只需要实现其中的一两个技术 -* 将下列数据移动到一个 [**内存缓存**](https://github.com/donnemartin/system-design-primer#cache),例如弹性缓存,以减少负载和延迟: +* 将下列数据移动到一个 [**内存缓存**](https://github.com/ido777/system-design-primer-update#cache),例如弹性缓存,以减少负载和延迟: * **MySQL** 中频繁访问的内容 * 首先, 尝试配置 **MySQL 数据库** 缓存以查看是否足以在实现 **内存缓存** 之前缓解瓶颈 * 来自 **Web 服务器** 的会话数据 * **Web 服务器** 变成无状态的, 允许 **自动伸缩** - * 从内存中读取 1 MB 内存需要大约 250 微秒,而从SSD中读取时间要长 4 倍,从磁盘读取的时间要长 80 倍。1 -* 添加 [**MySQL 读取副本**](https://github.com/donnemartin/system-design-primer#master-slave-replication) 来减少写主线程的负载 + * 从内存中读取 1 MB 内存需要大约 250 微秒,而从SSD中读取时间要长 4 倍,从磁盘读取的时间要长 80 倍。1 +* 添加 [**MySQL 读取副本**](https://github.com/ido777/system-design-primer-update#master-slave-replication) 来减少写主线程的负载 * 添加更多 **Web 服务器** and **应用服务器** 来提高响应 **折中方案, 可选方案, 和其他细节:** @@ -254,7 +254,7 @@ **折中方案, 可选方案, 和其他细节:** -* 查阅 [关系型数据库管理系统 (RDBMS)](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) 章节 +* 查阅 [关系型数据库管理系统 (RDBMS)](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) 章节 ### 用户++++ @@ -317,14 +317,14 @@ SQL 扩展模型包括: -* [集合](https://github.com/donnemartin/system-design-primer#federation) -* [分片](https://github.com/donnemartin/system-design-primer#sharding) -* [反范式](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL 调优](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [集合](https://github.com/ido777/system-design-primer-update#federation) +* [分片](https://github.com/ido777/system-design-primer-update#sharding) +* [反范式](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL 调优](https://github.com/ido777/system-design-primer-update#sql-tuning) -为了进一步处理高读和写请求,我们还应该考虑将适当的数据移动到一个 [**NoSQL数据库**](https://github.com/donnemartin/system-design-primer#nosql) ,例如 DynamoDB。 +为了进一步处理高读和写请求,我们还应该考虑将适当的数据移动到一个 [**NoSQL数据库**](https://github.com/ido777/system-design-primer-update#nosql) ,例如 DynamoDB。 -我们可以进一步分离我们的 [**应用服务器**](https://github.com/donnemartin/system-design-primer#application-layer) 以允许独立扩展。不需要实时完成的批处理任务和计算可以通过 Queues 和 Workers 异步完成: +我们可以进一步分离我们的 [**应用服务器**](https://github.com/ido777/system-design-primer-update#application-layer) 以允许独立扩展。不需要实时完成的批处理任务和计算可以通过 Queues 和 Workers 异步完成: * 以照片服务为例,照片上传和缩略图的创建可以分开进行 * **客户端** 上传图片 @@ -344,58 +344,58 @@ SQL 扩展模型包括: ### SQL 扩展模式 -* [读取副本](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [集合](https://github.com/donnemartin/system-design-primer#federation) -* [分区](https://github.com/donnemartin/system-design-primer#sharding) -* [反规范化](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL 调优](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [读取副本](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [集合](https://github.com/ido777/system-design-primer-update#federation) +* [分区](https://github.com/ido777/system-design-primer-update#sharding) +* [反规范化](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL 调优](https://github.com/ido777/system-design-primer-update#sql-tuning) #### NoSQL -* [键值存储](https://github.com/donnemartin/system-design-primer#key-value-store) -* [文档存储](https://github.com/donnemartin/system-design-primer#document-store) -* [宽表存储](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [图数据库](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [键值存储](https://github.com/ido777/system-design-primer-update#key-value-store) +* [文档存储](https://github.com/ido777/system-design-primer-update#document-store) +* [宽表存储](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [图数据库](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### 缓存 * 缓存到哪里 - * [客户端缓存](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN 缓存](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web 服务缓存](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [数据库缓存](https://github.com/donnemartin/system-design-primer#database-caching) - * [应用缓存](https://github.com/donnemartin/system-design-primer#application-caching) + * [客户端缓存](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN 缓存](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web 服务缓存](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [数据库缓存](https://github.com/ido777/system-design-primer-update#database-caching) + * [应用缓存](https://github.com/ido777/system-design-primer-update#application-caching) * 缓存什么 - * [数据库请求层缓存](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [对象层缓存](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [数据库请求层缓存](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [对象层缓存](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * 何时更新缓存 - * [预留缓存](https://github.com/donnemartin/system-design-primer#cache-aside) - * [完全写入](https://github.com/donnemartin/system-design-primer#write-through) - * [延迟写 (写回)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [事先更新](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [预留缓存](https://github.com/ido777/system-design-primer-update#cache-aside) + * [完全写入](https://github.com/ido777/system-design-primer-update#write-through) + * [延迟写 (写回)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [事先更新](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### 异步性和微服务 -* [消息队列](https://github.com/donnemartin/system-design-primer#message-queues) -* [任务队列](https://github.com/donnemartin/system-design-primer#task-queues) -* [回退压力](https://github.com/donnemartin/system-design-primer#back-pressure) -* [微服务](https://github.com/donnemartin/system-design-primer#microservices) +* [消息队列](https://github.com/ido777/system-design-primer-update#message-queues) +* [任务队列](https://github.com/ido777/system-design-primer-update#task-queues) +* [回退压力](https://github.com/ido777/system-design-primer-update#back-pressure) +* [微服务](https://github.com/ido777/system-design-primer-update#microservices) ### 沟通 * 关于折中方案的讨论: - * 客户端的外部通讯 - [遵循 REST 的 HTTP APIs](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * 内部通讯 - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [服务探索](https://github.com/donnemartin/system-design-primer#service-discovery) + * 客户端的外部通讯 - [遵循 REST 的 HTTP APIs](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * 内部通讯 - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [服务探索](https://github.com/ido777/system-design-primer-update#service-discovery) ### 安全性 -参考 [安全章节](https://github.com/donnemartin/system-design-primer#security) +参考 [安全章节](https://github.com/ido777/system-design-primer-update#security) ### 延迟数字指标 -查阅 [每个程序员必懂的延迟数字](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know) +查阅 [每个程序员必懂的延迟数字](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know) ### 正在进行 diff --git a/solutions/system_design/scaling_aws/README.md b/solutions/system_design/scaling_aws/README.md index 9ffcdc40..29768d2f 100644 --- a/solutions/system_design/scaling_aws/README.md +++ b/solutions/system_design/scaling_aws/README.md @@ -1,6 +1,6 @@ # Design a system that scales to millions of users on AWS -*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* +*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* ## Step 1: Outline use cases and constraints @@ -83,7 +83,7 @@ Handy conversion guide: * **Web server** on EC2 * Storage for user data - * [**MySQL Database**](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) + * [**MySQL Database**](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) Use **Vertical Scaling**: @@ -96,7 +96,7 @@ Use **Vertical Scaling**: *Trade-offs, alternatives, and additional details:* -* The alternative to **Vertical Scaling** is [**Horizontal scaling**](https://github.com/donnemartin/system-design-primer#horizontal-scaling) +* The alternative to **Vertical Scaling** is [**Horizontal scaling**](https://github.com/ido777/system-design-primer-update#horizontal-scaling) #### Start with SQL, consider NoSQL @@ -104,8 +104,8 @@ The constraints assume there is a need for relational data. We can start off us *Trade-offs, alternatives, and additional details:* -* See the [Relational database management system (RDBMS)](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) section -* Discuss reasons to use [SQL or NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* See the [Relational database management system (RDBMS)](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) section +* Discuss reasons to use [SQL or NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) #### Assign a public static IP @@ -118,7 +118,7 @@ Add a **DNS** such as Route 53 to map the domain to the instance's public IP. *Trade-offs, alternatives, and additional details:* -* See the [Domain name system](https://github.com/donnemartin/system-design-primer#domain-name-system) section +* See the [Domain name system](https://github.com/ido777/system-design-primer-update#domain-name-system) section #### Secure the web server @@ -131,7 +131,7 @@ Add a **DNS** such as Route 53 to map the domain to the instance's public IP. *Trade-offs, alternatives, and additional details:* -* See the [Security](https://github.com/donnemartin/system-design-primer#security) section +* See the [Security](https://github.com/ido777/system-design-primer-update#security) section ## Step 4: Scale the design @@ -187,7 +187,7 @@ We've been able to address these issues with **Vertical Scaling** so far. Unfor *Trade-offs, alternatives, and additional details:* -* See the [Security](https://github.com/donnemartin/system-design-primer#security) section +* See the [Security](https://github.com/ido777/system-design-primer-update#security) section ### Users++ @@ -201,18 +201,18 @@ Our **Benchmarks/Load Tests** and **Profiling** show that our single **Web Serve * The following goals attempt to address the scaling issues with the **Web Server** * Based on the **Benchmarks/Load Tests** and **Profiling**, you might only need to implement one or two of these techniques -* Use [**Horizontal Scaling**](https://github.com/donnemartin/system-design-primer#horizontal-scaling) to handle increasing loads and to address single points of failure - * Add a [**Load Balancer**](https://github.com/donnemartin/system-design-primer#load-balancer) such as Amazon's ELB or HAProxy +* Use [**Horizontal Scaling**](https://github.com/ido777/system-design-primer-update#horizontal-scaling) to handle increasing loads and to address single points of failure + * Add a [**Load Balancer**](https://github.com/ido777/system-design-primer-update#load-balancer) such as Amazon's ELB or HAProxy * ELB is highly available - * If you are configuring your own **Load Balancer**, setting up multiple servers in [active-active](https://github.com/donnemartin/system-design-primer#active-active) or [active-passive](https://github.com/donnemartin/system-design-primer#active-passive) in multiple availability zones will improve availability + * If you are configuring your own **Load Balancer**, setting up multiple servers in [active-active](https://github.com/ido777/system-design-primer-update#active-active) or [active-passive](https://github.com/ido777/system-design-primer-update#active-passive) in multiple availability zones will improve availability * Terminate SSL on the **Load Balancer** to reduce computational load on backend servers and to simplify certificate administration * Use multiple **Web Servers** spread out over multiple availability zones - * Use multiple **MySQL** instances in [**Master-Slave Failover**](https://github.com/donnemartin/system-design-primer#master-slave-replication) mode across multiple availability zones to improve redundancy -* Separate out the **Web Servers** from the [**Application Servers**](https://github.com/donnemartin/system-design-primer#application-layer) + * Use multiple **MySQL** instances in [**Master-Slave Failover**](https://github.com/ido777/system-design-primer-update#master-slave-replication) mode across multiple availability zones to improve redundancy +* Separate out the **Web Servers** from the [**Application Servers**](https://github.com/ido777/system-design-primer-update#application-layer) * Scale and configure both layers independently - * **Web Servers** can run as a [**Reverse Proxy**](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) + * **Web Servers** can run as a [**Reverse Proxy**](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * For example, you can add **Application Servers** handling **Read APIs** while others handle **Write APIs** -* Move static (and some dynamic) content to a [**Content Delivery Network (CDN)**](https://github.com/donnemartin/system-design-primer#content-delivery-network) such as CloudFront to reduce load and latency +* Move static (and some dynamic) content to a [**Content Delivery Network (CDN)**](https://github.com/ido777/system-design-primer-update#content-delivery-network) such as CloudFront to reduce load and latency *Trade-offs, alternatives, and additional details:* @@ -232,13 +232,13 @@ Our **Benchmarks/Load Tests** and **Profiling** show that we are read-heavy (100 * The following goals attempt to address the scaling issues with the **MySQL Database** * Based on the **Benchmarks/Load Tests** and **Profiling**, you might only need to implement one or two of these techniques -* Move the following data to a [**Memory Cache**](https://github.com/donnemartin/system-design-primer#cache) such as Elasticache to reduce load and latency: +* Move the following data to a [**Memory Cache**](https://github.com/ido777/system-design-primer-update#cache) such as Elasticache to reduce load and latency: * Frequently accessed content from **MySQL** * First, try to configure the **MySQL Database** cache to see if that is sufficient to relieve the bottleneck before implementing a **Memory Cache** * Session data from the **Web Servers** * The **Web Servers** become stateless, allowing for **Autoscaling** - * Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 -* Add [**MySQL Read Replicas**](https://github.com/donnemartin/system-design-primer#master-slave-replication) to reduce load on the write master + * Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 +* Add [**MySQL Read Replicas**](https://github.com/ido777/system-design-primer-update#master-slave-replication) to reduce load on the write master * Add more **Web Servers** and **Application Servers** to improve responsiveness *Trade-offs, alternatives, and additional details:* @@ -254,7 +254,7 @@ Our **Benchmarks/Load Tests** and **Profiling** show that we are read-heavy (100 *Trade-offs, alternatives, and additional details:* -* See the [Relational database management system (RDBMS)](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) section +* See the [Relational database management system (RDBMS)](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) section ### Users++++ @@ -317,14 +317,14 @@ We'll continue to address scaling issues due to the problem's constraints: SQL scaling patterns include: -* [Federation](https://github.com/donnemartin/system-design-primer#federation) -* [Sharding](https://github.com/donnemartin/system-design-primer#sharding) -* [Denormalization](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL Tuning](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [Federation](https://github.com/ido777/system-design-primer-update#federation) +* [Sharding](https://github.com/ido777/system-design-primer-update#sharding) +* [Denormalization](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL Tuning](https://github.com/ido777/system-design-primer-update#sql-tuning) -To further address the high read and write requests, we should also consider moving appropriate data to a [**NoSQL Database**](https://github.com/donnemartin/system-design-primer#nosql) such as DynamoDB. +To further address the high read and write requests, we should also consider moving appropriate data to a [**NoSQL Database**](https://github.com/ido777/system-design-primer-update#nosql) such as DynamoDB. -We can further separate out our [**Application Servers**](https://github.com/donnemartin/system-design-primer#application-layer) to allow for independent scaling. Batch processes or computations that do not need to be done in real-time can be done [**Asynchronously**](https://github.com/donnemartin/system-design-primer#asynchronism) with **Queues** and **Workers**: +We can further separate out our [**Application Servers**](https://github.com/ido777/system-design-primer-update#application-layer) to allow for independent scaling. Batch processes or computations that do not need to be done in real-time can be done [**Asynchronously**](https://github.com/ido777/system-design-primer-update#asynchronism) with **Queues** and **Workers**: * For example, in a photo service, the photo upload and the thumbnail creation can be separated: * **Client** uploads photo @@ -344,58 +344,58 @@ We can further separate out our [**Application Servers**](https://github.com/don ### SQL scaling patterns -* [Read replicas](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [Federation](https://github.com/donnemartin/system-design-primer#federation) -* [Sharding](https://github.com/donnemartin/system-design-primer#sharding) -* [Denormalization](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL Tuning](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [Read replicas](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [Federation](https://github.com/ido777/system-design-primer-update#federation) +* [Sharding](https://github.com/ido777/system-design-primer-update#sharding) +* [Denormalization](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL Tuning](https://github.com/ido777/system-design-primer-update#sql-tuning) #### NoSQL -* [Key-value store](https://github.com/donnemartin/system-design-primer#key-value-store) -* [Document store](https://github.com/donnemartin/system-design-primer#document-store) -* [Wide column store](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [Graph database](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [Key-value store](https://github.com/ido777/system-design-primer-update#key-value-store) +* [Document store](https://github.com/ido777/system-design-primer-update#document-store) +* [Wide column store](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [Graph database](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### Caching * Where to cache - * [Client caching](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN caching](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web server caching](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [Database caching](https://github.com/donnemartin/system-design-primer#database-caching) - * [Application caching](https://github.com/donnemartin/system-design-primer#application-caching) + * [Client caching](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN caching](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web server caching](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [Database caching](https://github.com/ido777/system-design-primer-update#database-caching) + * [Application caching](https://github.com/ido777/system-design-primer-update#application-caching) * What to cache - * [Caching at the database query level](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [Caching at the object level](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [Caching at the database query level](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [Caching at the object level](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * When to update the cache - * [Cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside) - * [Write-through](https://github.com/donnemartin/system-design-primer#write-through) - * [Write-behind (write-back)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [Refresh ahead](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [Cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside) + * [Write-through](https://github.com/ido777/system-design-primer-update#write-through) + * [Write-behind (write-back)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [Refresh ahead](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### Asynchronism and microservices -* [Message queues](https://github.com/donnemartin/system-design-primer#message-queues) -* [Task queues](https://github.com/donnemartin/system-design-primer#task-queues) -* [Back pressure](https://github.com/donnemartin/system-design-primer#back-pressure) -* [Microservices](https://github.com/donnemartin/system-design-primer#microservices) +* [Message queues](https://github.com/ido777/system-design-primer-update#message-queues) +* [Task queues](https://github.com/ido777/system-design-primer-update#task-queues) +* [Back pressure](https://github.com/ido777/system-design-primer-update#back-pressure) +* [Microservices](https://github.com/ido777/system-design-primer-update#microservices) ### Communications * Discuss tradeoffs: - * External communication with clients - [HTTP APIs following REST](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * Internal communications - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [Service discovery](https://github.com/donnemartin/system-design-primer#service-discovery) + * External communication with clients - [HTTP APIs following REST](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * Internal communications - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [Service discovery](https://github.com/ido777/system-design-primer-update#service-discovery) ### Security -Refer to the [security section](https://github.com/donnemartin/system-design-primer#security). +Refer to the [security section](https://github.com/ido777/system-design-primer-update#security). ### Latency numbers -See [Latency numbers every programmer should know](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know). +See [Latency numbers every programmer should know](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know). ### Ongoing diff --git a/solutions/system_design/social_graph/README-zh-Hans.md b/solutions/system_design/social_graph/README-zh-Hans.md index 07b8e3e7..c465ca80 100644 --- a/solutions/system_design/social_graph/README-zh-Hans.md +++ b/solutions/system_design/social_graph/README-zh-Hans.md @@ -1,6 +1,6 @@ # 为社交网络设计数据结构 -**注释:为了避免重复,这篇文章的链接直接关联到 [系统设计主题](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) 的相关章节。为一讨论要点、折中方案和可选方案做参考。** +**注释:为了避免重复,这篇文章的链接直接关联到 [系统设计主题](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) 的相关章节。为一讨论要点、折中方案和可选方案做参考。** ## 第 1 步:用例和约束概要 @@ -99,9 +99,9 @@ class Graph(Graph): return None ``` -我们不能在同一台机器上满足所有用户,我们需要通过 **人员服务器** [拆分](https://github.com/donnemartin/system-design-primer#sharding) 用户并且通过 **查询服务** 访问。 +我们不能在同一台机器上满足所有用户,我们需要通过 **人员服务器** [拆分](https://github.com/ido777/system-design-primer-update#sharding) 用户并且通过 **查询服务** 访问。 -* **客户端** 向 **服务器** 发送请求,**服务器** 作为 [反向代理](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) +* **客户端** 向 **服务器** 发送请求,**服务器** 作为 [反向代理](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * **搜索 API** 服务器向 **用户图服务** 转发请求 * **用户图服务** 有以下功能: * 使用 **查询服务** 找到当前用户信息存储的 **人员服务器** @@ -217,7 +217,7 @@ class UserGraphService(object): return None ``` -我们用的是公共的 [**REST API**](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest): +我们用的是公共的 [**REST API**](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest): ``` $ curl https://social.com/api/v1/friend_search?person_id=1234 @@ -243,7 +243,7 @@ $ curl https://social.com/api/v1/friend_search?person_id=1234 }, ``` -内部通信使用 [远端过程调用](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc)。 +内部通信使用 [远端过程调用](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc)。 ## 第 4 步:扩展设计 @@ -259,25 +259,25 @@ $ curl https://social.com/api/v1/friend_search?person_id=1234 我们即将介绍一些组件来完成设计和解决扩展性问题。内部负载均衡不显示以减少混乱。 -**避免重复讨论**,以下网址链接到 [系统设计主题](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) 相关的主流方案、折中方案和替代方案。 +**避免重复讨论**,以下网址链接到 [系统设计主题](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) 相关的主流方案、折中方案和替代方案。 -* [DNS](https://github.com/donnemartin/system-design-primer#domain-name-system) -* [负载均衡](https://github.com/donnemartin/system-design-primer#load-balancer) -* [横向扩展](https://github.com/donnemartin/system-design-primer#horizontal-scaling) -* [Web 服务器(反向代理)](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) -* [API 服务器(应用层)](https://github.com/donnemartin/system-design-primer#application-layer) -* [缓存](https://github.com/donnemartin/system-design-primer#cache) -* [一致性模式](https://github.com/donnemartin/system-design-primer#consistency-patterns) -* [可用性模式](https://github.com/donnemartin/system-design-primer#availability-patterns) +* [DNS](https://github.com/ido777/system-design-primer-update#domain-name-system) +* [负载均衡](https://github.com/ido777/system-design-primer-update#load-balancer) +* [横向扩展](https://github.com/ido777/system-design-primer-update#horizontal-scaling) +* [Web 服务器(反向代理)](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) +* [API 服务器(应用层)](https://github.com/ido777/system-design-primer-update#application-layer) +* [缓存](https://github.com/ido777/system-design-primer-update#cache) +* [一致性模式](https://github.com/ido777/system-design-primer-update#consistency-patterns) +* [可用性模式](https://github.com/ido777/system-design-primer-update#availability-patterns) -解决 **平均** 每秒 400 次请求的限制(峰值),人员数据可以存在例如 Redis 或 Memcached 这样的 **内存** 中以减少响应次数和下游流量通信服务。这尤其在用户执行多次连续查询和查询哪些广泛连接的人时十分有用。从内存中读取 1MB 数据大约要 250 微秒,从 SSD 中读取同样大小的数据时间要长 4 倍,从硬盘要长 80 倍。1 +解决 **平均** 每秒 400 次请求的限制(峰值),人员数据可以存在例如 Redis 或 Memcached 这样的 **内存** 中以减少响应次数和下游流量通信服务。这尤其在用户执行多次连续查询和查询哪些广泛连接的人时十分有用。从内存中读取 1MB 数据大约要 250 微秒,从 SSD 中读取同样大小的数据时间要长 4 倍,从硬盘要长 80 倍。1 以下是进一步优化方案: * 在 **内存** 中存储完整的或部分的BFS遍历加快后续查找 * 在 **NoSQL 数据库** 中批量离线计算并存储完整的或部分的BFS遍历加快后续查找 * 在同一台 **人员服务器** 上托管批处理同一批朋友查找减少机器跳转 - * 通过地理位置 [拆分](https://github.com/donnemartin/system-design-primer#sharding) **人员服务器** 来进一步优化,因为朋友通常住得都比较近 + * 通过地理位置 [拆分](https://github.com/ido777/system-design-primer-update#sharding) **人员服务器** 来进一步优化,因为朋友通常住得都比较近 * 同时进行两个 BFS 查找,一个从 source 开始,一个从 destination 开始,然后合并两个路径 * 从有庞大朋友圈的人开始找起,这样更有可能减小当前用户和搜索目标之间的 [离散度数](https://en.wikipedia.org/wiki/Six_degrees_of_separation) * 在询问用户是否继续查询之前设置基于时间或跳跃数阈值,当在某些案例中搜索耗费时间过长时。 @@ -289,58 +289,58 @@ $ curl https://social.com/api/v1/friend_search?person_id=1234 ### SQL 扩展模式 -* [读取副本](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [集合](https://github.com/donnemartin/system-design-primer#federation) -* [分区](https://github.com/donnemartin/system-design-primer#sharding) -* [反规范化](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL 调优](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [读取副本](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [集合](https://github.com/ido777/system-design-primer-update#federation) +* [分区](https://github.com/ido777/system-design-primer-update#sharding) +* [反规范化](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL 调优](https://github.com/ido777/system-design-primer-update#sql-tuning) #### NoSQL -* [键值存储](https://github.com/donnemartin/system-design-primer#key-value-store) -* [文档存储](https://github.com/donnemartin/system-design-primer#document-store) -* [宽表存储](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [图数据库](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [键值存储](https://github.com/ido777/system-design-primer-update#key-value-store) +* [文档存储](https://github.com/ido777/system-design-primer-update#document-store) +* [宽表存储](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [图数据库](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### 缓存 * 缓存到哪里 - * [客户端缓存](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN 缓存](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web 服务缓存](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [数据库缓存](https://github.com/donnemartin/system-design-primer#database-caching) - * [应用缓存](https://github.com/donnemartin/system-design-primer#application-caching) + * [客户端缓存](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN 缓存](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web 服务缓存](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [数据库缓存](https://github.com/ido777/system-design-primer-update#database-caching) + * [应用缓存](https://github.com/ido777/system-design-primer-update#application-caching) * 缓存什么 - * [数据库请求层缓存](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [对象层缓存](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [数据库请求层缓存](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [对象层缓存](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * 何时更新缓存 - * [预留缓存](https://github.com/donnemartin/system-design-primer#cache-aside) - * [完全写入](https://github.com/donnemartin/system-design-primer#write-through) - * [延迟写 (写回)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [事先更新](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [预留缓存](https://github.com/ido777/system-design-primer-update#cache-aside) + * [完全写入](https://github.com/ido777/system-design-primer-update#write-through) + * [延迟写 (写回)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [事先更新](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### 异步性和微服务 -* [消息队列](https://github.com/donnemartin/system-design-primer#message-queues) -* [任务队列](https://github.com/donnemartin/system-design-primer#task-queues) -* [回退压力](https://github.com/donnemartin/system-design-primer#back-pressure) -* [微服务](https://github.com/donnemartin/system-design-primer#microservices) +* [消息队列](https://github.com/ido777/system-design-primer-update#message-queues) +* [任务队列](https://github.com/ido777/system-design-primer-update#task-queues) +* [回退压力](https://github.com/ido777/system-design-primer-update#back-pressure) +* [微服务](https://github.com/ido777/system-design-primer-update#microservices) ### 沟通 * 关于折中方案的讨论: - * 客户端的外部通讯 - [遵循 REST 的 HTTP APIs](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * 内部通讯 - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [服务探索](https://github.com/donnemartin/system-design-primer#service-discovery) + * 客户端的外部通讯 - [遵循 REST 的 HTTP APIs](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * 内部通讯 - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [服务探索](https://github.com/ido777/system-design-primer-update#service-discovery) ### 安全性 -参考 [安全章节](https://github.com/donnemartin/system-design-primer#security) +参考 [安全章节](https://github.com/ido777/system-design-primer-update#security) ### 延迟数字指标 -查阅 [每个程序员必懂的延迟数字](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know) +查阅 [每个程序员必懂的延迟数字](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know) ### 正在进行 diff --git a/solutions/system_design/social_graph/README.md b/solutions/system_design/social_graph/README.md index 79f698be..f68a3688 100644 --- a/solutions/system_design/social_graph/README.md +++ b/solutions/system_design/social_graph/README.md @@ -1,6 +1,6 @@ # Design the data structures for a social network -*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* +*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* ## Step 1: Outline use cases and constraints @@ -99,9 +99,9 @@ class Graph(Graph): return None ``` -We won't be able to fit all users on the same machine, we'll need to [shard](https://github.com/donnemartin/system-design-primer#sharding) users across **Person Servers** and access them with a **Lookup Service**. +We won't be able to fit all users on the same machine, we'll need to [shard](https://github.com/ido777/system-design-primer-update#sharding) users across **Person Servers** and access them with a **Lookup Service**. -* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) +* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * The **Web Server** forwards the request to the **Search API** server * The **Search API** server forwards the request to the **User Graph Service** * The **User Graph Service** does the following: @@ -218,7 +218,7 @@ class UserGraphService(object): return None ``` -We'll use a public [**REST API**](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest): +We'll use a public [**REST API**](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest): ``` $ curl https://social.com/api/v1/friend_search?person_id=1234 @@ -244,7 +244,7 @@ Response: }, ``` -For internal communications, we could use [Remote Procedure Calls](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc). +For internal communications, we could use [Remote Procedure Calls](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc). ## Step 4: Scale the design @@ -260,25 +260,25 @@ It's important to discuss what bottlenecks you might encounter with the initial We'll introduce some components to complete the design and to address scalability issues. Internal load balancers are not shown to reduce clutter. -*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: +*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: -* [DNS](https://github.com/donnemartin/system-design-primer#domain-name-system) -* [Load balancer](https://github.com/donnemartin/system-design-primer#load-balancer) -* [Horizontal scaling](https://github.com/donnemartin/system-design-primer#horizontal-scaling) -* [Web server (reverse proxy)](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) -* [API server (application layer)](https://github.com/donnemartin/system-design-primer#application-layer) -* [Cache](https://github.com/donnemartin/system-design-primer#cache) -* [Consistency patterns](https://github.com/donnemartin/system-design-primer#consistency-patterns) -* [Availability patterns](https://github.com/donnemartin/system-design-primer#availability-patterns) +* [DNS](https://github.com/ido777/system-design-primer-update#domain-name-system) +* [Load balancer](https://github.com/ido777/system-design-primer-update#load-balancer) +* [Horizontal scaling](https://github.com/ido777/system-design-primer-update#horizontal-scaling) +* [Web server (reverse proxy)](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) +* [API server (application layer)](https://github.com/ido777/system-design-primer-update#application-layer) +* [Cache](https://github.com/ido777/system-design-primer-update#cache) +* [Consistency patterns](https://github.com/ido777/system-design-primer-update#consistency-patterns) +* [Availability patterns](https://github.com/ido777/system-design-primer-update#availability-patterns) -To address the constraint of 400 *average* read requests per second (higher at peak), person data can be served from a **Memory Cache** such as Redis or Memcached to reduce response times and to reduce traffic to downstream services. This could be especially useful for people who do multiple searches in succession and for people who are well-connected. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 +To address the constraint of 400 *average* read requests per second (higher at peak), person data can be served from a **Memory Cache** such as Redis or Memcached to reduce response times and to reduce traffic to downstream services. This could be especially useful for people who do multiple searches in succession and for people who are well-connected. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 Below are further optimizations: * Store complete or partial BFS traversals to speed up subsequent lookups in the **Memory Cache** * Batch compute offline then store complete or partial BFS traversals to speed up subsequent lookups in a **NoSQL Database** * Reduce machine jumps by batching together friend lookups hosted on the same **Person Server** - * [Shard](https://github.com/donnemartin/system-design-primer#sharding) **Person Servers** by location to further improve this, as friends generally live closer to each other + * [Shard](https://github.com/ido777/system-design-primer-update#sharding) **Person Servers** by location to further improve this, as friends generally live closer to each other * Do two BFS searches at the same time, one starting from the source, and one from the destination, then merge the two paths * Start the BFS search from people with large numbers of friends, as they are more likely to reduce the number of [degrees of separation](https://en.wikipedia.org/wiki/Six_degrees_of_separation) between the current user and the search target * Set a limit based on time or number of hops before asking the user if they want to continue searching, as searching could take a considerable amount of time in some cases @@ -290,58 +290,58 @@ Below are further optimizations: ### SQL scaling patterns -* [Read replicas](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [Federation](https://github.com/donnemartin/system-design-primer#federation) -* [Sharding](https://github.com/donnemartin/system-design-primer#sharding) -* [Denormalization](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL Tuning](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [Read replicas](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [Federation](https://github.com/ido777/system-design-primer-update#federation) +* [Sharding](https://github.com/ido777/system-design-primer-update#sharding) +* [Denormalization](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL Tuning](https://github.com/ido777/system-design-primer-update#sql-tuning) #### NoSQL -* [Key-value store](https://github.com/donnemartin/system-design-primer#key-value-store) -* [Document store](https://github.com/donnemartin/system-design-primer#document-store) -* [Wide column store](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [Graph database](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [Key-value store](https://github.com/ido777/system-design-primer-update#key-value-store) +* [Document store](https://github.com/ido777/system-design-primer-update#document-store) +* [Wide column store](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [Graph database](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### Caching * Where to cache - * [Client caching](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN caching](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web server caching](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [Database caching](https://github.com/donnemartin/system-design-primer#database-caching) - * [Application caching](https://github.com/donnemartin/system-design-primer#application-caching) + * [Client caching](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN caching](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web server caching](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [Database caching](https://github.com/ido777/system-design-primer-update#database-caching) + * [Application caching](https://github.com/ido777/system-design-primer-update#application-caching) * What to cache - * [Caching at the database query level](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [Caching at the object level](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [Caching at the database query level](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [Caching at the object level](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * When to update the cache - * [Cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside) - * [Write-through](https://github.com/donnemartin/system-design-primer#write-through) - * [Write-behind (write-back)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [Refresh ahead](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [Cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside) + * [Write-through](https://github.com/ido777/system-design-primer-update#write-through) + * [Write-behind (write-back)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [Refresh ahead](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### Asynchronism and microservices -* [Message queues](https://github.com/donnemartin/system-design-primer#message-queues) -* [Task queues](https://github.com/donnemartin/system-design-primer#task-queues) -* [Back pressure](https://github.com/donnemartin/system-design-primer#back-pressure) -* [Microservices](https://github.com/donnemartin/system-design-primer#microservices) +* [Message queues](https://github.com/ido777/system-design-primer-update#message-queues) +* [Task queues](https://github.com/ido777/system-design-primer-update#task-queues) +* [Back pressure](https://github.com/ido777/system-design-primer-update#back-pressure) +* [Microservices](https://github.com/ido777/system-design-primer-update#microservices) ### Communications * Discuss tradeoffs: - * External communication with clients - [HTTP APIs following REST](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * Internal communications - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [Service discovery](https://github.com/donnemartin/system-design-primer#service-discovery) + * External communication with clients - [HTTP APIs following REST](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * Internal communications - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [Service discovery](https://github.com/ido777/system-design-primer-update#service-discovery) ### Security -Refer to the [security section](https://github.com/donnemartin/system-design-primer#security). +Refer to the [security section](https://github.com/ido777/system-design-primer-update#security). ### Latency numbers -See [Latency numbers every programmer should know](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know). +See [Latency numbers every programmer should know](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know). ### Ongoing diff --git a/solutions/system_design/twitter/README-zh-Hans.md b/solutions/system_design/twitter/README-zh-Hans.md index 30813f3f..91a4a3d2 100644 --- a/solutions/system_design/twitter/README-zh-Hans.md +++ b/solutions/system_design/twitter/README-zh-Hans.md @@ -1,6 +1,6 @@ # 设计推特时间轴与搜索功能 -**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)中的有关部分,以避免重复的内容。你可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** +**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)中的有关部分,以避免重复的内容。你可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** **设计 Facebook 的 feed** 与**设计 Facebook 搜索**与此为同一类型问题。 @@ -100,13 +100,13 @@ ### 用例:用户发表了一篇推特 -我们可以将用户自己发表的推特存储在[关系数据库](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms)中。我们也可以讨论一下[究竟是用 SQL 还是用 NoSQL](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql)。 +我们可以将用户自己发表的推特存储在[关系数据库](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms)中。我们也可以讨论一下[究竟是用 SQL 还是用 NoSQL](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql)。 -构建用户主页时间轴(查看关注用户的活动)以及推送推特是件麻烦事。将推特传播给所有关注者(每秒约递送 6 万条推特)这一操作有可能会使传统的[关系数据库](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms)超负载。因此,我们可以使用 **NoSQL 数据库**或**内存数据库**之类的更快的数据存储方式。从内存读取 1 MB 连续数据大约要花 250 微秒,而从 SSD 读取同样大小的数据要花费 4 倍的时间,从机械硬盘读取需要花费 80 倍以上的时间。1 +构建用户主页时间轴(查看关注用户的活动)以及推送推特是件麻烦事。将推特传播给所有关注者(每秒约递送 6 万条推特)这一操作有可能会使传统的[关系数据库](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms)超负载。因此,我们可以使用 **NoSQL 数据库**或**内存数据库**之类的更快的数据存储方式。从内存读取 1 MB 连续数据大约要花 250 微秒,而从 SSD 读取同样大小的数据要花费 4 倍的时间,从机械硬盘读取需要花费 80 倍以上的时间。1 我们可以将照片、视频之类的媒体存储于**对象存储**中。 -* **客户端**向应用[反向代理](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server)的**Web 服务器**发送一条推特 +* **客户端**向应用[反向代理](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server)的**Web 服务器**发送一条推特 * **Web 服务器**将请求转发给**写 API**服务器 * **写 API**服务器将推特使用 **SQL 数据库**存储于用户时间轴中 * **写 API**调用**消息输出服务**,进行以下操作: @@ -130,7 +130,7 @@ 新发布的推特将被存储在对应用户(关注且活跃的用户)的主页时间轴的**内存缓存**中。 -我们可以调用一个公共的 [REST API](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest): +我们可以调用一个公共的 [REST API](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest): ``` $ curl -X POST --data '{ "user_id": "123", "auth_token": "ABC123", \ @@ -150,7 +150,7 @@ $ curl -X POST --data '{ "user_id": "123", "auth_token": "ABC123", \ } ``` -而对于服务器内部的通信,我们可以使用 [RPC](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc)。 +而对于服务器内部的通信,我们可以使用 [RPC](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc)。 ### 用例:用户浏览主页时间轴 @@ -207,7 +207,7 @@ REST API 与前面的主页时间轴类似,区别只在于取出的推特是 * 规范字母大小写 * 将查询转换为布尔操作 * 查询**搜索集群**(例如[Lucene](https://lucene.apache.org/))检索结果: - * 对集群内的所有服务器进行查询,将有结果的查询进行[发散聚合(Scatter gathers)](https://github.com/donnemartin/system-design-primer#under-development) + * 对集群内的所有服务器进行查询,将有结果的查询进行[发散聚合(Scatter gathers)](https://github.com/ido777/system-design-primer-update#under-development) * 合并取到的条目,进行评分与排序,最终返回结果 REST API: @@ -232,19 +232,19 @@ $ curl https://twitter.com/api/v1/search?query=hello+world 我们将会介绍一些组件来完成设计,并解决架构扩张问题。内置的负载均衡器将不做讨论以节省篇幅。 -**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及可选的替代方案。 +**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及可选的替代方案。 -* [DNS](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#域名系统) -* [负载均衡器](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#负载均衡器) -* [水平拓展](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#水平扩展) -* [反向代理(web 服务器)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器) -* [API 服务(应用层)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用层) -* [缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存) -* [关系型数据库管理系统 (RDBMS)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms) -* [SQL 故障主从切换](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#故障切换) -* [主从复制](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#主从复制) -* [一致性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#一致性模式) -* [可用性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#可用性模式) +* [DNS](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#域名系统) +* [负载均衡器](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#负载均衡器) +* [水平拓展](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#水平扩展) +* [反向代理(web 服务器)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器) +* [API 服务(应用层)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用层) +* [缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存) +* [关系型数据库管理系统 (RDBMS)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#关系型数据库管理系统rdbms) +* [SQL 故障主从切换](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#故障切换) +* [主从复制](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#主从复制) +* [一致性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#一致性模式) +* [可用性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#可用性模式) **消息输出服务**有可能成为性能瓶颈。那些有着百万数量关注着的用户可能发一条推特就需要好几分钟才能完成消息输出进程。这有可能使 @回复 这种推特时出现竞争条件,因此需要根据服务时间对此推特进行重排序来降低影响。 @@ -267,10 +267,10 @@ $ curl https://twitter.com/api/v1/search?query=hello+world 高容量的写入将淹没单个的 **SQL 写主从**模式,因此需要更多的拓展技术。 -* [联合](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#联合) -* [分片](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#分片) -* [非规范化](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#非规范化) -* [SQL 调优](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-调优) +* [联合](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#联合) +* [分片](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#分片) +* [非规范化](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#非规范化) +* [SQL 调优](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-调优) 我们也可以考虑将一些数据移至 **NoSQL 数据库**。 @@ -280,50 +280,50 @@ $ curl https://twitter.com/api/v1/search?query=hello+world #### NoSQL -* [键-值存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#键-值存储) -* [文档类型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#文档类型存储) -* [列型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#列型存储) -* [图数据库](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#图数据库) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql) +* [键-值存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#键-值存储) +* [文档类型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#文档类型存储) +* [列型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#列型存储) +* [图数据库](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#图数据库) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql) ### 缓存 * 在哪缓存 - * [客户端缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#客户端缓存) - * [CDN 缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#cdn-缓存) - * [Web 服务器缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#web-服务器缓存) - * [数据库缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库缓存) - * [应用缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用缓存) + * [客户端缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#客户端缓存) + * [CDN 缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#cdn-缓存) + * [Web 服务器缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#web-服务器缓存) + * [数据库缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库缓存) + * [应用缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用缓存) * 什么需要缓存 - * [数据库查询级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库查询级别的缓存) - * [对象级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#对象级别的缓存) + * [数据库查询级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库查询级别的缓存) + * [对象级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#对象级别的缓存) * 何时更新缓存 - * [缓存模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存模式) - * [直写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#直写模式) - * [回写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#回写模式) - * [刷新](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#刷新) + * [缓存模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存模式) + * [直写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#直写模式) + * [回写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#回写模式) + * [刷新](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#刷新) ### 异步与微服务 -* [消息队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#消息队列) -* [任务队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#任务队列) -* [背压](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#背压) -* [微服务](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#微服务) +* [消息队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#消息队列) +* [任务队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#任务队列) +* [背压](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#背压) +* [微服务](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#微服务) ### 通信 * 可权衡选择的方案: - * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest) - * 服务器内部通信 - [RPC](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc) -* [服务发现](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#服务发现) + * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest) + * 服务器内部通信 - [RPC](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc) +* [服务发现](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#服务发现) ### 安全性 -请参阅[「安全」](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#安全)一章。 +请参阅[「安全」](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#安全)一章。 ### 延迟数值 -请参阅[「每个程序员都应该知道的延迟数」](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 +请参阅[「每个程序员都应该知道的延迟数」](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 ### 持续探讨 diff --git a/solutions/system_design/twitter/README.md b/solutions/system_design/twitter/README.md index 8a29070d..08ba68bf 100644 --- a/solutions/system_design/twitter/README.md +++ b/solutions/system_design/twitter/README.md @@ -1,6 +1,6 @@ # Design the Twitter timeline and search -*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* +*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* **Design the Facebook feed** and **Design Facebook search** are similar questions. @@ -101,13 +101,13 @@ Handy conversion guide: ### Use case: User posts a tweet -We could store the user's own tweets to populate the user timeline (activity from the user) in a [relational database](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms). We should discuss the [use cases and tradeoffs between choosing SQL or NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql). +We could store the user's own tweets to populate the user timeline (activity from the user) in a [relational database](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms). We should discuss the [use cases and tradeoffs between choosing SQL or NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql). -Delivering tweets and building the home timeline (activity from people the user is following) is trickier. Fanning out tweets to all followers (60 thousand tweets delivered on fanout per second) will overload a traditional [relational database](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms). We'll probably want to choose a data store with fast writes such as a **NoSQL database** or **Memory Cache**. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 +Delivering tweets and building the home timeline (activity from people the user is following) is trickier. Fanning out tweets to all followers (60 thousand tweets delivered on fanout per second) will overload a traditional [relational database](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms). We'll probably want to choose a data store with fast writes such as a **NoSQL database** or **Memory Cache**. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 We could store media such as photos or videos on an **Object Store**. -* The **Client** posts a tweet to the **Web Server**, running as a [reverse proxy](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) +* The **Client** posts a tweet to the **Web Server**, running as a [reverse proxy](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * The **Web Server** forwards the request to the **Write API** server * The **Write API** stores the tweet in the user's timeline on a **SQL database** * The **Write API** contacts the **Fan Out Service**, which does the following: @@ -131,7 +131,7 @@ If our **Memory Cache** is Redis, we could use a native Redis list with the foll The new tweet would be placed in the **Memory Cache**, which populates the user's home timeline (activity from people the user is following). -We'll use a public [**REST API**](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest): +We'll use a public [**REST API**](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest): ``` $ curl -X POST --data '{ "user_id": "123", "auth_token": "ABC123", \ @@ -151,7 +151,7 @@ Response: } ``` -For internal communications, we could use [Remote Procedure Calls](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc). +For internal communications, we could use [Remote Procedure Calls](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc). ### Use case: User views the home timeline @@ -208,7 +208,7 @@ The REST API would be similar to the home timeline, except all tweets would come * Normalizes capitalization * Converts the query to use boolean operations * Queries the **Search Cluster** (ie [Lucene](https://lucene.apache.org/)) for the results: - * [Scatter gathers](https://github.com/donnemartin/system-design-primer#under-development) each server in the cluster to determine if there are any results for the query + * [Scatter gathers](https://github.com/ido777/system-design-primer-update#under-development) each server in the cluster to determine if there are any results for the query * Merges, ranks, sorts, and returns the results REST API: @@ -233,20 +233,20 @@ It's important to discuss what bottlenecks you might encounter with the initial We'll introduce some components to complete the design and to address scalability issues. Internal load balancers are not shown to reduce clutter. -*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: +*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: -* [DNS](https://github.com/donnemartin/system-design-primer#domain-name-system) -* [CDN](https://github.com/donnemartin/system-design-primer#content-delivery-network) -* [Load balancer](https://github.com/donnemartin/system-design-primer#load-balancer) -* [Horizontal scaling](https://github.com/donnemartin/system-design-primer#horizontal-scaling) -* [Web server (reverse proxy)](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) -* [API server (application layer)](https://github.com/donnemartin/system-design-primer#application-layer) -* [Cache](https://github.com/donnemartin/system-design-primer#cache) -* [Relational database management system (RDBMS)](https://github.com/donnemartin/system-design-primer#relational-database-management-system-rdbms) -* [SQL write master-slave failover](https://github.com/donnemartin/system-design-primer#fail-over) -* [Master-slave replication](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [Consistency patterns](https://github.com/donnemartin/system-design-primer#consistency-patterns) -* [Availability patterns](https://github.com/donnemartin/system-design-primer#availability-patterns) +* [DNS](https://github.com/ido777/system-design-primer-update#domain-name-system) +* [CDN](https://github.com/ido777/system-design-primer-update#content-delivery-network) +* [Load balancer](https://github.com/ido777/system-design-primer-update#load-balancer) +* [Horizontal scaling](https://github.com/ido777/system-design-primer-update#horizontal-scaling) +* [Web server (reverse proxy)](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) +* [API server (application layer)](https://github.com/ido777/system-design-primer-update#application-layer) +* [Cache](https://github.com/ido777/system-design-primer-update#cache) +* [Relational database management system (RDBMS)](https://github.com/ido777/system-design-primer-update#relational-database-management-system-rdbms) +* [SQL write master-slave failover](https://github.com/ido777/system-design-primer-update#fail-over) +* [Master-slave replication](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [Consistency patterns](https://github.com/ido777/system-design-primer-update#consistency-patterns) +* [Availability patterns](https://github.com/ido777/system-design-primer-update#availability-patterns) The **Fanout Service** is a potential bottleneck. Twitter users with millions of followers could take several minutes to have their tweets go through the fanout process. This could lead to race conditions with @replies to the tweet, which we could mitigate by re-ordering the tweets at serve time. @@ -269,10 +269,10 @@ Although the **Memory Cache** should reduce the load on the database, it is unli The high volume of writes would overwhelm a single **SQL Write Master-Slave**, also pointing to a need for additional scaling techniques. -* [Federation](https://github.com/donnemartin/system-design-primer#federation) -* [Sharding](https://github.com/donnemartin/system-design-primer#sharding) -* [Denormalization](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL Tuning](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [Federation](https://github.com/ido777/system-design-primer-update#federation) +* [Sharding](https://github.com/ido777/system-design-primer-update#sharding) +* [Denormalization](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL Tuning](https://github.com/ido777/system-design-primer-update#sql-tuning) We should also consider moving some data to a **NoSQL Database**. @@ -282,50 +282,50 @@ We should also consider moving some data to a **NoSQL Database**. #### NoSQL -* [Key-value store](https://github.com/donnemartin/system-design-primer#key-value-store) -* [Document store](https://github.com/donnemartin/system-design-primer#document-store) -* [Wide column store](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [Graph database](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [Key-value store](https://github.com/ido777/system-design-primer-update#key-value-store) +* [Document store](https://github.com/ido777/system-design-primer-update#document-store) +* [Wide column store](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [Graph database](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### Caching * Where to cache - * [Client caching](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN caching](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web server caching](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [Database caching](https://github.com/donnemartin/system-design-primer#database-caching) - * [Application caching](https://github.com/donnemartin/system-design-primer#application-caching) + * [Client caching](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN caching](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web server caching](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [Database caching](https://github.com/ido777/system-design-primer-update#database-caching) + * [Application caching](https://github.com/ido777/system-design-primer-update#application-caching) * What to cache - * [Caching at the database query level](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [Caching at the object level](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [Caching at the database query level](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [Caching at the object level](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * When to update the cache - * [Cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside) - * [Write-through](https://github.com/donnemartin/system-design-primer#write-through) - * [Write-behind (write-back)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [Refresh ahead](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [Cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside) + * [Write-through](https://github.com/ido777/system-design-primer-update#write-through) + * [Write-behind (write-back)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [Refresh ahead](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### Asynchronism and microservices -* [Message queues](https://github.com/donnemartin/system-design-primer#message-queues) -* [Task queues](https://github.com/donnemartin/system-design-primer#task-queues) -* [Back pressure](https://github.com/donnemartin/system-design-primer#back-pressure) -* [Microservices](https://github.com/donnemartin/system-design-primer#microservices) +* [Message queues](https://github.com/ido777/system-design-primer-update#message-queues) +* [Task queues](https://github.com/ido777/system-design-primer-update#task-queues) +* [Back pressure](https://github.com/ido777/system-design-primer-update#back-pressure) +* [Microservices](https://github.com/ido777/system-design-primer-update#microservices) ### Communications * Discuss tradeoffs: - * External communication with clients - [HTTP APIs following REST](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * Internal communications - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [Service discovery](https://github.com/donnemartin/system-design-primer#service-discovery) + * External communication with clients - [HTTP APIs following REST](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * Internal communications - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [Service discovery](https://github.com/ido777/system-design-primer-update#service-discovery) ### Security -Refer to the [security section](https://github.com/donnemartin/system-design-primer#security). +Refer to the [security section](https://github.com/ido777/system-design-primer-update#security). ### Latency numbers -See [Latency numbers every programmer should know](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know). +See [Latency numbers every programmer should know](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know). ### Ongoing diff --git a/solutions/system_design/web_crawler/README-zh-Hans.md b/solutions/system_design/web_crawler/README-zh-Hans.md index 2ad0938e..d2f9e9be 100644 --- a/solutions/system_design/web_crawler/README-zh-Hans.md +++ b/solutions/system_design/web_crawler/README-zh-Hans.md @@ -1,6 +1,6 @@ # 设计一个网页爬虫 -**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)中的有关部分,以避免重复的内容。你可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** +**注意:这个文档中的链接会直接指向[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)中的有关部分,以避免重复的内容。你可以参考链接的相关内容,来了解其总的要点、方案的权衡取舍以及可选的替代方案。** ## 第一步:简述用例与约束条件 @@ -79,7 +79,7 @@ 我们将用表 `crawled_links` (已抓取链接 )来记录已经处理过的链接以及相应的页面签名。 -我们可以将 `links_to_crawl` 和 `crawled_links` 记录在键-值型 **NoSQL 数据库**中。对于 `crawled_links` 中已排序的链接,我们可以使用 [Redis](https://redis.io/) 的有序集合来维护网页链接的排名。我们应当在 [选择 SQL 还是 NoSQL 的问题上,讨论有关使用场景以及利弊 ](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql)。 +我们可以将 `links_to_crawl` 和 `crawled_links` 记录在键-值型 **NoSQL 数据库**中。对于 `crawled_links` 中已排序的链接,我们可以使用 [Redis](https://redis.io/) 的有序集合来维护网页链接的排名。我们应当在 [选择 SQL 还是 NoSQL 的问题上,讨论有关使用场景以及利弊 ](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql)。 * **爬虫服务**按照以下流程循环处理每一个页面链接: * 选取排名最靠前的待抓取链接 @@ -209,7 +209,7 @@ class RemoveDuplicateUrls(MRJob): ### 用例:用户输入搜索词后,可以看到相关的搜索结果列表,列表每一项都包含由网页爬虫生成的页面标题及摘要 -* **客户端**向运行[反向代理](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器)的 **Web 服务器**发送一个请求 +* **客户端**向运行[反向代理](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器)的 **Web 服务器**发送一个请求 * **Web 服务器** 发送请求到 **Query API** 服务器 * **查询 API** 服务将会做这些事情: * 解析查询参数 @@ -222,7 +222,7 @@ class RemoveDuplicateUrls(MRJob): * **倒排索引服务**对匹配到的结果进行排名,然后返回最符合的结果 * 使用**文档服务**返回文章标题与摘要 -我们使用 [**REST API**](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest) 与客户端通信: +我们使用 [**REST API**](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest) 与客户端通信: ``` $ curl https://search.com/api/v1/search?query=hello+world @@ -248,7 +248,7 @@ $ curl https://search.com/api/v1/search?query=hello+world }, ``` -对于服务器内部通信,我们可以使用 [远程过程调用协议(RPC)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc) +对于服务器内部通信,我们可以使用 [远程过程调用协议(RPC)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc) ## 第四步:架构扩展 @@ -265,19 +265,19 @@ $ curl https://search.com/api/v1/search?query=hello+world 我们将会介绍一些组件来完成设计,并解决架构规模扩张问题。内置的负载均衡器将不做讨论以节省篇幅。 -**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及替代方案。 +**为了避免重复讨论**,请参考[系统设计主题索引](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#系统设计主题的索引)相关部分来了解其要点、方案的权衡取舍以及替代方案。 -* [DNS](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#域名系统) -* [负载均衡器](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#负载均衡器) -* [水平扩展](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#水平扩展) -* [Web 服务器(反向代理)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#反向代理web-服务器) -* [API 服务器(应用层)](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用层) -* [缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存) -* [NoSQL](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#nosql) -* [一致性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#一致性模式) -* [可用性模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#可用性模式) +* [DNS](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#域名系统) +* [负载均衡器](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#负载均衡器) +* [水平扩展](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#水平扩展) +* [Web 服务器(反向代理)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#反向代理web-服务器) +* [API 服务器(应用层)](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用层) +* [缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存) +* [NoSQL](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#nosql) +* [一致性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#一致性模式) +* [可用性模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#可用性模式) -有些搜索词非常热门,有些则非常冷门。热门的搜索词可以通过诸如 Redis 或者 Memcached 之类的**内存缓存**来缩短响应时间,避免**倒排索引服务**以及**文档服务**过载。**内存缓存**同样适用于流量分布不均匀以及流量短时高峰问题。从内存中读取 1 MB 连续数据大约需要 250 微秒,而从 SSD 读取同样大小的数据要花费 4 倍的时间,从机械硬盘读取需要花费 80 倍以上的时间。1 +有些搜索词非常热门,有些则非常冷门。热门的搜索词可以通过诸如 Redis 或者 Memcached 之类的**内存缓存**来缩短响应时间,避免**倒排索引服务**以及**文档服务**过载。**内存缓存**同样适用于流量分布不均匀以及流量短时高峰问题。从内存中读取 1 MB 连续数据大约需要 250 微秒,而从 SSD 读取同样大小的数据要花费 4 倍的时间,从机械硬盘读取需要花费 80 倍以上的时间。1 以下是优化**爬虫服务**的其他建议: @@ -285,7 +285,7 @@ $ curl https://search.com/api/v1/search?query=hello+world * 为了处理数据大小问题以及网络请求负载,**倒排索引服务**和**文档服务**可能需要大量应用数据分片和数据复制。 * DNS 查询可能会成为瓶颈,**爬虫服务**最好专门维护一套定期更新的 DNS 查询服务。 * 借助于[连接池](https://en.wikipedia.org/wiki/Connection_pool),即同时维持多个开放网络连接,可以提升**爬虫服务**的性能并减少内存使用量。 - * 改用 [UDP](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#用户数据报协议udp) 协议同样可以提升性能 + * 改用 [UDP](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#用户数据报协议udp) 协议同样可以提升性能 * 网络爬虫受带宽影响较大,请确保带宽足够维持高吞吐量。 ## 其它要点 @@ -294,61 +294,61 @@ $ curl https://search.com/api/v1/search?query=hello+world ### SQL 扩展模式 -* [读取复制](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#主从复制) -* [联合](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#联合) -* [分片](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#分片) -* [非规范化](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#非规范化) -* [SQL 调优](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-调优) +* [读取复制](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#主从复制) +* [联合](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#联合) +* [分片](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#分片) +* [非规范化](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#非规范化) +* [SQL 调优](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-调优) #### NoSQL -* [键-值存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#键-值存储) -* [文档类型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#文档类型存储) -* [列型存储](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#列型存储) -* [图数据库](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#图数据库) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#sql-还是-nosql) +* [键-值存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#键-值存储) +* [文档类型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#文档类型存储) +* [列型存储](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#列型存储) +* [图数据库](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#图数据库) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#sql-还是-nosql) ### 缓存 * 在哪缓存 - * [客户端缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#客户端缓存) - * [CDN 缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#cdn-缓存) - * [Web 服务器缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#web-服务器缓存) - * [数据库缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库缓存) - * [应用缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#应用缓存) + * [客户端缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#客户端缓存) + * [CDN 缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#cdn-缓存) + * [Web 服务器缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#web-服务器缓存) + * [数据库缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库缓存) + * [应用缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#应用缓存) * 什么需要缓存 - * [数据库查询级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#数据库查询级别的缓存) - * [对象级别的缓存](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#对象级别的缓存) + * [数据库查询级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#数据库查询级别的缓存) + * [对象级别的缓存](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#对象级别的缓存) * 何时更新缓存 - * [缓存模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#缓存模式) - * [直写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#直写模式) - * [回写模式](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#回写模式) - * [刷新](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#刷新) + * [缓存模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#缓存模式) + * [直写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#直写模式) + * [回写模式](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#回写模式) + * [刷新](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#刷新) ### 异步与微服务 -* [消息队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#消息队列) -* [任务队列](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#任务队列) -* [背压](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#背压) -* [微服务](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#微服务) +* [消息队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#消息队列) +* [任务队列](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#任务队列) +* [背压](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#背压) +* [微服务](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#微服务) ### 通信 * 可权衡选择的方案: - * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#表述性状态转移rest) - * 内部通信 - [RPC](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#远程过程调用协议rpc) -* [服务发现](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#服务发现) + * 与客户端的外部通信 - [使用 REST 作为 HTTP API](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#表述性状态转移rest) + * 内部通信 - [RPC](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#远程过程调用协议rpc) +* [服务发现](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#服务发现) ### 安全性 -请参阅[安全](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#安全)。 +请参阅[安全](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#安全)。 ### 延迟数值 -请参阅[每个程序员都应该知道的延迟数](https://github.com/donnemartin/system-design-primer/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 +请参阅[每个程序员都应该知道的延迟数](https://github.com/ido777/system-design-primer-update/blob/master/README-zh-Hans.md#每个程序员都应该知道的延迟数)。 ### 持续探讨 diff --git a/solutions/system_design/web_crawler/README.md b/solutions/system_design/web_crawler/README.md index 7ee09be0..c8200dc1 100644 --- a/solutions/system_design/web_crawler/README.md +++ b/solutions/system_design/web_crawler/README.md @@ -1,6 +1,6 @@ # Design a web crawler -*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* +*Note: This document links directly to relevant areas found in the [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) to avoid duplication. Refer to the linked content for general talking points, tradeoffs, and alternatives.* ## Step 1: Outline use cases and constraints @@ -81,7 +81,7 @@ We'll assume we have an initial list of `links_to_crawl` ranked initially based We'll use a table `crawled_links` to store processed links and their page signatures. -We could store `links_to_crawl` and `crawled_links` in a key-value **NoSQL Database**. For the ranked links in `links_to_crawl`, we could use [Redis](https://redis.io/) with sorted sets to maintain a ranking of page links. We should discuss the [use cases and tradeoffs between choosing SQL or NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql). +We could store `links_to_crawl` and `crawled_links` in a key-value **NoSQL Database**. For the ranked links in `links_to_crawl`, we could use [Redis](https://redis.io/) with sorted sets to maintain a ranking of page links. We should discuss the [use cases and tradeoffs between choosing SQL or NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql). * The **Crawler Service** processes each page link by doing the following in a loop: * Takes the top ranked page link to crawl @@ -211,7 +211,7 @@ We might also choose to support a `Robots.txt` file that gives webmasters contro ### Use case: User inputs a search term and sees a list of relevant pages with titles and snippets -* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) +* The **Client** sends a request to the **Web Server**, running as a [reverse proxy](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) * The **Web Server** forwards the request to the **Query API** server * The **Query API** server does the following: * Parses the query @@ -224,7 +224,7 @@ We might also choose to support a `Robots.txt` file that gives webmasters contro * The **Reverse Index Service** ranks the matching results and returns the top ones * Uses the **Document Service** to return titles and snippets -We'll use a public [**REST API**](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest): +We'll use a public [**REST API**](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest): ``` $ curl https://search.com/api/v1/search?query=hello+world @@ -250,7 +250,7 @@ Response: }, ``` -For internal communications, we could use [Remote Procedure Calls](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc). +For internal communications, we could use [Remote Procedure Calls](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc). ## Step 4: Scale the design @@ -266,26 +266,26 @@ It's important to discuss what bottlenecks you might encounter with the initial We'll introduce some components to complete the design and to address scalability issues. Internal load balancers are not shown to reduce clutter. -*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/donnemartin/system-design-primer#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: +*To avoid repeating discussions*, refer to the following [system design topics](https://github.com/ido777/system-design-primer-update#index-of-system-design-topics) for main talking points, tradeoffs, and alternatives: -* [DNS](https://github.com/donnemartin/system-design-primer#domain-name-system) -* [Load balancer](https://github.com/donnemartin/system-design-primer#load-balancer) -* [Horizontal scaling](https://github.com/donnemartin/system-design-primer#horizontal-scaling) -* [Web server (reverse proxy)](https://github.com/donnemartin/system-design-primer#reverse-proxy-web-server) -* [API server (application layer)](https://github.com/donnemartin/system-design-primer#application-layer) -* [Cache](https://github.com/donnemartin/system-design-primer#cache) -* [NoSQL](https://github.com/donnemartin/system-design-primer#nosql) -* [Consistency patterns](https://github.com/donnemartin/system-design-primer#consistency-patterns) -* [Availability patterns](https://github.com/donnemartin/system-design-primer#availability-patterns) +* [DNS](https://github.com/ido777/system-design-primer-update#domain-name-system) +* [Load balancer](https://github.com/ido777/system-design-primer-update#load-balancer) +* [Horizontal scaling](https://github.com/ido777/system-design-primer-update#horizontal-scaling) +* [Web server (reverse proxy)](https://github.com/ido777/system-design-primer-update#reverse-proxy-web-server) +* [API server (application layer)](https://github.com/ido777/system-design-primer-update#application-layer) +* [Cache](https://github.com/ido777/system-design-primer-update#cache) +* [NoSQL](https://github.com/ido777/system-design-primer-update#nosql) +* [Consistency patterns](https://github.com/ido777/system-design-primer-update#consistency-patterns) +* [Availability patterns](https://github.com/ido777/system-design-primer-update#availability-patterns) -Some searches are very popular, while others are only executed once. Popular queries can be served from a **Memory Cache** such as Redis or Memcached to reduce response times and to avoid overloading the **Reverse Index Service** and **Document Service**. The **Memory Cache** is also useful for handling the unevenly distributed traffic and traffic spikes. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 +Some searches are very popular, while others are only executed once. Popular queries can be served from a **Memory Cache** such as Redis or Memcached to reduce response times and to avoid overloading the **Reverse Index Service** and **Document Service**. The **Memory Cache** is also useful for handling the unevenly distributed traffic and traffic spikes. Reading 1 MB sequentially from memory takes about 250 microseconds, while reading from SSD takes 4x and from disk takes 80x longer.1 Below are a few other optimizations to the **Crawling Service**: * To handle the data size and request load, the **Reverse Index Service** and **Document Service** will likely need to make heavy use sharding and federation. * DNS lookup can be a bottleneck, the **Crawler Service** can keep its own DNS lookup that is refreshed periodically * The **Crawler Service** can improve performance and reduce memory usage by keeping many open connections at a time, referred to as [connection pooling](https://en.wikipedia.org/wiki/Connection_pool) - * Switching to [UDP](https://github.com/donnemartin/system-design-primer#user-datagram-protocol-udp) could also boost performance + * Switching to [UDP](https://github.com/ido777/system-design-primer-update#user-datagram-protocol-udp) could also boost performance * Web crawling is bandwidth intensive, ensure there is enough bandwidth to sustain high throughput ## Additional talking points @@ -294,58 +294,58 @@ Below are a few other optimizations to the **Crawling Service**: ### SQL scaling patterns -* [Read replicas](https://github.com/donnemartin/system-design-primer#master-slave-replication) -* [Federation](https://github.com/donnemartin/system-design-primer#federation) -* [Sharding](https://github.com/donnemartin/system-design-primer#sharding) -* [Denormalization](https://github.com/donnemartin/system-design-primer#denormalization) -* [SQL Tuning](https://github.com/donnemartin/system-design-primer#sql-tuning) +* [Read replicas](https://github.com/ido777/system-design-primer-update#master-slave-replication) +* [Federation](https://github.com/ido777/system-design-primer-update#federation) +* [Sharding](https://github.com/ido777/system-design-primer-update#sharding) +* [Denormalization](https://github.com/ido777/system-design-primer-update#denormalization) +* [SQL Tuning](https://github.com/ido777/system-design-primer-update#sql-tuning) #### NoSQL -* [Key-value store](https://github.com/donnemartin/system-design-primer#key-value-store) -* [Document store](https://github.com/donnemartin/system-design-primer#document-store) -* [Wide column store](https://github.com/donnemartin/system-design-primer#wide-column-store) -* [Graph database](https://github.com/donnemartin/system-design-primer#graph-database) -* [SQL vs NoSQL](https://github.com/donnemartin/system-design-primer#sql-or-nosql) +* [Key-value store](https://github.com/ido777/system-design-primer-update#key-value-store) +* [Document store](https://github.com/ido777/system-design-primer-update#document-store) +* [Wide column store](https://github.com/ido777/system-design-primer-update#wide-column-store) +* [Graph database](https://github.com/ido777/system-design-primer-update#graph-database) +* [SQL vs NoSQL](https://github.com/ido777/system-design-primer-update#sql-or-nosql) ### Caching * Where to cache - * [Client caching](https://github.com/donnemartin/system-design-primer#client-caching) - * [CDN caching](https://github.com/donnemartin/system-design-primer#cdn-caching) - * [Web server caching](https://github.com/donnemartin/system-design-primer#web-server-caching) - * [Database caching](https://github.com/donnemartin/system-design-primer#database-caching) - * [Application caching](https://github.com/donnemartin/system-design-primer#application-caching) + * [Client caching](https://github.com/ido777/system-design-primer-update#client-caching) + * [CDN caching](https://github.com/ido777/system-design-primer-update#cdn-caching) + * [Web server caching](https://github.com/ido777/system-design-primer-update#web-server-caching) + * [Database caching](https://github.com/ido777/system-design-primer-update#database-caching) + * [Application caching](https://github.com/ido777/system-design-primer-update#application-caching) * What to cache - * [Caching at the database query level](https://github.com/donnemartin/system-design-primer#caching-at-the-database-query-level) - * [Caching at the object level](https://github.com/donnemartin/system-design-primer#caching-at-the-object-level) + * [Caching at the database query level](https://github.com/ido777/system-design-primer-update#caching-at-the-database-query-level) + * [Caching at the object level](https://github.com/ido777/system-design-primer-update#caching-at-the-object-level) * When to update the cache - * [Cache-aside](https://github.com/donnemartin/system-design-primer#cache-aside) - * [Write-through](https://github.com/donnemartin/system-design-primer#write-through) - * [Write-behind (write-back)](https://github.com/donnemartin/system-design-primer#write-behind-write-back) - * [Refresh ahead](https://github.com/donnemartin/system-design-primer#refresh-ahead) + * [Cache-aside](https://github.com/ido777/system-design-primer-update#cache-aside) + * [Write-through](https://github.com/ido777/system-design-primer-update#write-through) + * [Write-behind (write-back)](https://github.com/ido777/system-design-primer-update#write-behind-write-back) + * [Refresh ahead](https://github.com/ido777/system-design-primer-update#refresh-ahead) ### Asynchronism and microservices -* [Message queues](https://github.com/donnemartin/system-design-primer#message-queues) -* [Task queues](https://github.com/donnemartin/system-design-primer#task-queues) -* [Back pressure](https://github.com/donnemartin/system-design-primer#back-pressure) -* [Microservices](https://github.com/donnemartin/system-design-primer#microservices) +* [Message queues](https://github.com/ido777/system-design-primer-update#message-queues) +* [Task queues](https://github.com/ido777/system-design-primer-update#task-queues) +* [Back pressure](https://github.com/ido777/system-design-primer-update#back-pressure) +* [Microservices](https://github.com/ido777/system-design-primer-update#microservices) ### Communications * Discuss tradeoffs: - * External communication with clients - [HTTP APIs following REST](https://github.com/donnemartin/system-design-primer#representational-state-transfer-rest) - * Internal communications - [RPC](https://github.com/donnemartin/system-design-primer#remote-procedure-call-rpc) -* [Service discovery](https://github.com/donnemartin/system-design-primer#service-discovery) + * External communication with clients - [HTTP APIs following REST](https://github.com/ido777/system-design-primer-update#representational-state-transfer-rest) + * Internal communications - [RPC](https://github.com/ido777/system-design-primer-update#remote-procedure-call-rpc) +* [Service discovery](https://github.com/ido777/system-design-primer-update#service-discovery) ### Security -Refer to the [security section](https://github.com/donnemartin/system-design-primer#security). +Refer to the [security section](https://github.com/ido777/system-design-primer-update#security). ### Latency numbers -See [Latency numbers every programmer should know](https://github.com/donnemartin/system-design-primer#latency-numbers-every-programmer-should-know). +See [Latency numbers every programmer should know](https://github.com/ido777/system-design-primer-update#latency-numbers-every-programmer-should-know). ### Ongoing