Building a Content Distribution Network to Serve China
Recently we’ve been working hard on developing an ecommerce website that will not only be translated into 7 different languages when complete but also required different page layouts and content for key regions, one in particular was China.
Multi-lingual website support, and even regional variations in content and layout are all relatively easy tasks in comparison to making a UK-based site work in China. The problems start when you use external API’s, like Google’s – which are commonly used for mapping, fonts and JS utilities. It’s fair to say China doesn’t like Google, and so the API’s don’t work, which means the site doesn’t work.
That’s easy to fix by reducing the dependency on those services – but the bit that’s not so easy to fix is the very slow connection speeds!
If you’re in the UK, when you loaded this page you would have received all the content very quickly, the connection time between your computer and our servers should hopefully have been less than about 30ms.
When our client began to test in China we realised that this ‘latency’ between the UK server and China was over 300ms, ten times longer. Not only that there was also packet loss, and just generally slow net connectivity. All of which meant one thing, an unusable website in a key territory.
The solution was to go to Asia! Not literally though (however much I tried to convince my boss)!
We decided that the best solution was to serve Chinese web users from China, meaning a lot lower connection latencies. The easy bit was saying the idea out loud.
Hosting in mainland China is pretty intense, so we looked near by to Hong Kong for hosting, generally Hong Kong is far more liberal in hosting terms, allowing outsiders to freely obtain web services, unlike in China where the web is heavily regulated. Our first idea was to build and ship a server that would mirror exactly the UK server. But that introduces a host of t’s own issues; trust, security, manageability, keeping the systems in sync across mutliple code bases, etc.
Eventually we decided that there was too much risk involved and focused our efforts on an alternative method: building a content distribution network.
We built a system that would detect a (China) user’s request for an asset… say the companies logo, and instead of fetching it from the UK we would fetch it from HK. The HK server would act as a proxy for all asset requests allowing us to rapidly speed up delivery into Asia.
The actual content that the user requests from the HK server is transparently requested from the UK server, once the content had been pulled through a copy is temporarily kept for 24 hours. Which means the first visitor to the site in China has to wait 300ms, but for the rest of the day every other user gets the file delivered locally in a fraction of that time (less than 30ms).
It’s this ‘caching’ that allows us to deliver content quickly round the world without having to ship a server, or have the hassle of keeping several servers in sync. We can rapidly deploy a CDN (content distribution network) server through partner hosting companies in the required country and in a matter of hours be serving content locally in a scalable, manageable and secure way.
The key thing for our client was the reduction of risk – and securing their intellectual property was high on their list of priorities – distributing their code around the world on servers in data centers we have no prior relationship with would have been a very high risk strategy. A CDN allows us to deliver just the low-risk content locally using ‘throw away’ hosting services and to do so without storing the critical IP. Not only is it less risky, it’s also a lot cheaper than trying to physically host a server in these countries.
So now we have a quick website, a happy client and an ever expanding server network, now spanning two continents. We are just left wondering… what country is next?
We always enjoy a challenge, if a content distribution network or a multi-language website sounds like something you might need, get in touch with Kaweb today and let us help you reach your customers more efficiently .