In the face of massive user access, high concurrent requests, large amounts of data, high-performance servers, large databases, storage devices, high-performance Web servers, and high-efficiency programming languages such as (Go,scala), we need to consider business splitting and distributed deployment when single-machine capacity reaches the limit. To solve the large-scale web site access, concurrency, high volume of data problems.
From a stand-alone web site to a distributed Web site, it is important to differentiate between business splitting and distributed deployment, the application is split, and deployed to different machines for large-scale distributed systems. Distributed and business splitting solves the problem from centralization to distribution, but there is a single point of issue and access to the unified portal problem for each deployed standalone business, and we can take a redundant approach to solving a single point of failure. Deploy the same application to multiple machines. To solve the problem of accessing the unified portal, we can increase the load balancer device in front of the cluster to achieve traffic distribution.
Load Balancing (Balance), which means that load (work tasks, access requests) are balanced and distributed across multiple operating units (servers, components) for execution. is the ultimate solution for high-performance, single-point-of-failure (high availability), scalability (horizontal scaling).
This article is the first article on load Balancing, which describes the principle of load balancing, Load Balancing classification (DNS load balancing, HTTP load balancing). Part of the content is excerpted from reading notes.
This sharing outline
- Principle of load Balancing
- DNS Load Balancing
- HTTP Load Balancing
First, load balancing principle
The expansion of the system can be divided into vertical (vertical) expansion and horizontal (horizontal) expansion. Vertical expansion, from the point of view of a single machine to increase the hardware processing capacity, such as CPU processing capacity, memory capacity, disk and so on, to achieve the improvement of server processing capacity, can not meet the large-scale Distributed System (website), large traffic, high concurrency, massive data problems. Therefore, a scale-out approach is required to accommodate the processing power of large Web services by adding machines. For example: A machine can not be satisfied, then add two or more machines, the joint burden of access pressure. This is the typical cluster and load-balancing architecture:
- Application clusters: Deploy the same application to multiple machines, compose a processing cluster, receive requests for load-balanced device distribution, process them, and return the corresponding data.
- Load Balancing Device: Distributes user-accessed requests to a processing server in a cluster based on the load-balancing algorithm. (A device that disperses network requests to an available server in a server cluster)
The role of load balancing (problem solved):
1. Solve concurrency pressure, improve application processing performance (increase throughput, strengthen network processing power);
2. Provide failover to achieve high availability;
3. Provide website scalability (extensibility) by adding or reducing the number of servers;
4. Security protection; (do some filtering on the load balancer device, black and white list etc.)
Second, load Balancing classification
According to the implementation technology, it can be divided into DNS load balancing, HTTP load balancing, IP load Balancing, link layer load balancing and so on.
2.1DNS Load Balancing
The first load balancing technology, using domain name resolution to achieve load balancing, in the DNS server, configure multiple A records, these A records corresponding to the server constitutes a cluster. Large Web sites are always partially using DNS resolution as the first level of load balancing. Such as:
Advantages
- Simple to use: Load balancing work to DNS server processing, eliminating the hassle of load balancing server maintenance
- Improve performance: can support address-based domain name resolution, resolved to the nearest user server address, can speed up access to improve performance;
Disadvantages
- Poor availability: DNS resolution is a multilevel resolution, new/modified DNS, parsing time is long, during the parsing process, the user access to the site will fail;
- Low scalability: DNS Load Balancing control in the domain name vendor, it can not do more to improve and expand;
- Poor maintainability: Also does not reflect the current running state of the server, the number of supported algorithms, can not distinguish between server differences (not based on the state of the system and service to determine the load)
Practical advice
DNS is used as the first-level load balancer, a record corresponds to an internal load-balanced IP address, and the request is distributed to the real Web server through internal load balancing. Generally used in Internet companies, complex business systems are not suitable for use. Such as:
Large Web site Architecture series: Load Balancing detailed (1)