Geared for Speed

Online competition is so intense that any e-commerce company that fails to deliver a fast site can forget about winning in the marketplace. The consumers are simply too impatient with slow-loadinng sites!

Web performance measures the speed with which a site's pages are downloaded and displayed in a browser. Web performance optimization is a field of knowledge that looks at all the ways a page can be displayed faster. In this blog post, we will cover both the front-end techniques as well as back-end techniques.

  • File Compression
    These days most web servers and browsers support automatic compression and decompression of files respectively. As part of the compression process, HTML and CSS files are first compressed and then sent over the wire. This reduces the time it takes to download the page since the page size is now smaller. A typical file compression algorithm reduces the file size to 20% of the original size without any loss of data. If certain amount of data loss can be tolerated, such as while rendering big images or audio files, lossy compression algorithms can be used. Images should be optimized for the web since the user is not going to notice a small reduction is quality that reduces the image sizes substantially.
  • Caching Using Reverse Proxies
    Reverse proxies such as NGINX or Varnish can cache frequently-served content for a defined amount of time. The advantage of reverse proxies is that the request does not reach the web server, thus reducing loads on HTTP servers and database servers. A cache like Varnish can be very fast, reducing the response times to under a second. Getting Varnish properly configured to serve a site is difficult, but the rewards are worth it.
  • Choosing the Right Host
    The right host is a necessity, since there is so much variation in the quality of hosts. You also have to choose between Linux and Windows operating system. If your content management system runs on PHP and MySQL, you are more likely to choose a Linux-based host. If, on the other hand, your CMS relies on ASP and SQL Server, then a Windows-based host would be a right choice. Whichever operating system that you choose, make sure that your hosting company provides you with plenty of processing power and RAM. Having your database server run on a separate machine than your web server is also a good practice.
  • Database Optimization
    How to optimize databases is a very large topic that is beyond the scope of this blog post. Suffice it to say that it takes an experienced DBA to tweak queries, create indexes for faster access, and generally make the database design more efficient. You can also deploy read-only replicas of your database to alleviate the load on the "main" database. If your site is not serving content that is individualized for each user, let's say an online newspaper site, then you can deploy a caching layer such as Redis. If frequently-accessed data is stored in Redis, it saves a trip to the database server.
  • Proper Monitoring
    All your web infrastructure needs to be monitored 24x7. You must know what your usual usage patterns are, so that any deviations from that pattern can be observed and addressed quickly. If you are using cloud-based IaaS provider, such as AWS or Azure, you can take advantage of auto-scaling that is triggered by changes in the load patterns. This is a very powerful mechanism to deal with load spikes.