最近非常頻繁的接觸到Load Balancer這個概念。 最開始是從AWS上面的Elastic Load balancer開始,然后是各種視頻里都說面試題中 要考慮的load balancer 優(yōu)化的情況。所以打算深度了解一下。
Quora Link: https://www.quora.com/What-is-a-load-balancer
我總結(jié)了一下, Load Balancer主要是用在互聯(lián)網(wǎng),分配任務(wù)給服務(wù)器的。如果是個人開發(fā),小網(wǎng)站,不需要Load Balancer,因為你的訪問量估計不是很多。當(dāng)訪問量很多的時候,如果你全部用一個服務(wù)器來處理他們的請求,服務(wù)器會很慢很慢。所以,首先得有很多服務(wù)器, 然后Load Balancer根據(jù)哪個服務(wù)器比較沒那么累給他分配任務(wù)。
在面試的時候,如果有什么system design, 設(shè)計一個Twitter之類的, 如果你說到Load Balancer,這會是一個很加分的地方。?
例子: 做一個Twitter。
假設(shè)Twitter 有一個發(fā)Tweet的功能, 有一個點贊的功能, 有一個。。。的功能。 好,設(shè)計完畢。
然后,面試官,如果訪問量很大的時候,我們用一個server估計搞不過來,需要使用load balancer。

"
A load balancer is any method used for splitting the amount of requests to site among many machines (real or virtual) the most common methods are:
1. Round robin DNS
2. Round robin routing
3. Uee a proxy to divide it up
Of all the above the simplest and most effective is round robin DNS
"
“Requests are received by both types of load balancers and they are distributed to a particular server based on a configured algorithm. Some industry standard algorithms are:
Round robin
Weighted round robin
Least connections
Least response time
“
操作系統(tǒng)里面的Round robin 本來在我理解是用來切換不同任務(wù)的,原來也可以用在load balancer上。

AWS的云端Load Balancer: Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances. It enables you to achieve fault tolerance in your applications, seamlessly providing the required amount of load balancing capacity needed to route application traffic
因為很多中小公司會把網(wǎng)站放在Amazon上面來deploy,所以server也是amazon的。 可以通過Elastic Load Balancer來把流量分到幾個instance上。