Jim Westergren
A blog about me, my projects, SEO, Web Development and Personal Development.
"If we did all the things we are capable of, we would literally astound ourselves." - Thomas A. Edison

Why I recommend CloudFlare and why you should try it too

CloudFlare is a both a proxy and a CDN (content delivery network). It was recommended to me by Magnus Bråth.

Quoted from them:

On average, a website on CloudFlare

  • loads twice as fast
  • uses 60% less bandwidth
  • has 65% fewer requests
  • is way more secure

All for free!

Never heard of them? According this recent article on Forbes.com they are getting over 1500 new signups per day and on any given day 25 percent of the Internet’s visitors pass through its network.

I have now tested it for about a week and I recommend them. I am using the free version so far and below I will show you my results.

Stopping spam

The graph below shows that I received around 1000 spam comments per day on this blog (filtered by Akismet) and that CloudFlare cut this down to less than half with the medium security setting. What I really like is that CloudFlare blocks before any request is being sent to the server.

The graph below shows that CloudFlare blocks almost half of the hits to this blog. What is blocked is spam bots, they call it “threats”.

Does CloudFlare block real visitors? No. See the Google Analytics which remains almost the same:

When CloudFlare blocks it displays a CAPTCHA to the user to prove that they are a human. If passed, they are allowed access. So I am not so worried but I don’t want to set my security settings to high.

Now I have also installed a math challenge plugin to cut the spam down even more.

CDN and saving bandwitdh

CloudFlare caches your static content (images, CSS and javascript) and copies it to their different servers around the world. Then a visitor gets the images from the server closest to them (see a map and nice stats here).

I am hosting static content via my domain staticjw.com. It is hosted by a nginx server in Sweden. The subdomains images.staticjw.com and uploads.staticjw.com are pointing to Amazon S3 buckets in which I host images and uploaded files from users of N.nu. I didn’t use a real CDN until now meaning that content from S3 is now loading faster for my users in Sweden and all content loading faster for users outside Sweden.

See the graphs of my server (without the subdomains):

Stats from CloudFlare for this domain + subdomains the last 7 days:

And I did not yet receive any email asking me to upgrade to their Pro version.

Speeding up your website

If you already have optimized your website for speed and you are already using a CDN it might not load so much faster with CloudFlare (like in my case). In fact it can actually in some rare cases load slower if you have a fast server in the same country your visitors are located in and CloudFlare does not have a datacenter in that country. This is due to the extra added latency of around 0,2-0,3 seconds.

Also remember that CloudFlare does not cache HTML, only static content.

Read more about their speed improvements here. If you have not done speed optimization you have a lot to gain here.

Higher uptime

If your server or website goes down CloudFlare will keep it up by showing a cached copy of the HTML. Of course if CloudFlare goes down so do you. But I think CloudFlare has a higher uptime than what you are hosting with now unless you use for example Amazon EC2 or a similar high end solution.

There are some limitations, such as:

In order to trigger Always Online, your web server will need to be completely unresponsive, or return a 502 or 504 HTTP error response code. Always Online will not be triggered for other HTTP response codes, such as 500.

Read more limitations here.

Protection against DDoS attacks

CloudFlare protects you from DDoS attacks by blocking if before it reaches your server. But it might take some days before CloudFlare “learns” that the traffic spike is a DDoS attack and blocks it as shown by this graph of a real world example (not me):

You can however activate the “I’m Under Attack Mode” any time you want, read more here.

Free DNS tool

CloudFlare provides a very slick and easy to use DNS tool for unlimited number of domains with anycast and fast update of records. This alone is worth the signup for me. You can easy put CloudFlare on and off on a domain or subdomain.

Use this PHP code

Because CloudFlare acts as a proxy it will show their IP in the backend. With PHP use this code:

<?php
if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) {
	$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
}
?>

If you use WordPress you can simply activate their plugin.

Conclusion

Give it a try, it just takes a few minutes and there is nothing to install. If you don’t like it you can easily turn it off.

Boomark This! Subscribe to the RSS feed
About the Author Jim Westergren Jim Westergren is a web entrepreneur from Sweden now living in Bolivia. He is happily married and has two lovely children. Some of his interests are web development, SEO and writing. He is the Founder and CTO of TodaysWeb and his current major project is N.nu. Read his . Follow Jim on Twitter or Google+.
  • http://www.sunsetseo.com Magnus

    Great summary, it’s really a fantastic tool and worth mentioning.

  • http://cloudflare.com Damon Billian

    Hi Jim,

    Many thanks for the kind CloudFlare review. Please don’t be shyabout telling us what we can do even better.

  • http://www.jimwestergren.com/ Jim Westergren

    Thanks Damon,
    These are some things that I can think about right now:

    - Enable some kind of cache of HTML. Perhaps with your Pro version. Option to set a cache time, for example a few hours.
    - Improve so you never ever go down. I read a few blog posts that you have had a few problems.
    - A datacenter in Sweden would be nice ;)
    - I have read your blog post about that you do not censor and I guess that perhaps the best but personally I would like that you remove all illegal/porn/hacking/spam that are in your network. I am not sure if my static assets that share the same IP with porn websites can have any ramification for my users or Google.

  • http://www.golfing-usa.net Mary

    I think that this is great. Thanks for all the links and wonderful information. I am always searching the web for good ideas. I hope that you good luck with this.

  • Dan

    Why should you combine amazon s3 and cloudflare?
    Using cloudflare as CDN, isn’t enough to have your static assets stored in a simpe hosting?

  • http://www.hk-r.se Erik

    I’ve been thinking about using CDN on my many websites and this article is a step forward to doing so.

  • Erik_qwerty713

    Hey Jim!

    Very nice site with great tutorials you have here. I have a question about the Cloudflare network and would be very happy for some feedback from you. I have a Swedish site hosted on a web hosting company with servers in Stockholm, they are supposed to have SSD-harddrives, with guaranteed CPU power and RAM-memory. The page is cached and minified and according to pingdom tools from amsterdam it loads in about 0.5-0.8 seconds, I haven’t gotten around to setup asynchronous javascript loading but most other things are pretty well setup I think.

    Do you think such websites as mine will benefit from the Cloudfare network? I mean, visitors will come from Sweden so the server distance is not a problem. The site is low traffic (2k/day) so bandwidth is not an issue.

    Will Cloudflare really improve the page speed in this case?

  • http://www.jimwestergren.com/ Jim Westergren

    I don’t think it will help a lot in this case. But there are other aspects such as more uptime, DDOS protection, and spam blocking for example.

Previous post in category:

Next post in category:

Design, text and custom cache solution by myself.

Page generated in
0.00344 sec