Read the principle of CDN acceleration in one article

What is CDN

CDNThe full name is Content Delivery NetWork, ie 内容分发网络. It 目的is to add a new layer to the existing Internet, and 缓存层publish the content of the website to 最接近用户的网络边缘节点so that users can 就近取得get the content 提高they need 访问网站的响应速度.

Technically 全面解决Since the 网络带宽小, 用户访问量大, 网点分布不均and other issues, 提高the user 访问网站的响应速度.

The following is a simple schematic diagram of CDN: The
Insert picture description here
CDNpair is 网络的优化作用mainly reflected in the following aspects:

  • Resolve server-side 第一公里problem
  • Alleviate or even eliminate the impact of interconnection bottlenecks between different operators
  • Reduced the export bandwidth pressure of various provinces
  • Relieved the pressure on the backbone network
  • Optimized online hot content

working principle

Traditional visit process

Insert picture description here

As can be seen from the above figure, 未使用 CDN 缓存the process of a user visiting the website:

  1. The user enters the domain name to be accessed, and the operating system queries LocalDNS for the IP address of the domain name
  2. LocalDNS queries Root DNS for the authorized server of the domain name (here it is assumed that the cache of LocalDNS has expired)
  3. Root DNS responds the domain name authorized DNS record to LocalDNS
  4. After LocalDNS obtains the domain name authorization record, it continues to query the domain name's ip address from the domain name authorization DNS
  5. LocalDNS returns the obtained domain name ip address to the client
  6. After the user gets the domain name IP address, he visits the site server
  7. The site server responds to the request and returns the requested resource to the client

CDN access process

Insert picture description here
From the above figure, we can understand that the 使用了 CDN 缓存subsequent website visit process is changed to:

  1. The user enters the domain name to be accessed, and the operating system queries LocalDNS for the IP address of the domain name
  2. LocalDNS queries RootDNS for the authorized server of the domain name (here it is assumed that the cache has expired)
  3. RootDNS returns the domain name authorized DNS record to LocalDNS
  4. After LocalDNS obtains the authorization record of the domain name, it continues to query the domain name's IP address from the domain name authorized DNS
  5. After the domain name authorizes DNS to query the domain name record (usually CNAME), it responds to LocalDNS
  6. Intelligent scheduling DNS responds with the most suitable CDN node IP address to LocalDNS according to certain algorithms and strategies (such as static topology, capacity, etc.)
  7. LocalDNS gets the domain name IP address and returns it to the client
  8. After the client gets the IP address, it sends a request to access the site server
  9. The CDN node server responds to the request and returns the content to the client

Through the above comparison, we can get: In order to achieve transparent access to ordinary users (the user does not need to make any settings after using the cache) access, DNS (domain name resolution) needs to be used to guide users to access the Cache server to achieve transparent acceleration services. Since the first step for users to visit a website is domain name resolution, it is the simplest and most effective way to guide users to visit by modifying DNS.

Components

For ordinary Internet users, each CDN 节点equivalent to a placed in him 周围的网站服务器. Through the takeover of DNS, the user's request is transparently directed to him 最近的节点, and 节点中的 CDN 服务器will 网站的原始服务器respond to the user's request like the same. Since it is closest to the user, the response time is also faster.

From the above figure, we can know that the dashed block is CDN层, and this layer is 位于用户端和站点服务器之间.

Intelligent scheduling DNS

智能调度 DNSIt is a key system in the CDN service. When a user visits a website that joins the CDN service, it 域名解析请求will ultimately be 智能调度 DNShandled. It provides the user with the node address closest to the user through a set of pre-defined strategies, so that the user can get fast service. At the same time, it needs to keep in touch with CDN nodes distributed in various places, track the health status, capacity and other information of each node, and ensure that user requests are distributed to nearby available nodes.

Cache function service

Load balancing equipment

Content Cache server

Shared storage

Glossary

CNAME record

CNAMEThat is 别名(Canonical Name); it can be used to resolve a domain name into another domain name. When the DNS system is querying the name on the left of CNAME, it will turn to the name on the right of CNAME for query, until the last PTR or A name is reached. Will respond, otherwise it will fail.

For example, if you have a server that stores a lot of information, you use doc.example.com to access these resources, but you want to access these resources through documents.example.com, then you can resolve it in your DNS The service provider adds a CNAME record and points documents.example.com to doc.example.com. After adding the record, all requests for accessing documents.example.com will be forwarded to doc.example.com and get the same response.

CNAME domain

When accessing the CDN, after adding the accelerated domain name in the CDN provider console, you will get a CNAME domain name assigned to you by the CDN. You need to add a CNAME record to your DNS resolution service and point your accelerated domain name to this CNAME Domain name, so that the request for this domain name will be directed to the CDN node to achieve acceleration.

Back to source host

The return-to-origin host determines the specific site that the return-to-origin request visits to the original site.

Example 1: The origin site is the domain name. The origin site is www.a.com, and the return-to-origin host is www.b.com, then the actual return-to-origin is the IP resolved by the request to www.a.com, and the corresponding site www on the host .b.com

Example 2: The origin site is the IP origin site is 1.1.1.1 and the return source host is www.b.com, then the actual return source is the site www.b.com on the host corresponding to 1.1.1.1

Agreement back to the source

It means that the protocol used when returning to the source is consistent with the protocol used when the client accesses the resource. That is, if the client uses HTTPS to request the resource, when the resource is not cached on the CDN node, the node will use the same HTTPS method to get the resource back to the source; Similarly, if the client uses the HTTP protocol request, the CDN node also uses the HTTP protocol when returning to the source.


谢谢你阅读到了最后~
期待你关注、收藏、评论、点赞~

Refer to the
CDN acceleration principle-using the Journey to the West as an analogy, it is more interesting
CDN acceleration principle
front-end advanced road-full of dry goods

Guess you like

Origin blog.csdn.net/weixin_42752574/article/details/109303090