Website architecture exploration (3)-Server Load balancer approach Wang zebin

Source: Internet
Author: User

 

In the previous article, I introduced some of the principles and concepts of cdn and the ways to provide basic cdn services. Cdn seems to be very suitable for static content, such as html, js, and image. Through cdn deployment, users only need to access the website content in one hop. What about dynamic content? I will answer:
Dynamic content can be divided into three types according to the existing form.
The first category: content does not need to be changed for a long time. This type of content is generally converted to static content through static Web page technology to achieve cdn deployment. The typical type is content-based websites, for example, content publishing systems such as Sina, Sohu, and Netease, and management work such as content addition, deletion, modification, and so on are quasi-real-time Synchronized to each node.
Category 2: The content may change in a short period of time, but it will eventually be stable. For example, for forums, blogs, and other applications, the content provided by such services is synchronized in batches at a certain interval. Of course, there are also real-time static content, the Mop-like hodgedge and Netease community use such strategies.
Category 3: The content changes in real time and is very personalized. For example, for mailbox applications, the content provided by such services cannot be static and can only be optimized through regional deployment and load balancing.
For the vendors that provide cdn services, static content cdn is naturally no problem. For the third type of services, they can only be optimized from the communication link layer.
For the pseudo-static nature of many websites, some are for Seo considerations, and some are for security reasons, the means are basically rewrite URLs. It is just an external form of expression. It is different from Html static, and it is still a dynamic content.

1. Load Balancing Classification
The server Load balancer technology is widely used and mature in website operation. Server Load balancer is divided into soft and hard balancing Based on hardware and software. Soft balancing is a balance based on software technology, while hard balancing is a balance based on hardware technology;
Layer-4 and layer-7 are divided according to network protocols. Layer-4 balancing is data balancing Based on the OSI network layer, and layer-7 balancing is data balancing Based on the OSI application layer.
Various balancing methods are used in large websites. In most cases, they are a combination of multiple balancing methods.

2. DNS round robin balancing
This method is a relatively independent method. It is not listed in the preceding table, but is widely used and is generally used at the front end of a website. You can perform a test to run the nslook command in the doscommand line. For example, nslookup www. 163. Com, you will see that the command gives a bunch of resolved IP addresses. These addresses are multiple A records bound to the domain name www.163.com. The access request token we initiate from the browser. Using this principle, the Dns round robin method binds n ip addresses under a domain name, and access requests are evenly distributed to different devices. The IP address provided by Dns round robin is often the address of a cluster in a large website, which may be a balanced switch or a balanced server. For small websites, it is no problem to connect multiple servers.

Advantages of DNS round robin balancing:
1. Zero cost: Only A few A records are bound to the Dns server, which is generally provided by the domain name registrar;
2. easy deployment: Expand devices in the network topology and add records to the Dns server.
Disadvantages of DNS round robin balancing:
1. unbalanced traffic distribution: the Dns resolution process involves many links and is a layer-by-layer caching mechanism. Although your dns server is updated, however, the client and other dns servers on the network are not updated in real time, so it is difficult to ensure an average of 100% of the traffic. Currently, dns servers provide multiple methods to adjust dns round robin allocation policies, but they cannot guarantee perfect balance.
2. Health Check: If A server in the Dns server's A record address is down, the DNS server will still allocate access to the server. Therefore, personnel or tools are required to perform real-time detection. After A machine goes down, the backup machine is pushed to the production line. If you want to remove an address from the record address, this notification process takes several hours or even longer to spread to all clients.

It is very effective to push the Dns round robin method to the frontend of the service. It maps access users to different service clusters in the original way. For large websites, the IP addresses of external services cannot be changed frequently. Once the backend cluster is down, the redundant cluster can be quickly promoted. In addition, the Service is generally deployed through CDN, and the service is split into various parts, so the operation process will not have a big impact.

3. OSI Layer-7 Model
Let's talk about layer-7 balancing. To understand the principle of layer-4 and layer-7 balancing, you must first recall the network layer-7 model (OSI) in university textbooks ).
OSI is an open reference model for System Interconnection. It is a well-defined protocol specification. The OSI model has a layer-7 structure, and each layer can have several child layers.
The OSI Layer-7 model is a good theoretical model, but has been cropped in practical applications. Especially with the prevalence of TCP/IP, the layer-7 structure is squashed into layer-4,
Therefore, many people criticize that the OSI Layer-7 model is too complex. However, it is well recognized as a complete and comprehensive network model. Layer 7 of OSI consists of the application layer, presentation layer, Session Layer, transmission layer, network layer, data link layer, and physical layer.
Layer-7 features:
(1) Application Layer: an application that communicates with other computers. It corresponds to the communication service of applications. For example, a word processing program without communication functions cannot execute communication code, and programmers engaged in word processing do not care about OSI Layer 7th. However, if a file transfer option is added, the programmer of the word processor needs to implement the OSI Layer 7th. Example: telnet, HTTP, FTP, WWW, NFS, SMTP, etc.
(2) Presentation Layer: The main function of this layer is to define the data format and encryption. For example, FTP allows you to transfer data in binary or ASII format. If binary is selected, the sender and receiver do not change the file content. If the ASII format is selected, the sender converts the text from the sender's character set to the standard ASII and then sends the data. The receiver converts the standard ASII to the character set of the receiver's computer. Example: encryption, ASII, etc.
(3) Session Layer: it defines how to start, control, and end a session, including control and management of multiple two-way hours, so that the application can be notified when only part of the continuous message is completed, so that the data seen in the presentation layer is continuous. In some cases, if the presentation layer receives all the data, data is used to represent the presentation layer. Example: RPC and SQL.
(4) Transport Layer: This layer features whether to select the error recovery protocol or error-free recovery protocol, and reuse the input of data streams of different applications on the same host, it also includes the re-sorting function for packets that are not in the correct order. Example: TCP, UDP, and SPX.
(5) network layer: This layer defines the end-to-end packet transmission. It defines the logical addresses that can identify all nodes, and also defines the routing implementation and learning methods. To adapt to the transmission medium whose maximum transmission unit length is smaller than the packet length, the network layer also defines how to break a packet into smaller packets. Example: IP, IPX, etc.
(6) data link layer: it defines how data is transmitted on a single link. These protocols are related to the song media discussed. Example: ATM, FDDI, etc.
(7) Physical Layer: OSI physical layer specifications are characteristic standards for transmission media. These specifications are generally referred to standards developed by other organizations. Connector, needle, needle usage, current, current, encoding and optical modulation all belong to the content of various physical layer specifications. Multiple specifications are commonly used in the physical layer to define all details. Example: Rj45, 802.3, etc.

 

Recently, I have been pondering the new argument raised by a thinker: ten glasses, nine hooligans, and one Lust. Really?

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.