Web Performance Tips #04 - CloudFlare

Those having their own domain should be familiar with domain registrar. It is basically an organization managing the reservation of Internet domain names. Each web server are being assigned with a unique IP. Imaging a user typed in "www.littlecpu.com" on his/her Internet browser. The request will be sent to his/her ISP and the next thing ISP needs to do is to get the IP associated with "www.littlecpu.com". DNS server then comes into action. It will search through its database and return IP address to the user before contacting web server. All these process usually done in miliseconds.

Here comes the problem. If the user is an attacker. He/She will do the same thing and keep on sending request to your web server. This will eventually bring your web server to its knees.

Image courtesy of CloudFlare

CloudFlare is an intelligent DNS service provider in which it is able to detect whether the requestor is coming from a valid or blacklisted IP. If it is from a blacklisted IP, CloudFlare will block the request from reaching web server. Consider it a middle man between your web server and users.


Another advantage of CloudFlare is that it is able to cache static contents such as images/javascript/css files in their cloud server so that your website loads faster. CloudFlare provides you an easy-to-configure interface to optimize your website. For my case, I usually select "Medium" for security profile and "CDN + Basic Optimization" for performance profile. Once you selected one of these options, CloudFlare will take care of other detailed options for you. 


If you are editing your website, you may need to turn off CloudFlare caching so that changes you made on your website will be reflected from your browser immediatley. CloudFlare provides a quick menu in which you can turn on Development Mode or pause CloudFlare. Turning on Development Mode will disable caching while pausing CloudFlare will totoally bypass CloudFlare. 


CloudFlare even provides you page view report. The page views can be further derived into regular traffic, crawlersbots, and threats.

Registration is pretty straightforward. I suggest you to go to www.cloudflare.com and follow instructions from there. Registration is free and I strongly suggest you to go for the FREE plan first unless you are using SSL (e.g. HTTPS) on your website in which you need to pay in this case. Below are general steps:

  1. Create an account in CloudFlare
  2. Add a domain
  3. Provide web server IP (usually for VPS owner) or nameserver (usually for website resized in a web hosting company)
  4. Domain verification. There are some options for you to verify that the domain is actually belong to you. My preference is to upload a HTML file to web server.
  5. Update nameserver information in your domain registrar (e.g. GoDaddy) so that it will point to CloudFlare instead to your web server directly. Nameservers information will be provided during configuration.
  6. Verify that your website is working and the changes and you are done.

Below is a very simple "ping" test on a domain without and with CloudFlare enabled. The first ping is without CloudFlare with the highest ping time of 326ms. Second ping is with CloudFlare enabled and the ping time reduced to 65ms. That's about 5x improvement!


Note: Little CPU does not affliate with CloudFlare and this article is purely experience sharing with readers. 

About the Author


CheeWah (Waco) has more than 10 years working experience in IT fields, especially in software development and testing. Some of the key projects included software development and support for production/R&D, software test automation, and Search Engine Optimisation (SEO). He is a food lover and has a food blog at www.noweating.com. Little CPU acts as his IT knowledge sharing hub.