Notes on CloudFlare
What it is: a free CDN!
What is a CDN? A Content Delivery Network is a service that caches parts of your web site at different points around the world. This makes your web site load faster in foreign countries, and it reduces load on your server, which is really useful if there’s a traffic spike.
Why is it free? Apparently, they started as a honey pot. A honey pot is a trap where you leave something sweet out for spammers and hackers, who will come and try to taste your honey. The honey pot keeps track of where the bad guys are coming from and what techniques they are using, and this data is then analysed to improve security. They also have a bunch of apps they can sell you, and honestly when you’re looking for a paid service for your company, the first thing that will come to mind is the service you already use for your personal stuff.
I personally have never set up a CDN before, but it has always sounded like a pain in the rear. So, I was pleased to see that Cloudflare made it braindead simple: they did a pretty good job of guessing out the contents of my DNS zone file, which I was later allowed to upload in full, then a quick update of my registrar’s NS records and yes, I was using Cloudflare inside of 5 minutes.
How does it work? It basically replaces your world-facing, web-serving A records with its own IPs, which it then answers HTTP/1.1 style. If you need dedicated IPs for SSL, that costs money. You set some A records to go straight to your server, so you can, for example, use SSH. It hands out the same IPs around the world, then magic network routing that I haven’t learned about takes care of the rest.
So, is it faster? Results from just-ping.com look very promising. I see an average latency of 62ms for CloudFlare versus an average latency of 144ms for direct access to my server in Chicago.
An interesting aside, here’s a bit of the just-ping.com output for CloudFlare:
Mumbai, India: Okay 64.1 64.5 67.4 184.108.40.206 Chicago, U.S.A.: Okay 0.3 0.5 1.4 220.127.116.11 Nagano, Japan: Okay 5.5 5.7 6.1 18.104.22.168 . . . Lisbon, Portugal: Okay 58.8 59.1 59.4 22.214.171.124 Chicago, U.S.A.: Okay 1.8 2.3 2.7 126.96.36.199 Dallas, U.S.A.: Okay 1.4 1.6 1.7 188.8.131.52
And for my direct IP:
Mumbai, India: Okay 286.8 288.1 293.1 184.108.40.206 Chicago, U.S.A.: Okay 1.9 2.0 2.5 220.127.116.11 Nagano, Japan: Okay 165.8 165.9 166.1 18.104.22.168 . . . Lisbon, Portugal: Okay 151.1 152.7 153.6 22.214.171.124 Chicago, U.S.A.: Okay 0.2 0.3 0.5 126.96.36.199 Dallas, U.S.A.: Okay 25.3 25.5 25.9 188.8.131.52
This shows two things. First, CloudFlare thoroughly reduces my latency anywhere outside Chicago. Second, and really just interesting for the biggest nerds, just-ping’s first Chicago node is closer to CloudFlare’s Chicago node, and just-ping’s second Chicago node is closer to my RackSpace-hosted Chicago node.
Okay, what about actual page-loading time? Well, I just happened to be doing some basic latency testing last month. Here’s what page load looked like in Google Chrome then:
Here’s what a page load from California looks like just now:
So, a basic test shows that the initial round trips go from 275ms to 136ms, and the total page load time is reduced by about 1/3. Now, the difference between 750ms and 500ms isn’t a huge deal, but the second you step overseas it makes a big difference. Above you see that the latency from my server in Chicago to Lison is 150ms, and 165ms to Nagano, and 290ms to Mumbai. With the latency goggles cranked to 200ms my page load times went from .75s to nearly 2s. So, my web site
feels sluggish for people in Europe or Japan, and frustratingly slow in India. CloudFlare removes that frustration. Now, Mumbai can browse my site as comfortably as I could from California the day before. (Mumbai should be even faster once Cloudflare adds a node in India.)