How Cloudflare works? How Cloudflare differs from other CDN? The advantages and disadvantages of using Cloudflare? When Should a site use Cloudflare?
Cloudflare is a content delivery network that acts as a middle layer between your actual hosting provider and the user browsing your site using your domain’s name.
Taking the example of imtips.co which is on a server with IP address as 126.96.36.199 then Cloudflare will act as a middle layer such that when you type imtips.co in your browser, it will check if you are a real user or not and then it will fetch the content from 188.8.131.52 for you.
How Cloudflare Works?
Below image clarifies how Cloudflare works.
It passes all the traffic that will typically hit your server to go through the filter process of Cloudflare, and only the validated traffic will route to the host.
You can have different security levels based on how and what you term as spammers and hackers that you want to filter out.
How Cloudflare differs from Other CDN?
Content delivery network or CDN is a lot different from Cloudflare in the sense that CDN mirror the complete site from a particular domain/subdomain/subfolder. You can use alternative mirrored CDN url to serve the static content from the CDN.
So imtips.co is my primary domain site. I use Cloudfront as a CDN for my website. So the other url for my site as by CloudFront is
Once you are serving static content from a separate cookieless subdomain, the browser doesn’t need to send extra header information for the static content reducing the packet size of to and fro data transfer speeding up the site’s loading time.
Moreover, the browser can parallelly download the static content making from different URLs.
Apart from that, the most significant advantage of using a CDN is, it serves the content from the nearest edge location A user in India may see content being served from a CDN edge server somewhere in Asia whereas US user may see content being served from a nearby US server making it load faster for the user. So CDN mainly focuses on speed up the site’s loading time.
Cloudflare is different. CDN serves the content faster to the user, whereas Cloudflare filters the traffic and keeps unwanted traffic away from web hosts.
Advantages of Cloudflare
What are the common benefits of using Cloudflare?
Cloudflare is entirely free to get started, whereas other CDN services cost money. Cloudfront by Amazon’s pay as you go option, but still it costs money to use their services.
2. Performance Improvement
As the site traffic is filtered, only genuine traffic passes. So the hosting resources can serve actual users at a better speed. Moreover, Cloudflare also caches the static content and helps them without requesting each time from the host. So the host needs lesser processing to serve the content.
3. Save Hosting Bandwidth
Not all the traffic goes to host. So one can save on the bandwidth that you may waste otherwise to spammers and hackers. Moreover, static content served as cached from Cloudflare will save on the hosting bandwidth as well.
4. Spam Protection
One can filter out the bad traffic and protect the hosting or servers from automated bots and spammers.
5. Accurate Site Analytics
6. DNS Changes are faster
Cloudflare controls your DNS. So when changing hosts, at the most you need to do is change the IP address your old host to the new host. It can complete in minutes instead of 24 to 48 hours one typically may need to wait for DNS changes to propagate.
7. Blocks DoS and DDoS
Cloudflare blocks DDoS and DoS.
DDoS is an attack on the server to send too many automated requests from various locations to bring it down.
If your IP Address is known to the hacker, Cloudflare cannot protect your server from DDoS as the attacker targets IP directly bypassing the Cloudflare. The solution is to change the IP address and use the new IP address only in Cloudflare.
If a site experiences too much of DDoS attacks, it makes sense to use Cloudflare.
Disadvantages of Cloudflare
There are two sides to every coin. Here are some disadvantages of using Cloudflare
1. Extra Layer Between User and Website
Unless your site has decent spam activities and needs protection, or is frequent on the list of hackers with DDoS, I don’t see a reason to add one extra layer of security.
The most significant disadvantages of Cloudflare I have experienced in the past were too many false positives. Many of my users in the past complained of being blocked out. Had to enter captcha to view the site’s content.
With high-security settings, Cloudflare even had issues with owners being blocked out of the site.
Though you can white, list your IP for your site, but if you are not on a connection where IP is static or if you are having a connection where IP changes too frequently (Which usually is the case here in India), you can be whitelisting your IPs most of the time.
3. Host Support for Cloudflare
If your code validates a user based on IP Address, with Cloudflare, your code needs to change the way Cloudflare passes IP.
As user viewing your site isn’t directly connecting to the server. So user’s IP address isn’t directly available in the code the same way as without Cloudflare.
So a web server module needs to be installed for the code to work the same it used to be without Cloudflare.
If you are on shared hosting, you may need to check if the host supports Cloudflare or not though most shared hosts do support Cloudflare.
If you are on Virtual Dedicated Server or a Dedicated Server, you either need to add Cloudflare modules to the webserver (Apache) for code to fetch user’s IP to work fine as earlier or need to update the code to support Cloudflare’s way of fetching user’s IP.
When should One use Cloudflare?
If you are bottle-necked on bandwidth or have too much spam coming your way or have issues with DDoS or have problems with the site getting hacked too frequently, use Cloudflare but not otherwise.
If your host is low quality and has issues with the site load time or site getting offline too often, you can use Cloudflare. It will cache the site. So, mini blips of the website offline can be fixed. Still, I recommend moving to better hosts than to use Cloudflare in such cases.
In short, you should not be using Cloudflare unless and until you have to.
Should You Use a CDN?
Always. Even if you are serving the CDN content from the same domain/subdomain,
- CDN can free up your server from serving static content
- Can serve the content from the nearest location to end-user
- Allow browsers to fetch content parallel to your site’s content.
Readers who read this article also read …