Notes for Harvard CS75 Web Development Lecture 9 Scalability(解答系统设计中的scale的问题)

本文涉及的概念众多:
scaling(horizontal scaling, vertical scaling, load balancer, cookies, sessions, caching, replication: master-slave, master-master. partitioning, high availability…)

当我们运算能力或者读写能力不够的时候 我们需要购买更多的主机。这个时候需要scale:
那么怎么样scale呢?
vertical scaling: 使用更多的RAM,处理器,硬盘空间
horizontal scaling: 增加辑器的数量,用更多的服务器去构建

load balancer: 我们要让每台服务器进可能均匀使用,而同时又需要让用户得到尽可能块的相应,因此我们要用这种负载均衡器来分配传入的HTTP请求。
其实这种负载均衡器并不是一个固定的东西 而是一种概念,我们有多种可以实现它的方式:Round robin(轮询)/基于每个server的负载进行选择/用一个server来管理服务器的分配

缓存:caching
这是一种可以被用于很多东西上面的技术 .
.html vs. MySQL database/XML (avoid regenerating) more performance vs. more space. But requires a lot of work when want to update/redesign the page
MySQL query cache: query_cache_type: 1
memchached: store whatever you want in RAM (garbage collection: expire objects based on when they are put in)

Replication:
Master-Slave
Master: the main database that you write/read data to/from.
Slave: anytime a query is executed on the
master that same query is copied down to one or more slaves and they do the exact same thing
Advantages:
If the master is down, promote one of the slaves and do some configuration. (redundacy)
If there are a lot queries, you could just load balance across database servers
For read heavy websites, any select can go to all four databases, while any insert/update/delete has to go to server master
Mastter-Master
you could write to either server one or two and if you happen to write to server1 that query gets replicated on server2 and vice versa so now you could keep it simple

posted @ 2020-12-25 22:15  EvanMeetTheWorld  阅读(44)  评论(0)    收藏  举报