Technical, Technology

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.

You're sharing IPs now, so HTTP/1.1 will work fine, but you'll need to set aside an A record if you need direct access.

CloudFlare A Records

Configure your A records: orange clouds will be fronted by CloudFlare, grey clouds will go straight home.

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
 Chicago, U.S.A.:	Okay	0.3	0.5	1.4
 Nagano, Japan: 	Okay	5.5	5.7	6.1
. . .
 Lisbon, Portugal:	Okay	58.8	59.1	59.4
 Chicago, U.S.A.:	Okay	1.8	2.3	2.7
 Dallas, U.S.A.:	Okay	1.4	1.6	1.7

And for my direct IP:

 Mumbai, India: 	Okay	286.8	288.1	293.1
 Chicago, U.S.A.:	Okay	1.9	2.0	2.5
 Nagano, Japan: 	Okay	165.8	165.9	166.1
. . .
 Lisbon, Portugal:	Okay	151.1	152.7	153.6
 Chicago, U.S.A.:	Okay	0.2	0.3	0.5
 Dallas, U.S.A.:	Okay	25.3	25.5	25.9

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:

Google Chrome's Developer Tool Network view last month.

Here’s what a page load from California looks like just now:

Page load time from California with CloudFlare enabled.

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 feelsfelt 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.)

Read More

Categories: Technical, Technology

Discover more from dannyman.toldme.com

Subscribe now to keep reading and get access to the full archive.

Continue reading