Summary-the realization of several load balancing technologies

[Preface]
Load balancing technology has great advantages in improving the performance of medium and large websites. Recently, I am studying "Architecture of Large-scale Website Technology". There are some introductions to load balancing technology. I will summarize the learning experience and share it. Communicate more.

[Protocol layer] http redirection protocol realizes the
principle of load balancing : calculate a real web server address according to the user's http request, and write the web server address into the http redirect response and return it to the browser, and the browser will retry access.

As shown in the figure:

Insert picture description here

优点:比较简单

缺点:浏览器需要两次请求服务器才能完成一次访问,性能较差。

        http重定向服务器自身的处理能力可能成为瓶颈。

        使用http302响应重定向,有可能使搜索引擎判断为SEO作弊,降低搜索排名。

[Protocol layer] DNS domain name resolution load balancing
Principle: Configure multiple domain name corresponding IP records on the DNS server. For example, a domain name www.baidu.com corresponds to a set of web server IP addresses, and a domain name request is allocated to a suitable real server through the algorithm of the DNS server during domain name resolution.

As shown in the figure:

Insert picture description here

   优点:将负载均衡的工作交给了DNS,省却了网站管理维护负载均衡服务器的麻烦,
   同时许多DNS还支持基于地理位置的域名解析,将域名解析成距离用户地理最近的一个服务器地址,加快访问速度,改善性能。

   缺点:目前的DNS解析是多级解析,每一级DNS都可能化缓存记录A,当某一服务器下线后,
   该服务器对应的DNS记录A可能仍然存在,导致分配到该服务器的用户访问失败。

    DNS负载均衡的控制权在域名服务商手里,网站可能无法做出过多的改善和管理。

    不能够按服务器的处理能力来分配负载。DNS负载均衡采用的是简单的轮询算法,
    不能区分服务器之间的差异,不能反映服务器当前运行状态,所以其负载均衡效果并不是太好。

    可能会造成额外的网络问题。为了使本DNS服务器和其他DNS服务器及时交互,保证DNS数据及时更新,
    使地址能随机分配,一般都要将DNS的刷新时间设置的较小,但太小将会使DNS流量大增造成额外的网络问题。

[Protocol layer]
Principle of reverse proxy load balancing : The reverse proxy is on the side of the web server. The reverse proxy server provides the function of load balancing and manages a group of web servers at the same time. It forwards the requested browser access to the web server according to the load balancing algorithm. Different web servers process, and the processing results are returned to the browser through the reverse server.

As shown in the figure:

Insert picture description here

For example: the address requested by the browser is the address of the reverse proxy server 114.100.80.10, the reverse proxy server receives the request, after the load balancing algorithm, a real physical address 10.0.03 is obtained, and the request result is sent to the real no service , The real server returns to the requesting user through the reverse proxy server after processing.

  优点:部署简单,处于http协议层面。

  缺点:使用了反向代理服务器后,web 服务器地址不能直接暴露在外,因此web服务器不需要使用外部IP地址,
  而反向代理服务作为沟通桥梁就需要配置双网卡、外部内部两套IP地址。

[Network layer] IP load balancing
Principle: Load balancing is performed at the network layer by modifying the target address.

As shown in the figure:

Insert picture description here

The user access request arrives at the load balancing server. The load balancing server obtains network data packets in the kernel process of the operating system, obtains a real server address according to the algorithm, and then modifies the target address of the user request to the real server address. After the data is processed, it is returned to Load balancing server: After receiving the response, the load balancing server modifies its address to the original user's access address before returning the data. Similar to reverse server load balancing.

   优点:在响应请求时速度较反向服务器负载均衡要快。

   缺点:当请求数据较大(大型视频或文件)时,速度较慢。

[Link layer] Load balancing
at the data link layer Principle: Modify the Mac address at the data link layer for load balancing.

As shown in the figure:

Insert picture description here
The IP of the load balancing server is consistent with the virtual IP of the web service group it manages;
the IP address of the access address is not modified during the load balancing data distribution process, but the Mac address is modified;
through these two points, the original address of the data packet is not modified And the target address can be accessed normally.

   优点:不需要负载均衡服务器进行地址的转换。

    数据响应时不需要经过负载均衡服务器。

   缺点:负载均衡服务器的网卡带宽要求较高。

At present, link load balancing is a particularly common method, and a typical product is LVS (Linux Virtual Server).

Guess you like

Origin blog.csdn.net/qq_26249609/article/details/102456458