This article will outline some of the strategies to improve the performance of your website. Before delving into the article I would like introduce my experience in web development. I have worked on more than 20 public facing websites of which majority of them are e-commerce websites.

Here are the tips to tune your website.

Load Balancing

“Chair needs all legs to load balance. Don’t miss the big picture. Don’t make the sessions sticky.”

The basic and most important requirement is to load balance the site so that traffic can be distributed among a set of servers to process the request faster rather than sending all requests to one server and wait until it reaches peak CPU and memory usage. Whenever load balancing is implemented for a website the most obvious bug in application that gets exposed is the use sticky sessions. Session management should be moved to back-end database and sessions should not be process specific or machine specific. Before doing load balancing for a site it is important to understand how sessions are handled by the website. One other problem found during load balancing is that not all dependent applications are load balanced and not all layers of the application are load balanced. Load balancing is really an enterprise architectural task.

Resource Optimization

“Minification of text files. Dynamic resizing of images. Multiple video resolutions.”

The more the bytes to download the longer the download time. Websites use various assets like Videos, Images, Stylesheets, JavaScripts, SVG files and others. One of the strategies to minimize the download size of these assets is Minification. Minification is the process in which text based assets can be stripped of white spaces and unnecessary characters in the file there by reducing the file size. Advanced minification tools provide features to shorten variable names and method names this will be needed if your js or css files are huge. Images can be resized dynamically based on the display size needed. This will help reducing the download time of images. If an image is huge and it has be shown only on some client side event (like zoom event) then try to download the image in the background. It is better to have videos in various resolutions so that the best format for the device can be downloaded or streamed instead of downloading one huge size video file. If you are embedding YouTube videos on your site it is better to specify the resolution based on the client device.

Request Optimization

“Bundle the assets. Move assets to sub domains. Download assets in background.”

One of the standards followed by browsers is that it will send only a finite number of concurrent http requests for one (sub)domain in the range of 2-8. If a web page is using 10 css files the browser will issue 5 http requests and wait for it to download the first 5 css files before sending another 5 http requests to download the next 5 css files. One of the ways to minimize the number of http requests is to use bundling feature. The bundling feature in web programming framework zips a group of files and gives them a bundle name. The page can issue one http request and download all the files as a single zip file. Another way to optimize requests is to move the assets like images, css etc to a subdomain and the page reference assets from this subdomain. Remember that limitation in the number of concurrent connections is per (sub)domain. You can have multiple sub domains like to render just images, to render just videos that way you can increase the number of concurrent connections to do parallel downloads.

Content Delivery Network (CDN)

“Load static content to CDN. Caution while caching dynamic content.”

One other strategy to load balance your site is to use content delivery networks like Akamai, Azure etc. The CDN providers have servers geographically distributed and you can load your static assets like images, css, js files to CDN domain there by they are available in a wide network and the users will be downloading your assets from the nearest CDN server or optimal point of download in the CDN network. This relieves some CPU cycles in your server that can be used for execution of code. It is better to use CDN to deliver static content even though it can cache dynamic content and deliver that cached content. Most of the websites cache their entire home page in CDN along with the assets used by the page so that the users get a good first impression about the site. The downside is that if the page uses query string parameters whose combination can yield 1000s of versions of home page the CDN caches all of them and this increases your billing. If you are planning to use CDN to deliver dynamic content then avoid using query string parameters and other features that creates too many versions of the page.


“More hits. Cache must be distributed.”

Caching is the easiest and most valuable feature when it comes to improving the performance of the website. Caching can be done to any area of the website starting from data to files. For example: If your database stores list of countries and states let the web application retrieve that list once and store it in the server in memory. The list of countries and states do not change that frequently (assuming the world lives united). Large scale caching is now supported using memcache and other frameworks.

I hope this article helps you to optimize your websites for better performance.

Credits and References

  • The websites I worked on.
  • Peer learning.
  • MSDN