« Back

AlloyUI and the importance of CDN

Company Blogs March 4, 2013 By Zeno Rocha Staff

Some weeks ago we announced the preview release of AlloyUI 2.0. One of the cool things about it is that now we have a pretty new CDN (Content Delivery Network). So instead of downloading AlloyUI to use in your local environment, you just to need copy and paste this line of code and start using it.

	<script src="http://cdn.alloyui.com/2.0.0pr2/aui/aui-min.js"></script>

But it was only available for AlloyUI 2.0, which is not integrated with Liferay yet, then Liferay community wouldn't benefit from it.

That's why today we have some news to share, all versions of AlloyUI are now available on CDN to use in production or to download as a zip file \o/

PS: Check this table if you don't know which version is being used by Liferay.

 

Why it's so important to use a file hosted on a CDN?

Basically for performance improvements, we'll dig into some of them.

 

Decrease latency

Let's say you are in China and your server is in Los Angeles. When you load a file the browsers sends a HTTP request that will go across the globe until reach your server and, as you can see, it takes time.

However if this file is hosted on a CDN it will be distributed across many different servers in the world. So when you make a request, it will look for the nearest server, which decreases latency time a lot.

Wikipedia: (Left) Traditional scheme of distribution - (Right) CDN scheme of distribution

 

More parallel downloads

Browsers can't handle too many parallel downloads per domain.

That's why hosting files in different domains is a good performance tip.

 

Cache

Let's say you visited a website that uses AlloyUI hosted on CDN, as soon as you load it your browser will automatically cache it in your machine. Then if you visit another website that uses AlloyUI too, you don't need to download all those files again because you already have cached them.

 

What's the real benefit?

Let's try those performance improvements in real life. My experiment will load the exact same file using a CDN and don't using it.

Didn't use CDN:

When you load this file, that is not hosted on a CDN with a 10mb internet connection, you take 1.27 seconds with 404ms of latency.

Use CDN:

But when you load this file, that is now hosted on a CDN with the same internet connection, you take 314ms with 155ms of latency.

That's a 75% decrease and this is only one file!

Now imagine a lot of modules and its dependencies being loaded, it will cause a significant difference.

 

Conclusion

And that's all folks! If you have any questions please comment below :)

Threaded Replies Author Date
That was a wise choice, Zeno! Let's make it not... Cleydyr de Albuquerque March 4, 2013 11:59 AM
Exactly Cleydyr! Zeno Rocha March 4, 2013 3:15 PM
Once AUI2 is loaded, will it have a confliction... Neil Jin March 5, 2013 6:34 AM
Yeah, it will probably cause a conflict. Soon... Zeno Rocha March 6, 2013 5:12 AM
Has anyone here tried loading 2.0 via CDN over... Joseph Cook April 10, 2013 8:31 AM
It will probably break almost everything. We're... Zeno Rocha April 11, 2013 10:13 PM
Hi Zeno, how about the https CDN when that is... Sampsa Sohlman March 9, 2013 2:12 PM
Hey Sampsa, We're discussing that:... Zeno Rocha March 18, 2013 6:37 AM
Excellent Job team! Shagul Khajamohideen March 12, 2013 6:18 AM

That was a wise choice, Zeno! Let's make it not only simple and sexy, but also lightning fast to load wherever it is used.
Posted on 3/4/13 11:59 AM.
Posted on 3/4/13 3:15 PM in reply to Cleydyr de Albuquerque.
Once AUI2 is loaded, will it have a confliction with preloaded AUI library in LiIferay?
Posted on 3/5/13 6:34 AM.
Yeah, it will probably cause a conflict. Soon we're going to migrate Liferay to AUI2 emoticon
Posted on 3/6/13 5:12 AM in reply to Zhao Jin.
Hi Zeno, how about the https CDN when that is coming?
Posted on 3/9/13 2:12 PM.
Posted on 3/12/13 6:18 AM.
Hey Sampsa,

We're discussing that: https://github.com/liferay/alloy-ui/issues/25
Posted on 3/18/13 6:37 AM in reply to Sampsa Sohlman.
Has anyone here tried loading 2.0 via CDN over say a 6.1.1 install? If so, how bad were the conflicts?
Posted on 4/10/13 8:31 AM in reply to Zeno Rocha.
It will probably break almost everything. We're working on it Joseph, soon AlloyUI 2.0 will be available under 6.2
Posted on 4/11/13 10:13 PM in reply to Joseph Cook.