CloudFlare

By Jaaap on Wednesday 6 April 2011 16:09 - Comments (6)
Category: -, Views: 8.769

In search of better performance for my website i came across a free service called CloudFlare.

From their site:
CloudFlare protects and accelerates any website online.
...
We automatically optimize the delivery of your web pages so your visitors get the fastest page load times and best performance.
They serve as a CDN for all the content that has the proper cache headers (like expires, pragma etc).
Setup
If you subscribe for the free account, you are guided to a very clear setup process which involves transferring your Domain Name servers to CloudFlare.
Once it's done, the ip of your website changes to one of cloudflare's and content is served from or through their servers.
Performance in theory
If an image or a css file or a cacheable htmnl file has been served by ClioudFlare in the past, it can serve it the second time from its cache.
Since cloudflare uses servers all around the world and routes users based on the shortest route, the latency shoudl be low and (given enought bandwith) the file should be served pretty fast compared to a user on the other side of the world getting the same resource from your 1 server.
For dynamic content the cloudflare system will only add latency because the cloudflare server has to request the resource from its server to your server and only then can it be served to the client.
Performance in real life
My server was pretty fast to begin with. It is located in a decent datacenter in The Netherlands and typical latency within NL would range from 7ms for another fast datacenter 200km away to 200ms for a slow ADSL line.

When the CloudFlare DNS change was finished, the website felt a bit slower. The latency from my home location to the cloudflare server was about 130ms but that wasn't the problem.

The problem was that the latency between the cloudflare server and my server appeared to be around 500ms!
All of my html pages are dynamic in the sense that they should not be cached (not long anyway) so for every request the cloudflare server had to retrieve the html content from my server. The latency the user experienced would therefore be their latency to cloudflare + 500ms.
Google Webmaster Tools
The above is illustrated pretty well by Google Webmaster Tools. They have a nice graph under Diagnostics / "Crawl stats" that shows the latency they experience when crawling your site.
Here's a screenshot:
http://spaghetticoder.org/gwt-latency.gif
Their service was enabled between March 5th and March 28th.
Final Thoughts
If you have mostly well cacheable content and have a slow server or hight latencies for a large part of your users, CloudFlare might be for you.
It is free, and does serve as a CDN and it is relatively easy to setup.

In my case however, my users get better performance when they connect directly to my server.