Simple tips to performance tune your website without professional help

Written by
Shubhra Prakash Nandi's picture

Website speed means a lot today. It affects your SEO, search engine rankings, user experience and conversion rates. But many of us are clueless how to get up to the speed without investing too much in hardware and hosting. The below points will help you tune your website and target the important areas and gain considerably in terms of performance without much sweat and toil. I assume that your website is a dynamic one and utilizes common components like HTTP server, application code written in Java / PHP or other, SQL database.

Given the above the major factors which impact website response times are.

Major contributors

  1. Server hardware - More CPU cores/ CPUs, more RAM, SSD HDDs makes execution much faster. If you can afford more and faster hardware then go for it.
  2. Fine tuned application code - Your application should utilize caching to get frequently accessed objects and avoid hitting the database as much as possible. Use latest versions of runtime engines like latest version of Java or PHP 7 which itself can make your application layer perform much faster without making any code changes.
  3. Reverse proxy caching server - You must utilize a reverse proxy caching server like Varnish to serve pages to non-logged in users.
  4. Fine tuned database queries - Make sure your database tables are properly indexed and your queries are running against indexes only or to the maximum extent possible. Badly written database queries can slow down your webserver immensely.
  5. Use a CDN - If your website serves a lot of media files like images and videos then utilize a CDN. CDN will free up your webserver from serving these files saving a lot of bandwidth and giving better overall experience to your website visitors.
  6. Set correct HTTP headers for static files - Donot forget to set Cache and Expire HTTP headers for your static files like images, CSS, JS, PDF and others. Failing to set these headers will make your user to download these files every time they visit your website. Setting these headers correctly will make the user cache these files locally in the browser for fast access and rendering.
  7. Image optimization - Images form majority of your webpage content and are the largest components in terms of size of your webpage. Make sure your large images are in JPEG format and small ones in PNG format. Also make sure that JPEG images are sufficiently compressed and are progressive.

Medium contributors

  1. Opcache for PHP - If your application layer is developed in PHP then make sure you have switched on Opcache. Opcache can make your PHP application much faster than without it.
  2. Optimize CSS and JS - Try to bundle CSS and JS files in a smaller set of files. Minify them and provide gzipped versions along side plain text versions. Avoid using excessive JS on your web pages. Avoid using social networking share buttons based on JS as much as possible.
  3. Extensions - If your website utilizes extensions to add functionality make sure you donot leave any extension enabled which you donot need. Extensions usually are parsed and loaded in memory for each request and take up memory space and CPU time. Best practice is to uninstall and remove code of all extensions which are not utilized.
  4. Avoid shared hosting - If possible go for a VPS or dedicated server as shared hosting does not scale at all with increasing number of users.
  5. Use updated software - Make sure your operating system and server updates are in place and you are running the most recent stable version of your server and application code and runtime engines.
  6. Enable server side compression - Enable server extensions to send plain text files such as HTML, CSS, JS etc in compressed format to the user.

Minor contributors

  1. Use UNIX sockets if using Linux - For all local servers running on the same machine use UNIX sockets instead of TCP sockets to communicate. Latency of UNIX sockets is considerably lower than TCP sockets.
  2. Use Innodb if using Mysql - Use Innodb database engine instead of MyISAM if you are running Mysql database.
  3. Session handling - Avoid using database for storing and retrieving session data. Instead use default session handling provided by your application layer like file based or memory based.
  4. Use a high performance filesystem - If using Windows use NTFS filesystem and if on Linux use Ext4 or XFS.
  5. Number of files in a single directory - Try and keep number of files in a single directory to less than 10K.
  6. Logs - Avoid storing application logs in database. Store it in files or in a NOSQL storage.
  7. Purge redundant data - Periodically purge redundant data from the database as unnecessary rows will add to look up time and also make insertion of new data slower.

If you have more or better tips to share, do comment below and I will update the article with those ones too!

Credits and attributions

Photo by Taras Makarenko from Pexels

Zircon - This is a contributing Drupal Theme
Design by WeebPal.