Talking about server cluster, load balancing, and distributed

1. Load balancing

1. Load balancing concept:

It means that it is allocated to multiple operating units for execution. The operating units can be web servers, ftp servers, key enterprise application servers, etc. It cannot be understood as being evenly distributed to each operating unit, because the carrying capacity of each server is not enough. The same, hardware configuration, network bandwidth and other differences, so it can not be evenly distributed, there are many factors that need to be referred to.

2. Load balancing implementation

①http redirection

When an HTTP proxy (such as a browser) requests a URL from the web server, the web server can return a new URL through the Location tag in the HTTP response header. This means that the HTTP proxy needs to continue to request this new URL, complete Jump automatically.

Performance flaws:

1) Throughput limit (mainly the limit of the main site server)

2) Redirection access depth is different

We need to weigh the overhead of transferring the request against the overhead of processing the actual request. The smaller the former is relative to the latter, the more meaningful the redirection is, such as downloading.

You can go to many mirror download sites to try, and you will find that the basic downloads are redirected using Location.

②DNS load balancing

DNS is responsible for providing domain name resolution services. When visiting a site, in fact, it is first necessary to obtain the IP address pointed to by the domain name through the DNS server of the domain name of the site. In this process, the DNS server completes the mapping from the domain name to the IP address. Similarly, this mapping can also be one-to-many. At this time, the DNS server acts as a load balancing scheduler. It distributes user requests to multiple servers just like the http redirection conversion strategy, but its implementation The mechanism is completely different.

characteristic:

1) It can be intelligently resolved according to the user's IP. The DNS server can find the closest server to the user in all the available A records.

2) Dynamic DNS: Every time the IP address changes, the DNS server is updated in time. Of course, due to the cache, a certain delay is inevitable.

③Reverse proxy load balancing

Almost all mainstream web servers are keen to support load balancing based on reverse proxy. Its core job is to forward HTTP requests. Compared with the previous HTTP redirection and DNS resolution, the scheduler of reverse proxy plays the role of user and actual The role of the server middleman:

1) Any HTTP request to the actual server must go through the scheduler

2) The scheduler must wait for the HTTP response from the actual server and feed it back to the user (the first two methods do not require scheduling feedback, the actual server sends it directly to the user)

characteristic:

1) Rich scheduling strategies. For example, different weights can be set for different actual servers to achieve the effect of more work for those who are capable.

2) The concurrent processing capability of the reverse proxy server is high, because it works at the HTTP level.

3) The forwarding operation of the reverse proxy server itself requires a certain overhead, such as creating threads, establishing a TCP connection with the back-end server, receiving the processing results returned by the back-end server, analyzing HTTP header information, frequent user space and kernel space Switching, etc., although this part of the time is not long, but when the time for the backend server to process the request is very short, the forwarding overhead becomes particularly prominent. For example, when requesting static files, it is more suitable to use the DNS-based load balancing method described above.

4) The reverse proxy server can monitor the back-end servers, such as system load, response time, availability, the number of TCP connections, traffic, etc., so as to adjust the load balancing strategy according to these data.

5) The reverse proxy server can allow users to always forward all requests in a session cycle to a specific backend server (sticky session), which has the advantage of maintaining local access to the session and preventing the backend The server's dynamic memory cache is a waste of resources.

④IP load balancing (LVS-NAT)

Because the reverse proxy server works at the HTTP layer, its own overhead has severely restricted scalability, thus limiting its performance limit. Whether it can achieve load balancing below the HTTP layer. NAT server: It works at the transport layer, it can modify the sent IP data packets, and change the destination address of the data packets to the actual server address.

⑤Direct routing (LVS-DR)

NAT works at the transport layer (the fourth layer) of the network layering model, while direct routing works at the data link layer (the second layer), which seems to be more dick. It forwards the packet to the actual server by modifying the destination MAC address of the packet (without modifying the destination IP). The difference is that the actual server's response packet will be sent directly to the client without going through the scheduler.

⑥IP tunnel (LVS-TUN)

Request forwarding mechanism based on IP tunnel: The IP packet received by the scheduler is encapsulated in a new IP packet and forwarded to the actual server, and then the response packet from the actual server can reach the client directly. At present, Linux mostly supports it and can be implemented with LVS, which is called LVS-TUN. Unlike LVS-DR, the actual server and the scheduler can not be in the same WANt network segment. The scheduler forwards requests to the actual server through IP tunneling technology. , so the actual server must also have a valid IP address.

There are two types of load balancing: hardware and software:
the hardware layer is relatively powerful, and the 4-7 layer load balancing function is implemented in one hardware, such as F5 and Barracuda.

At present, the mainstream software load balancing is divided into four layers and seven layers. LVS belongs to four layers of load balancing. It works on the tcp/ip protocol stack and forwards by modifying the ip address and port of the network packet. It is placed at the front end of the architecture. The seven-layer load balancing includes nginx, haproxy, apache, etc., which work at the application layer, so application data such as HTTP requests can be sent to specific application servers, such as forwarding image requests to specific servers. In short, more intelligent load balancing can be achieved. These functions are not easy to achieve in the four-layer load balancing. They are generally placed at the back of the architecture and in front of the application server.

Second, the server cluster

A server cluster means that many servers are concentrated together to perform the same service, and it looks like there is only one server to the client. A cluster can use multiple computers for parallel computing to achieve high computing speed, or multiple computers can be used for parallel computing. Make backups, so that if any one machine is broken, the entire system can still run normally.

3. Distributed

It is a computer system that connects multiple computers in different locations, or with different functions, or with different data through a communication network, under the unified management and control of the control system, to coordinately complete large-scale information processing tasks.

Fourth, the difference between cluster and distributed

Distributed: A complex business is split into multiple sub-businesses and deployed on different servers.
Cluster: The same business is deployed on multiple servers.
Cluster is a physical form, and distributed is a way of working.
Clusters are generally physically centralized and managed in a unified manner , while distributed systems do not emphasize this.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325939000&siteId=291194637