Need Quality Code? Get Silver Backed

Better, Faster, Stronger - Why you should use a CDN



by Gary H

My crown is called content, a crown that seldom kings enjoy

William Shakespeare

If you're a regular visitor of the Leaping Gorilla site then you may have noticed some major improvements in speed over the last few days. That's because we've updated our site to use Amazon CloudFront - a Content Delivery Network (CDN).

What is a CDN?

A CDN acts as a middle man between your server and your users. A good CDN will take content from your servers and cache it in edge locations dispersed around the globe. These are located closer to your users so can serve the cached content faster than it would take for a full trip to your servers.

Lets take an example of retrieving a page from the Leaping Gorilla site without a CDN. Here's a typical trace route to get the home page:

TraceRoute to []
Hop	(ms)	(ms)  (ms)	IP Address	    Host name
1 	 0 	  	0 	  0	    xe-5-3-0.edge.dallas.level3  
2 	 127 	126   126	vlan70.csw2.dallas1.level3  
3 	 129 	129   129	ae-73-3.ebr3.dallas1.level3  
4 	 129 	130   129	    ae-7-7.ebr3.atlanta2.level3  
5 	 129 	128   128	    ae-2-2.ebr1.washingt.level3  
6 	 129 	130   130	ae-7-7.csw2.washingt.level3  
7 	 131 	129   129	ae-2-72.ebr2.washngt.level3  
8 	 130 	130   130	    ae-41-41.ebr2.paris1.level3  
9 	 130 	130   130	ae-2-12.bar1.dublin3.level3  
10 	 130 	130   130	 -  
11 	 130 	131   130	 -  
12 	 132 	144   132	 -  
13 	 132 	132   132  

As you can see, the request gets bounced around numerous servers as it moves through the internet to the Leaping Gorilla site. each of these hops adds latency to the request (more time for your user to wait) and dont forget this is just to retrieve the initial page. The browser will then need to get all of the resources - CSS, JavaScript, Images etc. that the page requires to render.

CDN to the Rescue

By using a CDN we eliminate all of these lookups. We change our DNS records to point at the CDN CNAME. When a user requests the Leaping Gorilla site now they instead get redirected to the nearest edge server for the CDN. If the page that they requested has been cached this will be immediately served back - we wont even hit the server! If it hasn't been cached the edge location will use an optimised path to pull the page from your server and distribute it to the user.

How much of a difference can this make? Let's take a look at a traceroute for the Leaping Gorilla home page with a CDN enabled:

TraceRoute to []
Hop	(ms) (ms) (ms)  IP Address		Host name
1 	  1    0    0	  	xe-5-3-0.edge3.dallas1.level3  
2 	  0    0    0	  	ae-1-60.edge2.dallas1.level3  
3 	  0    1    1	   	  -  
4 	  0    0    0  
5 	  0    0    0	server-54-230-120-44.cloudfront

We go from 15 hops to 5 and just look at the difference in latency! We're using our CDN's dedicated infrastructure for the lookup so it happens over blazing fast dedicated connections.


The benefits to Leaping Gorilla have been huge. We've gone from a very troubling load time of up to 6 seconds per page when accessing our EU servers from the USA to under 300ms. Also, whilst the content is served from the edge it means that it doesn't hit our server reducing load and enabling us to serve more requests with less infrastructure.


Nothing comes for free, so how much does it cost? So far - peanuts. We're looking at a monthly bill in the single digit dollar range. On tests with our clients we've been able to deliver a 10x improvement in page load from remote geographical areas whilst serving ~100GB of data/month for around $75. The kicker to this though? The edge locations reduced load on the main servers enough that we were able to thin out the server farm resulting in a net gain to the client.

I Want One!

If you are interested in setting up a CDN yourself then we would heartily recommend you use the CloudFront documentation as a starting point. If you would like our help to do this then feel free to contact us for a quote.

News , Performance , AWS

Comments are Locked for this Post