dennison
By:
dennison

How to use CDN to prevent visitors from reaching your server?

September 19, 2014 4.6k views

Does anyone have any experience with CDN? I have been struggling with traffic spikes lately, which would overload Apache/MySQL and kill the server.

To dip my toes into CDN I have been using CloudFlare's free service, but this hasn't prevented traffic spikes from killing my server.

I have been reading about assigning a separate domain for static content i.e. images ... would this help ease server load? Where can I find more information how to set this up?

Appreciate your help. For reference, the website I am referring to is ASTIG.PH.

1 comment
  • A CDN is ideal to mitigate traffic spikes and also to improve performance. I use DigitalOcean in combination with KeyCDN
    A CDN will definitely take away traffic from your origin server (droplet). As you mention it's common practice to create a subdomain for your static assets (e.g. images.yourdomain.com). This subdomain will then point to the CDN and that's how you offload traffic away from your droplet.

4 Answers

CloudFlare helps. I have used them myself. Have you considered something like Varnish cache?

I am guessing at how to use a separate domain for static content. Since nobody else has answered on the topic, my guess is that you would either have to rewrite your pages to bring in the static content from a separate domain or use a rewrite based on the directories that contain your static content.

by Etel Sverdlov
This article covers how to set up a simple load balancer on a DigitalOcean droplet with nginx. The tutorial covers setting up a round robin loadbalancer that can then direct site visitors to one of a set of IPs

Thanks byte232. I realized that CloudFlare does not cache html files.

I have used Cloudflare, but now I use this cdn service, more effective pricing model for me. I pay only for data transfer.

Have another answer? Share your knowledge.