CDN Effect on Server Performance

I recently got a new task to do: a web site with bugs which needs to be fixed and updated. This website was developed to meet millions of request in a few days. At first, it doesn’t seem like impossible to do. But the previous developers 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 start 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. That means the web server has to deal with serving all of these static files. On the home page there are 53 Javascript files (mostly non-minified), 20 CSS (mostly non-minified), 77 images, 5 media files and 6 font files. Totally 5.9MB. This size and file counts are also another fiasco.
I published this web site to Azure Web App (S1) and tested it by Load Test. The test was 20K users in 5 min to the homepage only. Here are the test results.

As seen from this report, 97% of 1.471.257 requests have failed.
When analyzing the details of reasons, I saw most of them are about the “static content”. So, I decided to move these contents to CDN (content delivery network) and a seperate storage and test it again. The tester sent 2.173.109 requests at the same time and 87% of them were successful.

Using “CDN” and a “separate storage” for “static assets” have very critical importance on web performance.
That’s it.
I hope this post has helped you.
Originally published at image4.io on May 7, 2019.