recruiter小姐姐把面试范围画了个重点,于是我来抱个佛脚。学习一下load balancer把流量分给各个server的原理和方法。
efficiently distributing incoming network traffic across a group of backend servers,把流量高效地分配给后端server。
基本职能:
保证没有server overworked万一某个server down,分给其他的一个新的server添加进来,开始向他分流量两种类型的load balancers都接收requests, 并根据一个算法来决定该request分到哪个server上。 工业界常见的算法:
Round robin: 顺序轮询Weighted round robinLeast connections:选有最少连接的那个serverLeast response time:选响应时间最短的那个Hash:根据hash value of client IP address或request URL决定 (a consistent hash to minimize redistribution of loads if the set of upstream servers changes)IP Hash: 根据hash value of client IP address决定哪个serverRandom with Two Choices:先随机选两个,再用其他算法二选一https://www.f5.com/services/resources/glossary/load-balancer https://www.nginx.com/resources/glossary/load-balancing/