Distributing Content via CDN
The most requested Invoicebus files from now on are delivered via Akamai CDN at blazing speeds, improving the overall performances, while reducing the load time
In one of the previous posts, we described how we host the Invoicebus site and introduced the term Cloud Files and CDN (Content Delivery Network). Because the user base of Invoicebus constantly increases, we decided to deploy the most common content on Akamai CDN, so the users can feel the turbo charge of the bus
Let’s assume visitors are coming from 10 different countries all over the world: United States, Canada, Mexico, United Kingdom, Germany, France, China, India, Australia and Philippines. For the example, we will take India in particular.
The primary web server of Invoicebus is located in Chicago, Illinois, US in the ORD1 Datacenter of Rackspace. That means all requests should be propagated thorough dozens of routers around the world, so the package from India can reach the server in the US, and then return way back home. Transferring such data over TCP/IP (read Internet) from India to US can take a while, even though this time is very short and usually expressed in milliseconds. However, when we multiply this time with the total number of requests, the delays can be drastic.
There’s a chance some packages to be lost on long distance routes, so resend will be needed, increasing the overall transfer time. There’re also other factors like intercontinental network congestion during busy hours that contribute for these delays.
That’s when CDN comes in game.
So when you deploy your files on CDN, the content will be retrieved from different servers in that CDN network all over the world. That means the users from India will request the files from the local cache in the nearest geo-located CDN server, and not going all the way to US. That’s why the content can be retrieved goddamn fast, leaving the primary server less engaged, so can easily deal other jobs.
We tested all pages from Invoicebus site, but to simplify the post, we will describe what happened with the login page which actually is pretty lightweight with only 160KB, including all the code, images, CSS and JS.
What we put on CDN from that page was the bus mascot image, a few JS scripts and the global CSS file, or to be precise we distributed content of 102.6KB in total.
Here’re the results of page load time:
Our plan is to optimize the whole app even more, so everything loads blazing fast, nearly as a native desktop app. Please let us know if you have any suggestion or request, we would like to hear from you. You can reach us on twitter whenever you like. We’re always by our laptops so will get you back in seconds.