Brief introduction of Load Balancing &CDN technology

Source: Internet
Author: User
Tags nginx reverse proxy

Original address: http://www.cnblogs.com/mokafamily/p/4402366.html

I've seen people ask, "Why do sites like Facebook require thousands of engineers to maintain?" ", the following answers are various, but summed up is: a high-performance web system needs to consider him from countless angles, large to the server layout, small to the implementation of a file in the software, or even a loop of operations if the occurrence of a non-rigorous can cause the overall crash.

The above mentioned that the Web performance optimization needs a number of angles to consider, we can not take into account all the optimization details, but from our known level to optimize, we start from the network level.

① Network Request Path:

--------------------------------------------------------------------------------------------------------------- ---------|

(client input URL locator) → (DNS server looking for mappings) → (enter server, process data) → (return data to client)

In this use case we can clearly see the network request to return process, although very abstract, but enough for us to base on him to optimize.

--------------------------------------------------------------------------------------------------------------- ---------|

1) Load Balancing

Boss gave Xiaoming a lot of tasks, Xiao Ming found how to arrange the time also do not finish, so he stared at the side secretly watching the movie, Xiao Qiang suddenly feel behind a coolness, a look back xiaoming a face bad smile looked at him, "These several tasks to you, evening please you eat, otherwise ... Hehe hey ", Xiao Qiang although reluctant, but in Xiao Ming's request (coerce), can only obey. The next day, Xiao Ming successfully completed the task, to small strong bought a bag spicy bar.

The same is true for load balancing on a computer, where our big Boss client sends requests to the server, but one server is unable to withstand very high concurrency, and we forward requests to other servers, and of course the true load-balancing architecture is not another server that is forwarded by one server. A load Balancing hardware (software) that is responsible for allocating requests is added to the client and server side.

Dns

noun: DNS is a very important relay in the client send request, his role is to map the URL of the user request to a specific IP address, the world has 13 root servers, but usually for our domain name resolution is not the root server, but direct access to our LDNS (Local DNS Server), typically maintained by network operators.

The first load balancing is implemented by building local DNS server, the implementation is simple and easy to understand, for the same host name to assign multiple mappings, you can use round-robin, random and other ways to allocate requests. There seems to be no problem, but in the use of the process will find that if one of the address down, we can not be found in time, if there is a user is assigned to this host will have access to the failure condition, and we can not judge the load of each server, may appear, a server almost idle , and another server with a very high load pressure situation.

                                    (Enter server 1, process data)

(client input URL locator) → (DNS server looking for mappings) → (DNS assignment request) (return data to client)

                                    (Enter server 2, process data)

Hardware devices

  noun: Load balancer (Balancer), a load balancer is typically placed between the client and the server as a standalone hardware.

The load balancer device has a very good load balancing performance, he has a lot of load balancing strategy (weight, dynamic ratio, fastest mode, minimum number of connections, etc.), can guarantee a relatively better way to allocate requests, but the good things always have a price, that is the price, The price of a load balancer is often as high as a hundred thousand of or even hundreds of thousands of, and many companies are reluctant to pay for it.

Reverse Proxy

  noun: Nginx. High-performance, lightweight, has become the first impression of Nginx, Nginx as an HTTP server, when processing high concurrent requests more than the current mainstream Apache server performance, and Nginx is also an excellent reverse proxy server.

The first time to hear "reverse proxy", may be a little strange, but if you understand the corresponding forward proxy is very good understanding, the forward proxy is usually actively linked by the client, such as our scientific Internet access is to use the forward proxy, to achieve the purpose of indirect access to the site, and reverse proxy on the server side, without the active link, When we visit a website that has a reverse proxy, we actually access its reverse proxy server, not the real one, and the reverse proxy server forwards the request to the server when the request arrives at the reverse proxy server. Reverse proxy is one of the mainstream means to achieve load balancing, usually using Nginx and other servers to build, Nginx also has a number of allocation strategies to ensure the average distribution of pressure.

(Enter server 1, process data)

(client input URL locator) → (DNS server looking for mappings) → (reverse proxy server) (return data to client)

(Enter server 2, process data)

Nginx Reverse proxy: BIGIP (Hardware) Load balancing:

2) CDN

Video is always in the buffer, pictures of various loading not come out, a few years ago is normal but the matter, at that time we did not feel that the matter, but put this situation in the present, I think people absolutely directly on the small Red fork, then how can we avoid such a situation? That's what I'm talking about, content distribution Network (Delivery), referred to as: CDN.

  CDN is simply to store some static files of one or more servers, through replication, caching, and so on, to save the file.

1. What are static files?

css,html, pictures, media are static files, that is, users send requests do not affect the content of static files, and jsp,php and other files are not static files, because their content will be changed by our request.

How does 2.CDN achieve acceleration?

Typically, the data we want is obtained from the primary server, but if our primary server is in the south, and access users in the north, then the access speed will be relatively slow, slow down for a number of reasons, such as transmission distance, operators, bandwidth and other factors, while using CDN technology, We will distribute the CDN nodes everywhere, and when the user sends the request to the server, the server assigns the nearest CDN server based on the user's zone information.

Where does 3.CDN data come from?

  replication, caching , CDN servers can cache files after a user requests, or actively crawl the contents of the master server.

CDNs distributed around the world:

  

Brief introduction of Load Balancing &CDN technology

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.