Why I drop using a CDN

Tips Dec 8, 2015

In the first instance, my site was deployed on DigitalOcean, and thanks to the Chinese government I got a fascinating network route.

In this case, I have to wait more than 8 second for a 500kb js file loading. Why don't you just kill me instead.

So I start to use a CDN, and the performance was amazing, you can read All my sites have been deployed on CDN and HTTP/2.0 for more details. Even it was on a CDN, it still cost nearly 2 second to load fully.

But now, my VPS has been moved to Chinese Mainland,  with SPDY and CDN, I found some problems.

If I use a CDN, SSL hand shake would perform twice or more, why I said or more, let's make a list

  • Original server SSL negotiation
  • CDN server SSL negotiation

Where is the third negotiation?

Font rendering will be executed at last since we use a modern browser, the same to favicon.

Sometimes the download of font would ask for a new session (I had tested it on Chrome), which means browser would perform another hand shake with server, just like the picture above (the purple part mean SSL hand shake).

How to solve this problem, I don't know, I know HTTP/2.0 (SPDY) was doing some work on HTTP multiplexing, prioritization, and server push. In some ways I think HTTP/2.0 have a better performance on HTTP multiplexing.

So I tried to move the font file to the original server, fortunately, I did it.

With h2 protocol, the last request don't need to create a new SSL connection.

What's more, sometimes I got a strange TTFB delay, over 200ms. The TTFB value is the DNS lookup time + the initial TCP handshake + the time it takes to receive the first HTML header response.

Since I drop using a CDN, the problem never appeared again.

So, if you'd like to share assets to another domain, you are going to lose all of the benefits of SPDY.

That's why I drop the CDN.


Jie Li

🚘 On-road / 📉 US Stock / 💻 Full Stack Developer / 🎓 Grad Student / ®️ ENTJ

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.