CloudFlare – The CDN That Saves Your Server!

CloudFlare LogoRecently, I had encountered a bit of a “situation”.

At one of the companies I work with, we have a VPS server that was getting a TON of HTTP traffic.

One website (alone) was sometimes even receiving over 1 million GET requests in a single day. Unfortunately, the “little server that could”, could no longer keep up and started to get its connections and resources pretty darn full.

This comes to no real surprise, however, as the VPS in question had the following (BASIC) hardware configuration…
RAM: 2048MB (guaranteed)
Disk Space: 80GB RAID-10
CPU: 4x Priority
Bandwidth: 5000GB
OS: CentOS Linux
Web Server: NGINX + Apache (Proxy Combo)
Database: MySQL
Accelerator: eAccelerator
PHP Handler: FastCGI (switched from SuPHP)
This configuration, in itself, was pretty optimized (ignoring the fact that Apache was running WITH NGINX). It may be slightly better with PHP-FPM, but I digress. The server could no longer “serve” to all the requests.

Rather than playing the tweaking game to try and allow more simultaneous connections and so forth, I decided to look for a way to offset some of the load. That’s when CloudFlare’s CDN (Content Delivery Network) came into play.

The web pages themselves were dynamic — utilizing WordPress and PHP to create some content that could not necessarily be cached in an optimal manner. So rather than attempting to cache the pages, I looked into caching absolutely everything else: Javascript / JS files, Images, CSS files, etc.

The result? Take a look at the images.

CloudFlare - Requests Saved

CloudFlare - Bandwidth Saved

Yep. That’s right! 4,683,687 requests out of the total 5,223,372 total requests were saved by CloudFlare. This solved the problem being experienced in a BIG way!

And the icing on the cake? 34.2 GB of bandwidth saved by CloudFlare out of the 49.8 GB total bandwidth being served.

Interested in this great CDN? Check out CloudFlare and get one of their free plans if you wish to test them out! It can do way more than just save you bandwidth, mind you. That’s only the tip of the iceberg. For example, it can minify your HTML, JS, and CSS. It can obfuscate email addresses to help prevent spam. It can even help you withstand a DDoS style of attack against your server.


How can you tell if CloudFlare is working?
The best way to see if CloudFlare is in fact enabled, is to view your server’s HTTP headers. Check out Web-Sniffer. There are several signs that show it is enabled. Your “Server” field will have “CloudFlare” as a prefix. For example — “cloudflare-nginx”. Your “X-Cache” should also make this clear with the status of “HIT” or “HIT from Backend”. Additionally, you should have the “CF-RAY” field and maybe even a CloudFlare cookie in the “Set-Cookie” field! If you DON’T see any of these fields, then you may need to wait for your DNS (or web-sniffer’s DNS) to update with your new nameserver info.
My CloudFlare Analytics are blank. Help!
If you are currently showing NO data — do not worry. I encountered the same thing. Rest assurred that data will begin to present itself in the stats. Just like the nameserver update take some time, so too do the Analytics (and in my case, longer than the DNS update). Be patient!
Is Minifying all content safe?
For some websites, minifying your content will result in it not working properly. This is the unfortunate truth of minification. So while it saves some bytes here and there, it may not be worth doing. I recommend experimenting first to see how your website reacts to the whole process.
Help! After switching to CloudFlare, I can no longer access CPANEL!
In all likelyhood, your issue is that all sessions instantly expire when logging into CPANEL and that the panel itself is missing many elements. No worries! There are two EASY ways to access CPANEL error-free (without having to do any configurations with CloudFlare either).

Instead of going to … try

Easy solution, right? And if you don’t want to do it that way, then use the server’s IP address instead:

The IP method is especially convenient for WHM. Please note though that all SSL connections require a paid-for version of CloudFlare and cannot be used with the free version…so mind your HTTPS links.
I use Drupal / WordPress with caching modules / plugins. Can CloudFlare still help me?
Out of the box, Drupal does nice caching already (which is improved upon by additional modules). For WordPress, this isn’t the same case, though the plugins are easily obtained. Despite the caching abilities that these two Content Management Systems (CMS) have, CloudFlare can and WILL benefit you still by at least taking some of the load off your server.

Leave a Reply

Your email address will not be published.