模块五作业
基于模块 5 第 6 课的微博实战案例,分析“微博评论”这个核心场景的业务特性,然后设计其高性能高可用计算架构,包括但不限于如下内容:
1. 计算性能预估(不需要考虑存储性能);
2. 非热点事件时的高性能计算架构,需要考虑是否要拆分独立的服务;
3. 热点事件时的高可用计算架构。
Functional Requirement
Add comment to Weibo post
Capacity Estimation
In Sep 2020, Sina Weibo hosts roughly 511M monthly active users, or 224M daily active users.
Supposed each user publishes 1 post every day, and each post has 20 comments on average. Then the total number of comment posting requests per day is:
QPS for write requests:
Peak QPS for write requests:
Supposed for each post, every user reads 10 comments on average. Then:
QPS for read requests: 26K
Peak QPS for read requests: 26K * 3 = 78K
Cache Design
Read comment:
Since comment is not static resource, CDN is not applicable for caching comment.
Load Balancer Design
High Availability Design
Read Comment
When a post becomes hot, above caching design still works. Further more, the comments of the post can be distributed and cached in multiple comment servers. Due to the significant number of comments, there is no need to show same comments to users. Showing random comments is an good option. With that in mind, each server can simply return the comments in its own cache for an incoming read request. There is no need to combine comments cached in different servers or DB.
Write Comment
When user sends a write request to add new comment, the request is stored in message queue. Each comment server picks the task from the message queue asynchronously.
评论