Last update: 20170628
Last Friday I was asked “how does a CDN work?” The first time I was asked the same question was year 1999. I acquired a lot of CDN knowledge and experience since I join the industry in 2012. CDN is not yet an everyday business in Asia nowadays. I want to help. An one page brief explanation. Hope you like it.
What is a CDN?
A Content Delivery Network (CDN) is a collection of web servers distributed among multiple locations to deliver content to users more efficiently.
What is the job to be done by CDN?
To send web content to enduser faster. How? By moving data close to the endusers to reduce round trips and network.
Ilya Grigorik, web performance engineer at Google, says :
- Latency, not bandwidth, is the performance bottleneck for most websites.
- Four major latency types: propagation delay, transmission delay, process delay, queuing delay
- To improve performance of our applications… we need to reduce round trips, move the data closer to the client.
Centralized Server vs CDN 
How does a CDN work?
In essence, CDN puts your content in many places at once, providing superior coverage to your users. For example, when someone in London accesses your US-hosted website, it is done through a local UK CDN server. This is much quicker than having the visitor’s requests, and your responses, travel the full width of the Atlantic and back.
By connecting users who request your website content to CDN, instead of connecting directly to your web server.
Using traditional centralized server model, a website, say www .abc.com, will usually have a “A Record” in the DNS configuration (of abc.com) to inform people to connect to the web server with the specific IP address, say 188.8.131.52. We call this Customer Origin. When a user John in Beijing browses www .abc.com the following (behind the scene) steps will happen:
- John’s computer will ask the its local DNS resolver to figure out the IP address of www .abc.com
- the resolver will then ask the root DNS server what is the authoritative DNS server of abc.com
- The resolver will then ask the authoritative DNS sever of abc.com what is the IP address of www .abc.com and will get the answer of 184.108.40.206.
- John’s computer will then connect to 220.127.116.11 to get the web content of www .abc.com
With CDN, www .abc.com will have a “CNAME Record” in the DNS configuration to inform people to connect to the server with the specific hostname, say abc.customer.cdn.com provided by the CDN provider. When John browses the website www .abc.com, we will have the same first two steps above-mentioned, but subsequent steps will become:
- The resolver will then ask the authoritative DNS server of abc.com what is the IP address of www .abc.com and will get the answer of abc.customer.cdn.com
- The resolver will then ask the authoritative DNS server of cdn.com what is the IP address of abc.customer.cdn.com. The authorization DNS server of cdn.com will, based on the IP address of John’s local DNS resolver and the CDN provider’s routing algorithm, provide the answer, say 18.104.22.168, which is the IP address of the CDN cache server located in/near Beijing and is the best machine to deliver the content of www .abc.com to John
- John’s computer will then connect to 22.214.171.124 to retrieve the web content of www .abc.com
Say there is another user Mary in Singapore going to browse www .abc.com, we will have the similar four steps, but the CDN provider will use, say 126.96.36.199, which is the IP address of the CDN cache server located in/near Singapore which can serve Mary most efficiently.
Do I need to upload my website content to CDN?
Not necessary. In most cases, CDN will on-demand fetch content from the Customer Origin.
When the CDN cache serve receives the HTTP GET request of www .abc.com from an enduser, the cache server will check if the requested content of www .abc.com is already stored in its storage:
- If yes, then the cache server will send the content stored on it to the enduser. We call this “Cache Hit”
- If no, then the cache server will fetch the content from the Customer Origin, then store it and send it to the enduser. We call the situation of missed content “Cache Miss”, and the process of fetching content from Customer Origin “Cache Fill”. CDN will Cache Fill when it needs to update the stored content.
The higher the Cache Hit rate, the faster the content delivery. High Cache Hit rate better utilizes CDN and reduces Customer Origin loading.
How long will the CDN keep my web content?
CDN provider will usually honor the Cache-Control header setting in Customer Origin. During the Cache Fill process, the CDN cache server will cache both the web content and the HTTP header information, including the Cache-Control header attributes. CDN provider will keep the content according to the Cache-Control setting or based on the customer CDN configuration.
CDN nowadays offers more features and services. Below are the key benefits of using CDN:
- Faster delivery of both cacheable and non-cacheable content
- Higher availability by leveraging CDN’s global footprint and scale.
- More secure by shielding the Customer Origin from public access.
- Reduce the expense on Customer Origin resources (computer and connectivity)
- High Performance Web Sites, Steve Souders
- High Performance Browser Networking, Ilya Grigorik
- CDN, Wikipedia
- Essential Guide to CDN, Incapsula
- Cache-Control header, Mozilla.org
I prepare this blogpost on the new iPad Pro 10.5” with Smart Keyboard. It is GREAT. Looking forward to iOS 11!
[Update: 20170628] Apple iPad Pro 10.5” with iOS 11 beta
You’re looking for a more powerful portable USB wall charger for your coming travel, aren’t you?
My use case for a portable USB wall charger with four USB ports is to charge at once my smartphone, tablet, Bluetooth headphone and Apple Watch. It helps me to have my most-frequently-used gadgets working all the time, especially when I am travelling and I don’t want to have multiple chargers in my luggage.
Anker is the one the most popular USB wall charger manufacturers on Amazon. I bought an Anker PowerPort 4 early this month and have been using it since then. I am glad to use it. It is my pleasure to share my review with you.
- It is powerful! It can output up to 8A and 40W! Each port can output up to 2.4A. iPhone 6(s) (plus) can draw up to 2.1A while iPad Air 1/2 draws 2.4A. So even if you plug in two iPhone 6 and one iPad Air, the charger is able to output another 7W, large enough for Apple Watch or typical Bluetooth headset. It meets my use case.
- It is small and light weight. The plug is foldable.
- It is Smart and charges faster. By Anker’s PowerIQ technology, Anker PowerPort 4 can communicate with the device being charged and provide it with the highest current it can take. For example, if an iPhone 6 is plugged in any one of the four USB ports, the port will charge it at 2.1A which is the maximum current iPhone 6 can take. If it is an iPad Air, it will charge it at 2.4A. Charging at maximum current reduces charging time and minimises the expense of unnecessary power. Doing so will make the best use of the maximum 40W power throughput the device can support. Because it charges fast, it can charges more devices (e.g. portable battery) in the same time span when compared to other wall chargers.
- It is Smart and user-friendly. Some wall chargers (e.g. Arctic Charger Pro 4) require user to plug power hungry device into the right “fast charge” port. Otherwise if you plug a power hungry device into a standard port, it will be charged at 500mA only and hence takes more time. Anker PowerPort 4 does not require this.
- It is Smart and works with devices which require non-standard USB chargers. A device being charged can detect what type of charger is being used through specific voltages on the USB data pins. Because of this, some devices only work with their own special chargers. An example is Nokia E6 which does not support charging by “dump” charger via its micro USB port. Anker PowerPort 4 is smart and can manage the voltages at the two data pins in each of the four USB ports.
- It provides visibility of charging status. When the PowerPort 4 is “slowly charging” or in standby mode (at an output current of less than 500mA), the LED will illuminate in blue. When the PowerPort 4 is “fast charging”(at an output current of higher than 500mA), the LED will illuminate in green. When you see the blue light, it implies your iPhone or iPad is fully charged. You can then charge something else.
- It is safe. Built-in surge protection.
- It can be used in many countries. It is Type A plug which is used in China, Taiwan, Japan and US, etc.
- It is joyful to use. It is beautiful. Its USB ports align. It shows commitment.
- It is not available in the retail 3C shops in Hong Kong.
- It does not support Type G plug used in Hong Kong.
- How USB charging works, or how to avoid blowing up your smartphone | ExtremeTech
- A dozen USB chargers in the lab: Apple is very good, but not quite the best | Ken Shirriff’s blog
- How do USB charging and “smart” charging ports (e.g. Anker’s PowerIQ) work? | StackExchange
- Plugs of the World | iTunes Store
(The following video is for testing purpose.)