What’s Up, CloudFlare?

OK, so today I was doing some routine testing of my sites, basically, to see if there is room for performance improvements.

I do this form time-to-time, normally when I’m having writers block, or need to take a break from programming.

Anyway – several of my sites are cached on CloudFlare’s free plan, I like the idea of them doing the heavy lifting wherever possible for images/js/css/etc. I also love the idea of being able to “flip” over to by backup server without having to wait for DNS to catch up.

PS. I’m yet to have an outage since switching to Digital Ocean – thanks guys!

[yellow-box]Tip: If you’re still using HostGator/BlueHost, consider moving to a VPS – you’ll get much more bang for buck[/yellow-box]

But today I discovered something that gave me pause.. I noticed that one of my money sites in particular was running like a dog. A three legged dog. With a bad back.

Slow Site On CloudFlare
6 seconds? I’m surprised this page is generating me any money at all!

So I started testing, to see what was up with the performance I was seeing. I mean, sure.. there are a bunch of requests there..

But a lot of those were for async javascript (think Google Analytics, Facebook like buttons, etc..) These wouldn’t actually impact the site speed for a visitor, so I wasn’t bothered by them.

But, the fact remained.. the page was slow to load, very slow.

So, I started by disabling every WP plugin on the site – not that it should have mattered, I used the plugins everywhere else..

But the problem remained.. It didn’t make much sense to me, it was hosted on the same server as several other sites that were speedy!

Even administration was painful – clicking around in the WP administration console was just annoyingly slow!

CloudFlare Is Slow?

I made a quick clone of the site to start really messing with it. Being impatient, I just added an entry to my hosts file. I didn’t want to wait for DNS propagation for test.domain.com to happen!

Low and behold, the EXACT same site was speedy! What?

Then I thought…

what if cloudflare was costing me money

I added my site’s server to my hosts file to bypass CloudFlare’s servers.

BAM! Like night and day, the site was very snappy again!

So, I started testing.. and here are the results (using Pingdom’s handy testing tool)

[like-page]

With CloudFlare:

Test Perf Grade Requests Load time Size
1 77 83 6.09 4.8
2 77 83 5.02 4.9
3 77 81 2.11 5.5
4 78 80 1.9 4.8
5 78 81 2.19 4.8
6 77 84 5.12 4.5
7 77 82 4.86 4.8
8 78 80 1.57 4.6
9 91 79 5.46 4.8
10 78 80 2.71 4.8
Mean 78.8 81.3 3.703 4.83
Median 77.5 81 3.785 4.8

Yikes – page load times are all over the place! An average of 3.7 seconds leaves a lot of room for improvement, and importantly.. a lot of money on the table!

Without CloudFlare:

Test Perf Grade Requests Load time Size
1 74 80 2.14 4.8
2 74 81 1.55 4.8
3 74 80 1.51 4.8
4 74 79 1.63 4.6
5 73 80 2.02 4.8
6 75 79 1.54 4.8
7 74 81 1.52 4.8
8 74 80 1.51 4.8
9 74 79 1.47 4.6
10 74 79 1.81 4.8
Mean 74 79.8 1.67 4.76
Median 74 80 1.545 4.8

Wow! Now we’re talking! taking CloudFlare out of the picture cut page load times down to less than half what they were before!

I’ll give you three guesses whether I’ll be sticking with CloudFlare for this site.. 😉

Now – before I get a bunch of hate-mail about CloudFlare, it’s safe to say that busier sites will see an improvement in response during peak load – so there’s definitely a use for CloudFlare.

Additionally, I’ll be keeping CloudFlare for my NS servers – they’re pretty damn fast compared to pretty much everything else I’ve tested.

[yellow-box]Tip: Use CloudFlare for DNS – you’ll gain an easy 50 – 100ms for first-page load time over most hosting companies DNS servers[/yellow-box]

So why do I think CloudFlare is slow? Well, I’m not 100% sure.. but here’s my guess..

CloudFlare have a pretty ambitious goal, of caching content as much as possible, as close as possible to the visitor as possible. And they’re achieving this by using AnyCast.

AnyCast allows multiple servers to answer the same request, with the network picking the “closest” one.

Sounds cool, right? Well, it is really – this is the type of technology that allows sites like YouTube, Facebook and Twitter to be so fast no matter where you are!

But in the cast of a small, relatively infrequently accessed site – this doesn’t work well..

Why Is CloudFlare Slow?

Well, CloudFlare’s edge servers are most likely having to dig around to see if they’ve got an appropriately cached copy of the site.

Then, if they don’t, they need to either:

a) Ask another CloudFlare server if they have one

or

b) Forward the request through to the original site

Now.. remember that this happens for every request, and requests queue up..

So, a request that may take 100ms (Visitor to original web server), may end up taking (hypothetically):

Step Time Action
1 50ms Visitor To CloudFlare edge
2 50ms CloudFlare edge cache search
3 100ms CloudFlare to original server
Total 200ms

Which is about what I’m seeing, roughly speaking..

Now, Am I suggesting you abandon CloudFlare if you’re using them already? Of course not!

Do your own testing, make your own decisions.. But don’t believe the hype that CloudFlare always works 🙂

Take care guys!

[like-page]

About the Author

michael

View Posts →

Leave a Reply

Your email address will not be published. Required fields are marked *