Skip to main content

Should I use CDN or not?

I was doing some comparison of home page loading of my company's website and one competitor's homepage loading. The competitor website loads in a snap and ours take some secs before it shows up. Here are some of the stats from YSlow for mine and competitor's site.










Now as I can see that competitor is making more images/JS then my company's site but it loads in a snap. I can notice three differences
  1. They are using a CDN so images are being downloaded from a local server near Dallas
  2. Their total download size for Java scripts and image are 1/3 then ours.
  3. ours is HTTPS and their site is HTTP. We can't change to HTTP as we cater to SMB and security transmission is a key for us.
I am working with the team to reduce the size of Javascript download and cut it by half. Earlier we were using YUI for tree and ExtJS for table. We recently moved to ExtJS tree as it performs much better then YUI in IE and when you have large no of  children nodes. There are few remaining pieces of code that still rely on YUI so removing them will cut the size of JS download by half. The size of images are also double the size of competitor mainly because our website has went through so many revisions that the sprites are becoming Fatty and we are not removing unused images out of those, plus some stupid decisions by developers to create a new sprite with common images has also caused issues. I had already tried smushing images and got the maximum juice out of them I guess I will have to go through a big cleanup.

But in the interim I am in dilemma to use CDN or not? Even locally within the intranet the home page load is sluggish so it has to be the size of download. Will try to reduce the size of download and see the timings?  If I can match the competitor's Kilobytes downloaded then I can think of using the CDN or not.

Comments

Popular posts from this blog

Killing a particular Tomcat thread

Update: This JSP does not work on a thread that is inside some native code.  On many occasions I had a thread stuck in JNI code and it wont work. Also in some cases thread.stop can cause jvm to hang. According to javadocs " This method is inherently unsafe. Stopping a thread with Thread.stop causes it to unlock all of the monitors that it has locked". I have used it only in some rare occasions where I wanted to avoid a system shutdown and in some cases we ended up doing system shutdown as jvm was hung so I had a 70-80% success with it.   -------------------------------------------------------------------------------------------------------------------------- We had an interesting requirement. A tomcat thread that was spawned from an ExecutorService ThreadPool had gone Rogue and was causing lots of disk churning issues. We cant bring down the production server as that would involve downtime. Killing this thread was harmless but how to kill it, t

Adding Jitter to cache layer

Thundering herd is an issue common to webapp that rely on heavy caching where if lots of items expire at the same time due to a server restart or temporal event, then suddenly lots of calls will go to database at same time. This can even bring down the database in extreme cases. I wont go into much detail but the app need to do two things solve this issue. 1) Add consistent hashing to cache layer : This way when a memcache server is added/removed from the pool, entire cache is not invalidated.  We use memcahe from both python and Java layer and I still have to find a consistent caching solution that is portable across both languages. hash_ring and spymemcached both use different points for server so need to read/test more. 2) Add a jitter to cache or randomise the expiry time: We expire long term cache  records every 8 hours after that key was added and short term cache expiry is 2 hours. As our customers usually comes to work in morning and access the cloud file server it can happe

Preparing for an interview after being employed 11 years at a startup

I would say I didn't prepared a hell lot but  I did 2 hours in night every day and every weekend around 8 hours for 2-3 months. I did 20-30 leetcode medium problems from this list https://leetcode.com/explore/interview/card/top-interview-questions-medium/.  I watched the first 12 videos of Lecture Videos | Introduction to Algorithms | Electrical Engineering and Computer Science | MIT OpenCourseWare I did this course https://www.educative.io/courses/grokking-the-system-design-interview I researched on topics from https://www.educative.io/courses/java-multithreading-for-senior-engineering-interviews and leetcode had around 10 multithreading questions so I did those I watched some 10-20 videos from this channel https://www.youtube.com/channel/UCn1XnDWhsLS5URXTi5wtFTA