CDN vs VPS

Mouth

Well-known member
If the majority of your users/visitors come from from one geographic country, how much better is a CDN compared to getting a VPS as close as possible to those users?

I've been researching the CDN providers, but am finding it difficult to pinpoint exactly where a CDN service had it's servers located - what point is a CDN if it's closest servers are in a different country or continent?

So then I started to think about a VPS on a good backbone right in the heart of where the majority of my sites userbase is - that would be just as good, if not better?

Note: I cannot even come close to affording to have the main server close to the main userbase. Local server hosting/charges are gigantic, and data charges even worse :(

Is this sort of thinking accurate, or am I missing something?
 
Our host actually offers both. We have a VPS from thm, and can optionally get a CND to compliment it.

In our case, the CDN hosts images and the javascripts :)
 
Hey Mouth - great to see another Aussie XenForo user here.

I face a similar problem with my forums, I ended up using both.

Most of my sites are Australian-centric, so I wanted them hosted as close as possible to here - but as you said, local VPS is prohibitively expensive.

I ended up going with Linode for my VPS - my Australian based sites are hosted in Tokyo. I tested all of their server locations and found that Tokyo was by far the fastest from most ISPs in Australia.

To further enhance performance, I use Amazon S3+Cloudfront to host static files (images / JS / etc). They now have an edge-location in Sydney.
 
My forums aren't slow now - but every site could do with putting static content closer to their users without it having to traverse the pacific every time it's requested :)
 
  • Like
Reactions: DRE
My forums aren't slow now - but every site could do with putting static content closer to their users without it having to traverse the pacific every time it's requested :)

How much time it takes to travel around the globe? 1-3 seconds at most?

Most of the static content is cached by browser on first load. So why you need CDN for it if you have fast loading websites near to your audience?

For some reason, I feel CDN is sometimes over hyped. That being said you site really loaded fast for me.
 
  • Like
Reactions: DRE
1+ seconds is an eternity for user experience. Makes a site feel very sluggish if you have to wait that long for things to start loading in the browser.

Ideally you want < 200ms to make site response feel snappy.

First visit load times are critical for engagement with the site and for SEO ... Google now measures these things and penalises slow sites.

I believe Amazon did some studies on their own website on load times and found that even a 100ms delay in load times lead to a dramatic drop in sales. Similarly, Google found that adding more search results to a page (at the cost to a 500ms delay in load times) resulted in far fewer searches being performed, and a substantial drop in revenue from search traffic.

Here is a page that summarises some of the reports about page load times (see reference links at the bottom of that page for sources).

Page load times and responsiveness do matter.
 
To further enhance performance, I use Amazon S3+Cloudfront to host static files (images / JS / etc). They now have an edge-location in Sydney.

Oh cool, finally a .au cloudfront location.
Thanks, I'll take a look!
 
To further enhance performance, I use Amazon S3+Cloudfront to host static files (images / JS / etc). They now have an edge-location in Sydney.

Has someone created a tutorial (hint hint) on how exactly to set up Amazon S3+Cloudfront and use it with XF?
 
Has someone created a tutorial (hint hint) on how exactly to set up Amazon S3+Cloudfront and use it with XF?

I just did it, took around 5 minutes :)

Steps:
1. Go to aws.amazon.com and activate the Cloudfront service. Configure it so that your origin is your existing XF site URL
2. Using the domain name that Amazon assigns to you from the above step (eg.abc123zyx987.cloudfront.net), add the x2 below entries at the bottom of your library/config.php file (replacing 'abc123zyx987.cloudfront.net' for your .cloudfront.net domain name).

Code:
// CDN support
$config['externalDataUrl'] = 'http://abc123zyx987.cloudfront.net/data';
$config['javaScriptUrl'] = 'http://abc123zyx987.cloudfront.net/js';

Voila!
 
I just did it, took around 5 minutes :)

Steps:
1. Go to aws.amazon.com and activate the Cloudfront service. Configure it so that your origin is your existing XF site URL
2. Using the domain name that Amazon assigns to you from the above step (eg.abc123zyx987.cloudfront.net), add the x2 below entries at the bottom of your library/config.php file (replacing 'abc123zyx987.cloudfront.net' for your .cloudfront.net domain name).

Code:
// CDN support
$config['externalDataUrl'] = 'http://abc123zyx987.cloudfront.net/data';
$config['javaScriptUrl'] = 'http://abc123zyx987.cloudfront.net/js';

Voila!
Thank you. I see that your avatars and image attachments are coming from cdn.netrider but your logo and header background images are being served from your server. How does Amazon know which to serve via Cloudfront?
 
How does Amazon know which to serve via Cloudfront?

Cloudfront serves anything you request from it, basically.

The 2 lines in config.php tell XenForo to return to the client browser anything it is retrieving from /data/* and /js/* to come from your CDN instead. It would be great for XF to add a third line to be able to deliver static images from within /styles/* too. Presently, it's just the two (/js and /data). I will possibly edit my CSS and templates shortly so that the logo and bg images come from CDN too.
 
It would be great for XF to add a third line to be able to deliver static images from within /styles/* too. Presently, it's just the two (/js and /data). I will possibly edit my CSS and templates shortly so that the logo and bg images come from CDN too.
(y)

xf.webp
 
So Cloudfront has basically grabbed your entire site and then XF just requests what it wants from it?
Seems like a lot of waste for Amazon to store everything when you are only using a portion.
 
So Cloudfront has basically grabbed your entire site and then XF just requests what it wants from it?
Seems like a lot of waste for Amazon to store everything when you are only using a portion.

No, think of CloudFront as a globally dispersed proxy server. If a browser requests an object from CDN (as directed by your site), then the CDN will deliver from it's local storage. If it does not have it, then it will retrieve it from your server (origin). The CDN only retrieves the object from your server when it's requested by a browser, and it does not already have it. I doesn't 'mine' or 'scrape' your site looking for content, only specific objects a browser requests.

Then add in some cache expiry control for being able to designate how often the CDN should refresh from your site.
 
Wow. The toughest part was navigating the AWS site...
Created and everything is working fine. I then made my logo served from CF as well as some custom forum description images that load on my forum home. Using Tinthe Image Attachment Optimization and also utilizing the CDN feature has every one of my image attachments on the edge servers. Can't wait til I see the bill next month :)
 
Mouth, Have you created CNAMEs to clean up the cloudfront urls?

Yes, worked fine for me.

Did you enter cdn.survivalmonkey.com into CloudFront in the Alternate Domain Name (CNAME) field?
I don't see a CNAME entry for cdn.survivalmonkey.com at your NS1.survivalmonkey.com though. Won't work if DNS lookup for cdn. fails ;)
 
Thanks. I removed the CNAME after thinking I had it wrong. I just added them back and will wait awhile and check again.
 
Top Bottom