preface

The full name of CDN is Content Delivery Network. CDN is a content distribution network built on the network. Relying on the edge servers deployed in various places and through the function modules of load balancing, content distribution and scheduling of the central platform, users can obtain the content they need nearby, reduce network congestion and improve user access response speed and hit ratio. The key technologies of CDN mainly include content storage and distribution. — Science Encyclopedia

The content has been posted on gitHub, welcome to Star, more articles are posted on gitHub.

The significance of CDN:

In order not to let network congestion become an obstacle to the development of the Internet.

For example

Before talking about CDN, let’s take a look at a life example:

Shopping on Taobao

We shop on Taobao, and most individual sellers only deliver goods in one place. It seems that outside jiangsu, Zhejiang and Shanghai, the goods are relatively slow to receive.

Shopping on JD.com

If we buy our own products on JINGdong, it will find the nearest and fastest warehouse nationwide according to our receiving location. No matter we are in Jiangsu, Zhejiang and Shanghai, xinjiang, Tibet and Inner Mongolia, our receiving time will be greatly reduced. Jd’s logistics system is similar to CDN.

From the above example, we can get a general idea of the basic principle of CDN, that is, relevant static resources are placed on CDN servers everywhere.

The advantage of CDN

  1. CDN node solves the problem of cross-operator and cross-region access, and the access delay is greatly reduced.
  2. Most of the requests are completed at the edge of CDN, which plays a shunt role and reduces the load of the source station.
  3. Reduce the impact of “broadcast storm” and improve the stability of network access; It saves backbone network bandwidth and reduces bandwidth demand.

Fast access speed is one of the necessary magic weapons to win the e-commerce website.

There are two core points of CDN: one is cache and the other is back source.

The cache

Resources requested from the root server are cached as required.

Back to the source

When a user accesses a resource, if the CDN node that is resolved does not cache the response content, or the cache has expired, it will go back to the source station to obtain the response. No one visits, CDN nodes will not take the initiative to request resources from the source station.

The key technology

  1. Content publishing: it publishes or delivers content to the nearest remote service point (POP) by means of indexing, caching, stream splitting, Multicast and other technologies.
  2. Content routing: it is a holistic network load balancing technology. Through the redirection (DNS) mechanism in the content router, users’ requests are balanced on multiple remote pops so that users’ requests can get the response from the nearest content source.
  3. Content exchange: it uses application layer exchange, stream splitting, redirection (ICP, WCCP) and other technologies to intelligently balance load traffic on the cache server of POP according to the availability of content, server availability and user background.
  4. Performance management: It obtains the health information of network components through internal and external monitoring systems, measures the end-to-end performance of content publishing (such as packet loss, delay, average bandwidth, startup time, frame rate, etc.), and ensures the optimal running state of the network.

The front-end tends to think of CDN as something you don’t need to know. But we front-end engineers are software engineers first. It is certainly beneficial to know more about things.

CDN & Static resources

Static resources have the characteristics of high access frequency and large incoming traffic, so the loading speed of static resources is always a key indicator of front-end performance. CDN is an important means to speed up static resources.

taobao

jingdong

The Denver nuggets

CDN & Cookie

We know that cookies and domain names go hand in hand. That is, all requests under the same domain name carry the same Cookie (which can be very large if not set properly).

Cookies are often not required for static resources

Static resources such as authentication information carried are generally not needed. Placing static resources and home pages under different domain names is a perfect way to avoid carrying unnecessary cookies in requests.

This is another benefit of CDN.

Finally, I will show you a direct view to compare the differences before and after the deployment of CDN service:

The last

If you want to join [big front-end communication group], you can pay attention to the public account and click “communication plus group” to add the robot to automatically pull you into the group. Pay attention to the first time I receive the latest dry goods.