CDN and then Domain ShardingPosted: August 3, 2013 Filed under: Uncategorized | Tags: CDN 1 Comment
[update 20160310: thank you for visiting my blog. Please note that demo webpages in this post are now working now. I will update them soon. ]
WebSiteOptimization.com says there are 86 resources and 7.6 hosts per web page on global average. However, for a typical website in Hong Kong there is a single dominant domain being used for downloading resources. It maybe because of easy content management – everything is under the same domain and relative paths are used in html codes. Another reason is the lack of understanding CDN and Domain Sharding.
There is a max number of concurrent connections to a single hostname for browser. For example, the numbers are 8 and 6 for IE 10 and Mobile Safari respectively according to Browserscope. This number limit the page load speed even if there is abundant available physical connectivity. Refer to Steve Souder’s Even Faster Web Sites, rule #9 Domain Sharding splits web content resources across multiple domains rather than a single domain. This technique allows more resources to be downloaded in parallel and hence reducing the overall page load time.
Should you use a lot of host on your web pages? Everything has its limit. Mobify did a test in 2012 and found that 2 hosts per mobile web page was the optimal number!
In my 21st demo, I compare web page with a single domain, with domain sharding and/or CDN applied:
A: origin web page delivered from customer origin in Singapore
B: the web page is delivered from CDN
C: the web page with domain sharding is delivered from CDN
D: the web page with domino sharding is delivered from customer origin in Singapore
All A, B, C and D are 150KB in size with 13 resources (including the HTML page). There is a single host staging.cheungwaikin.com in A. For D, resources split across two hosts, staging.cheungwaikin.com and image.cheungwaikin.com which are both in Singapore. To set up B is simple, product.cheungwaikin.com is pointing to CDN and CDN caches all resources from staging.cheungwaikin.com. For C, resources split across two hosts, production.cheungwaikin.com and cdn-i.cheungwaikin.com, and cdn-i.cheungwaikin.com is pointing to CDN and CDN caches resources from image.cheungwaikin.com.
Using webpagetest to load the pages from Dulles which is 18,256km from Singapore. The distance is about half of the 40,008km circumference of the Earth!
Test 1: A vs D: page load times of A and D are 1.669s and 1.549s.
Domain sharding improved page load time. Since the distance between web server and browser was huge, large transmission latency resulted in long load time. Transmission latency due to physical distance cannot be reduced by domain sharding.
Test 2: A vs B vs C: load times are 1.664s, 0.540s and 0.400s respectively.
It took just 32% of the load time of A to load B! Since content was delivered from EdgeCast CDN edge in Washington to Dulles, RTT was much smaller and transmission speed was much higher!
C was even faster since 12 objects were simultaneously download while for B only 6 objects were downloaded concurrently.
Test 3: C vs D: load times are 0.384s and 1.535s.
Domain sharing were used in both C and D. For C, distance and RTT between EdgeCast CDN edge and browser were both small, therefore times required for Initial Connection and Time To First Byte were small too!
1.use CDN first to improve website performance. Use CDN is the rule #2 suggested in Steve Souder’s first book High Performance Web Site.
2.in order to make Even Faster Web Sites, apply Domain Sharding after CDN!
That is really interesting, You’re an excessively professional blogger.
I’ve joined your feed and stay up for in quest of more of your wonderful post.
Additionally, I’ve shared your website in my social networks