DigitalOcean - CloudFlare CDN & Self-Hosted CDN

Posted May 4, 2017 15.9k views
NginxDigitalOceanVPNLEMPUbuntu 16.04

Hello Friends,
I’m trying to decrease server response time as per Google PageSpeed Insights recommendation. They’re saying “You should reduce your server response time under 200ms” and my server response time is approx 1.3 seconds. So I decide to make my own self-hosted CDN server by guideline of

I really need to close CloudFlare account?
I can setup my self-hosted CDN without stop using CloudFlare?

Thank you!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers


There’s a relatively large difference between CloudFlare, which uses hundreds to thousands of web servers that are geographically dispersed to various locations across the US and other countries and using a single-server to serve static content from a single location.

For example, using a single server may provide some benefit if all your visitors are coming from one specific location, such as New York. But what happens when someone visits your site from a state or country that’s relatively distant from the data center you’re serving the static content from?

I’m in Tennessee, so content being served from New York isn’t going to impact me – it’ll be quick to serve and I’ll be a happy camper. However, if I lived in California, the response time of the server in New York is going to be much higher than the response time from where I am in Tennessee.

For example, when I ping an IP in the NYC 2 data center, the average is about 38ms – that’s pretty quick. Now when I ping an IP in the in SF 2 data center, the average is about 115ms, that’s 3x slower for me due to distance.

You can setup your own CDN, though the time it’d take to manage a true CDN cluster dispersed across numerous data centers, with GeoIP targeting, would far outweigh the cost of even CloudFlares cheapest paid plan @ $20/site.

DigitalOcean doesn’t have enough data centers to match CloudFlare’s ability to deploy anywhere right now (that may very well change – DigitalOcean is growing fast!), so at best, you have 12x data centers you can deploy to. CloudFlare has 111 right now.

Using only 512MB Droplets, that’s $60/month, not counting the cost of server management and the additional cost of using a DNS provider (such as Amazon) that is capable of handling Geo DNS.

That being said, when it comes to the speed at which your site is served, a CDN is only a small fraction of a percentage.

You need to work on optimizing your LEMP stack, specifically NGINX and MariaDB to start. If you’re able to optimize your code (PHP), then factor that in as well. The default configuration for normal repository packages that you install with apt or apt-get are not optimized for production. They need to be tweaked/tuned according to the needs of your website(s).

If you’re not able to do that, I’d recommend hiring a sysadmin (hey…I’m available :-) - seriously). A CDN, however, won’t be a magic cure all, even if you did setup your own.

The above, of course, excludes other benefits that CloudFlare provides, that you would also need to setup on your own, if you went the self-hosted route. This ranges from Auto-SSL, a degree of DDoS protection, protection for your IP’s, etc (all of which come with the free accounts).

  • Thank you very much for all in-dept information @jtittle. I will seriously take a decision and try CloudFlare CDN premium package soon.

    I notice that you mentioned MariaDB and I’m using MySQL. Soon I will change my database. Here’s my website Google Insights score: click me

    You may check that only front-page is heavy weighted. On Internal pages/posts, I’m not getting errors like decrease server response time.

    If you have any suggestion or idea to get the high score then please share with me. And I will 100% think in future about hire a sysadmin.

    Thank you!

    • @chinmayrajyaguru

      I ran your site through GTMetrix – this is a direct link to the report.

      It looks like your page size is roughly 3.4 MB, which is definitely something I would work on reducing, starting with image optimization. From looking at the report, quite a few of your images could be losslessly compressed and that would reduce the page size by a margin.

      For example, when running this image through took it from 75.48 KB down to 46.06 KB, which is roughly a 39% difference.

      Running the same image through TinyPNG took it from 75 KB down to 26.7 KB, which is even better, with a savings of 65%.

      Since you’re using WordPress, you could take a look at the EWWW Image Optimizer plugin:

      This would allow you to compress images on the server during upload and after by running a batch. That way you’re not physically downloading and re-uploading images.

      Beyond the images, as noted before, I’d look in to hiring a sysadmin to work with you on tuning your stack to get the most out of it. My e-mail is in my profile if you want to get in touch with me and go that route.

@chinmayrajyaguru You might benefit from when it is released. From the makers of

@chinmayrajyaguru the Free Plan of CloudFlare has a CDN for images too?