System Design for Blog Website
Problem statement
Context
- Imagine you have to design a system for serving blogs to massive readers (10k tps).
- How would you design the system?
Requirements
- Propose your design
- Write your very first blog about it
Solutions
Version 1.0
In this version, I mainly focus on how to release a system that is simple and can work well in a small scope.
Minimum viable product |
Explain
Web server
: work as a reverse proxy- After
Client
sends a request toWeb server
, it forwards this request toAPI
. - Then,
API
query inDatabase
to return data to read or write the blogs.
Version 2.0
Later, I realize that the need for reading is more than the need for writing. Therefore, if every request points to the database, it will slow down query performance.
Version 2.0 |
Explain
In this design, I split API into 2 roles:
Read API
is for reading requestsWrite API
is for writing requests
To optimize database, I also divide into 2 roles like API
. In this diagram, Write Database
is master and Read Database
is slave.
Version 3.0
In version 2.0
, this design can cause bottlenecks in Web Server
, so I try to upgrade to a new version.
Version 3.0 |
Explain
Load Balancer
: divide tasks for resources and process more efficiently.Memory Cache
: This is a fast memory, so I will put data of active users here to perform better.
Version 4.0
I will release it if I have enough pieces of knowledge :whale:
Referals
https://en.wikipedia.org/wiki/Load_balancing_(computing)