Simple tips to performance tune your website without professional help

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
- 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.
- 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.
- Reverse proxy caching server - You must utilize a reverse proxy caching server like Varnish to serve pages to non-logged in users.
- 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.
- 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.
- 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.
- 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- 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.
- Use Innodb if using Mysql - Use Innodb database engine instead of MyISAM if you are running Mysql database.
- 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.
- Use a high performance filesystem - If using Windows use NTFS filesystem and if on Linux use Ext4 or XFS.
- Number of files in a single directory - Try and keep number of files in a single directory to less than 10K.
- Logs - Avoid storing application logs in database. Store it in files or in a NOSQL storage.
- 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!
Photo by Taras Makarenko from Pexels https://www.pexels.com/photo/action-asphalt-automobile-automotive-593172/
- Log in to post comments