Large Web site Architecture series: Load Balancing detailed (1)

Source: Internet
Author: User

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, IP load Balancing, link-layer load balancing, mixed p load balancing). Part of the content is excerpted from reading notes.

This sharing outline
    1. Principle of load Balancing
    2. DNS Load Balancing
    3. HTTP Load Balancing
    4. IP load Balancing
    5. Link Layer Load Balancing
    6. Hybrid p-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

    1. Simple to use: Load balancing work to DNS server processing, eliminating the hassle of load balancing server maintenance
    2. Improve performance: can support address-based domain name resolution, resolved to the nearest user server address, can speed up access to improve performance;

Disadvantages

    1. 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;
    2. Low scalability: DNS Load Balancing control in the domain name vendor, it can not do more to improve and expand;
    3. 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:

1.3 IP Load Balancing

The network layer is load balanced by modifying the request destination address.

After the user requests the packet, arrives at the Load Balancer server, the Load Balancer server obtains the network packet in the operating system kernel process, obtains a real server address according to the load balancing algorithm, then modifies the request destination address to, obtains the real IP address, does not need passes through the user process processing.

After the real server processing is completed, the response packet goes back to the Load Balancer server, the Load Balancer server, and then modifies the packet source address to its own IP address, which is sent to the user's browser. Such as:

IP load Balancing, the real physical server is returned to the Load Balancer server, there are two ways: (1) The Load Balancer server modifies the destination IP address while modifying the source address. Set the packet source address to its own disk, which is the source address translation (Snat). (2) The Load Balancer server acts as a gateway server for the real physical server cluster.

Advantages:

(1) It is better to distribute the data in kernel process than in the application layer;

Disadvantages:

(2) All request responses need to go through the Load Balancer server, the maximum throughput of the cluster is limited by the bandwidth of Load balancer server NIC;

2.4 Link Layer load Balancing

The data link layer of the communication protocol modifies the MAC address for load balancing.

Data distribution, do not modify the IP address, refers to the modification of the target MAC address, configure the real physical server cluster all machine virtual IP and Load Balancer server IP address consistent, to not modify the source address and destination address of the packet, for data distribution purposes.

The actual processing server IP and data request destination IP consistent, do not need to go through the Load Balancer Server for address translation, the response packet can be directly returned to the user browser, to avoid load Balancing server network card bandwidth becomes a bottleneck. Also known as Direct route mode (DR Mode). Such as:

Advantages: good performance;

Cons: Complex configuration;

Practice Recommendation: Dr Mode is currently the most widely used load balancing method.

2.5 mixed-load balancing

Due to the differences in hardware devices, sizes, and services provided in multiple server farms, it is possible to consider the most appropriate load balancing method for each server farm. Then again load-balancing or clustering among the multiple server farms to provide services to the outside world (i.e., as a new server farm) for optimal performance. This approach is called hybrid load balancing.

This approach is sometimes used in situations where the performance of a single equalization device does not satisfy a large number of connection requests. is currently a large-scale Internet company, commonly used in the way.

Way one, such as:

The above pattern is suitable for the scene with static and dynamic separation, and the reverse proxy server (cluster) can play the role of caching and dynamically requesting distribution, when the static resource is cached on the proxy server, it is returned directly to the browser. If the dynamic page requests a later application load balancer (application cluster).

Mode two, such as:

Above mode, suitable for dynamic request scene.

Because of the mixed mode, according to the specific scene, flexible collocation of various ways, the above two methods for reference only.

Reference:

Http://www.cnblogs.com/itfly8/p/5043435.html

Large Web site Architecture series: Load Balancing detailed (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.