Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of load balancing between server and client

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you the relevant knowledge about the method of load balancing between server and client. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article, let's take a look at it.

Load balancing concept

It refers to the horizontal increase of system throughput and performance through server cluster when the performance of a single server reaches its limit. When it comes to load balancing, we think of Ngnix. Discord denies that Ngnix is one of the best ways to achieve load balancing. But during the interview, the interviewer often wants to be able to get out of the whole workshop through a screw. If you just reply to Ngnix, it may not be too late to pass the interview.

Server load balancing

Server load balancer is what we usually call load balancer, which refers to the distribution of services upstream of the server. There are several common ways:

1. DNS domain name resolution load balancer. Assume that our domain name points to multiple IP addresses. When a domain name request comes, the DNS server performs domain name resolution to convert the domain name into IP address, and achieves load balancing in the mapping transformation of 1DNS N. The DNS server provides a simple load balancing algorithm, but when one of the servers fails, notify the DNS server to remove the current failed IP. 2. Reverse proxy load balancer; reverse proxy only values the proxy to the server, and the proxy server accepts the request and forwards the request to the back-end server through the load balancing algorithm. The back-end service returns to the proxy server and then the proxy server returns to the client. The advantage of reverse proxy server is that it isolates back-end server and client, and uses dual network cards to shield the real server network. Compared with DNS domain name to solve load balancing, reverse proxy is more flexible in fault handling and supports horizontal expansion of load balancing algorithm. At present, it is widely used. Of course, reverse proxy also needs to consider many problems, such as single point of failure, cluster deployment and so on. 3. IP load balancing; we all know that the reverse proxy works in the HTTP layer, which has a relatively high overhead and has a certain impact on performance. LVS-NAT is a load balancing in the bathroom transport layer, which achieves load balancing by modifying the destination address of the accepted packet. Later versions of Linux2.6.x have built-in IPVS, which is focused on implementing IP load balancer, so IP load balancer is widely used on Linux. LVS-DR works at the data link layer, and when it is more domineering than LVS-NAT, it directly modifies the MAC address of packets. Based on the request forwarding mechanism of IP tunnel, LVS-TUN-- encapsulates the IP data packets received by the scheduler and transfers them to the server, and then the server returns the data to achieve load balancing through the scheduler. This approach supports cross-segment scheduling. To sum up, both LVS-DR and LVS-TUN are suitable for Web servers with asymmetric responses and requests, and how to choose from them depends on your network deployment needs, because LVS-TUN can be cross-regional, and if you have similar requirements, you should choose LVS-TUN. Client load balancing

Compared with server load balancing, client load balancing is a very niche concept, but the interview will deliberately understand the breadth of the candidate's knowledge when asked about load balancing. Client-side load balancing is defined in the spring-cloud distributed framework component Ribbon. When we use the spring-cloud distributed framework, there is a high probability that more than one service will be started at the same time. When a request arrives, the way that these multiple service,Ribbon decide which service to use for this request through policy is the client-side load balancer. In the spring-cloud distributed framework, client-side load balancing is transparent to developers, just add the @ LoadBalanced annotation. The core difference between client load balancing and server load balancing lies in the service list itself. The client load balancing service list is maintained by the client, and the server load balancing service list is maintained separately by intermediate services. Through the understanding of the above knowledge, you can have a more comprehensive understanding of load balancing. Let me briefly talk to the interviewer about common load balancing algorithms:

Randomly, the service is randomly selected for execution, which is generally less used; rotation training is implemented by default, and the request is queued for processing; weighted rotation training, through the classification of server performance, allocates higher weights to servers with high configuration and low load to balance the pressure on each server; address Hash, server scheduling is carried out through the modular mapping of the Hash value of the address requested by the client. Minimum number of links; even if the request is balanced, the pressure may not be balanced. The minimum number of connections method allocates the request to the server with the least pressure according to the server's situation, such as the backlog of requests and other parameters. There are several other ways. These are all the contents of this article entitled "load balancing between Server and client". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report