CDN

1. The background

The distance data travels over the network directly affects the response speed of requests, and if the server does not fully cover your business, your application will be slower and experience worse. Therefore, it is necessary to shorten the physical distance between the client and the server.

Before playing games, there is always a kind of experience, you need to choose the game region, such as east China, South China and so on, this is to let the user to choose the server closest to their own, so as to achieve the best game experience. But relying on users to do this kind of optimization is not friendly, so CDN(Content delivery Network) came into being.

You just need to set up multiple node servers in your business area, and then rely on the intelligent dispatching of DNS, so that network requests can be accessed nearby.

To understand the principle of CDN, there are roughly two points:

  • How to forward requests to servers in close proximity;
  • What resources to deploy on node servers and how to deploy them.

2. Workflow of CDN

The workflow of CDN is closely related to DNS resolution. It only adds intelligent DNS(scheduled DNS) to the DNS resolution process. When a customer sends a network request, the intelligent DNS server will determine your location according to your IP address and return the IP address of the nearest server instead of directly returning the source IP address.

3. Classification of CDN

Node server resources

  • Static resources: HTML, JS, CSS, images, videos, and installation packages. These resources are static and generally large in volume. They can be deployed to node servers to speed up response and reduce bandwidth pressure on source sites.
  • Dynamic resources: dynamic data, such as the need to return to the database resources, the client can directly request the source site.

Update type of node server resources

  • Active push: the source station can actively push the commonly used resources to the node server;
  • Passive push: For infrequently used resources, the source site can wait for a node server cache miss request and then return.

4. Benefits of CDN

  • The physical distance between the user and the server becomes shorter, which speeds up the response time of the website
  • The server becomes more efficient by reducing load, bandwidth, and so on
  • The source station is much more hidden and secure

DNS Resolution Process

To understand CDN, we must also understand the DNS resolution process:

1. DNS resolves IP addresses on a hierarchical basis

  • Root DNS server: only responsible for top-level domain resolution;
  • Top-level domains such as.com,.gov (government),.cn (China), jp (Japan), and.kr (Korea) are categorized by domain name suffixes
  • Secondary domain: the next level domain

2. Process for obtaining an IP address through DNS (www.baidu.com)

  • When you visit a domain name, the request goes to your router (which can resolve DNS), and the router looks up for the IP;
  • Request the root domain, resolve the location of the top-level domain (.com), and return it to the router;
  • The router requests the top-level domain. The top-level domain can parse out the address of the baidu.com domain and return it to the router.
  • The router requests the second-level domain, which resolves the address of the next-level domain (www.baidu.com) and returns it to the router.
  • The router can then return the IP address to the browser. The router will cache the corresponding IP address of each of the above domains. As long as there is a cache, the router will directly return the IP address and stop searching up

Of course, CDN will have cache in every process of the whole resolution, from the browser to the computer and then to the router will cache the DNS resolution results every time, so as to speed up the response of the browser, but also indirectly reduce the pressure of DNS domains at all levels

Each level of domain name resolves only a portion of the URL, and this hierarchical architecture successfully distributes the pressure from one level to the next.

Very few developers are exposed to CDN process development, and knowing how pigs run is important, even if you don’t get to eat pork.


Talk about some of my learning methods:

  • When you’re first introduced to a concept, it’s always a little hard to understand or accept:
    • At this time, you can keep googling and read multiple articles in a point that you don’t understand. Maybe you didn’t understand this one, but the explanation Angle of another one will make you suddenly enlightened and understand the concept that you want to express in the last one. Learn from multiple angles and aspects, and you will understand faster and more comprehensively.
    • In addition, when learning, they will have a precipitation process. If you read an article today and tomorrow, you will have a different understanding. It may be that you have understood it at a deeper level, or you may learn a point that you did not pay attention to before. It is better to study it many times at irregular intervals before you are thoroughly proficient in it.
  • To learn something,background,concept,The whole processBe sure to be clear about why, what and how. You don’t have to dig really fine,When you actually have a problem, thinking that it can solve the problem is a success. You can study it when you really need it to solve a problemSpecific application process and principleA:
    • First, a secondary learning process, its context, what it can solve, these important concepts of comprehension will be more firmly in your mind.
    • Secondly, driven by business and problems, your purposefulness will greatly improve your learning efficiency and make you learn things very quickly.

No matter in life and work, these learning habits have become a part of me, I hope my sharing can help everyone, after all

The ability to learn is important!

The ability to learn is important!

The ability to learn is important!