CDN Effect on Server Performance

, Content Delivery Network

CDN Effect on Server Performance

Recently, I had a new task to do: a web site with bugs which needed to be fixed and updated. This website was developed to meet millions of requests in just a few days. At first, it doesn't seem like it is impossible to do. But the previous developers had failed to fix the needs and when a million hit came, the server crashed.

My task here was to bring the updates of the site's code to the required level in a few hours.

This web site backend was created with .NET MVC and no other structure was used.

Before making any changes on the code, I started to analyze what the problem could be. I found a few things to fix. The first problem is that, all static assets were stored in the web server, from where the web site is published. It means that the web server had to deal with serving all of these static files. On the home page there were 53 Javascript files (mostly non-minified), 20 CSS (mostly non-minified), 77 images, 5 media files and 6 font files. In total, 5.9MB. These size and file counts are also another fiasco.

I published this web site to Azure Web App (S1) and tested it via Load Test. The test sent 20K users in 5 min to the homepage only. Here are the test results.

Test 1 result

As seen from this report, 97% of 1.471.257 requests have failed.

When I got to the root of the problem, I saw that it was mostly about the "static content". So, I decided to move these contents to CDN (content delivery network) and a separate storage and then tested it again. The tester sent 2.173.109 requests at the same time and 87% of them were successful.

Test 2 result

Using "CDN" and a "separate storage" for "static assets" carry great importance on web performance.

That's it.

I hope this post helps you.

use image4io to optimize your websites' images.