How does a CDN work? Do you know?
A content delivery network (CDN) refers to geographically distributed servers (also known as edge servers) that can quickly deliver static and dynamic content. Let's take a look at how it works.
Let's say Bob, who lives in New York, wants to access an e-commerce website deployed in London. If the request is sent to a server located in London, the response will be quite slow. So, we deploy a CDN server near where Bob lives, and the content will be loaded from the nearby CDN server.
The following diagram illustrates this process.
Image
Step 1
Bob types www.myshop.com into the browser, which looks up the domain name in the local DNS cache.
Step 2
If the domain name doesn't exist in the local DNS cache, the browser goes to a DNS resolver to resolve the domain name. DNS resolvers are typically located in Internet Service Providers (ISPs).
Step 3
DNS resolvers recursively resolve domain names. Finally, it asks the authoritative name server to resolve the domain name.
Step 4
If you don't use a CDN, the authoritative name server returns the IP address of the www.myshop.com. But with a CDN, the authoritative name server has an alias pointing to www.myshop.cdn.com (the domain name of the CDN server).
Step 5
DNS resolvers require authoritative name servers to resolve www.myshop.cdn.com.
Step 6
The authoritative name server returns the domain name www.myshop.lb.com of the CDN load balancer.
Step 7
The DNS resolver requires the CDN load balancer to resolve the www.myshop.lb.com. The load balancer selects the best CDN edge server based on the user's IP address, the user's ISP, the content requested, and the server load.
Step 8
The CDN load balancer returns the IP address of the CDN edge server to www.myshop.lb.com.
Step 9
Now that we finally have the actual IP address to access, the DNS resolver returns the IP address to the browser.
Step 10
Browser access to CDN edge server loading content There are two types of content cached on CDN servers: static content and dynamic content. The former includes static pages, images, and videos; The latter includes the results of edge computing.
Step 11
If the content is not available in the Edge CDN server cache, it is uploaded to the regional CDN server. If you still can't find the content, go up to the central CDN server or even to the origin, the London web server. This is known as a CDN distribution network, where servers are deployed geographically.
How can I prevent piracy of videos cached on a CDN?
- Video encryption and watermarking
Encryption: Video files are encrypted, decrypted and played back only by authorized clients. Standard encryption algorithms such as AES can be employed.
Dynamic Watermarks: Incorporate traceable dynamic watermarks into your videos that change as the video plays, allowing them to be traced back to the source of piracy.
- Signing and token validation
Use signatures and tokens to ensure that every request is verified. For example, include timestamps and cryptographic signatures in video links to ensure that they are only valid for a certain period of time and that unauthorized requests are denied.
- Limit the cache duration
Set a short cache expiration time to prevent video content from being stored on CDN nodes for a long time. Reduce the risk of piracy by controlling TTL (Time To Live) or cache purging policies to reduce the cache lifetime of your videos.
- Leechlink protection
Configure CDNs and servers to restrict access sources for video content. For example, use HTTP Referer header checks to ensure that only requests from legitimate websites or apps can access videos.