There are several ways to improve the performance of your Drupal website. Here are the Top 10 things that one should check if one’s website does not satisfy in terms of performance.
Plan your modules
This should be the first step while you plan your website to be build it in Drupal. Make a list of modules that you are going to need for developing all the functionality before you actually start building your website. Drupal is all about modules and you have to make a careful selection of modules since, it would make the website slow if you have a number of unwanted modules. So, it’s always a good habit to sort out unwanted modules.
It is best if you stay updated ! Make sure that your Drupal core is at its latest version and also your modules. Updating them to their latest versions keeps you on the safer side.
Have a habit of checking the ‘Reports > Available updates’ section of your Drupal website frequently to find if there are any updates available. Install the updates once you find them.
Default caching feature of Drupal
Drupal has its own caching features. You can improve caching of pages, blocks, CSS and even JS files. They would be fetched from cache instead of reading them each time from the server. You can set your own time for the cache to be retained in admin/config/development/performance.
Memcache has been an excellent choice for caching in Drupal 6 as well as in Drupal 7. It i also well supported and actively maintained module for both Drupal 6 and Drupal 7. Each Drupal module has an ability to write its own cache tables in the database using Drupal’s hook API. Every time a modules runs, it can create more slow queries for reading and writing the cache. Memcache relieves this trouble by storing all these cache tables in memory. This reduces the load time of the pages in a website.
APC (Alternative PHP Cache)
APC is a PHP code cache. It is a ‘install it once and let it do its job forever’ type module. This should be installed in the website’s hosting server. Many Drupal specific hosting providers have APC installed by default.
When you have a lot of anonymous users, this module can save you a lot of server load. Varnish is one of the more popular solutions within the Drupal world. It is an advanced and very fast reverse-proxy system. Varnish can be quite complex to setup, but there are many Drupal focused tutorials. Varnish handles serving static files and anonymous page-views for your site much faster and at higher volumes than Apache, in the neighborhood of 3000 requests per second. This can increase the performance considerably.
When you are on an environment that won’t allow you to use Varnish, such as shared hosting, Boost will work as a great alternative. Boost module caches all the pages, for anonymous users, to flat files. When the page is requested it is loaded a lot quicker, because it is coming straight from the disk and no PHP or MySQL processing is needed.
Caching can be enabled even for views. Each view is able to cache its own results. This cache can be timed according to our need as how long a view should cache its results. This can be found in advanced section of the view.
Using CDNs (Content Delivery Network)
Bad Custom Codes
It is must to follow Drupal’s coding standards while you write custom code to your website. The custom codes must be tested for its performance and it should be replaced with any alternatives available or it should be changed in compliance with Drupal’s coding standards.
Check the database Query runs
When a page or a set of pages take more time to load, it may be due to more number of database queries running when the page gets loaded. This increased query hit may be a result of a bad module or perhaps a bad custom code. It is advisable and a good practice to check the run time of the queries that get fired up when you find a slow loading page.
Better error logging
By default, Drupal logs all errors to the database. Using the module ‘Syslog’ can prevent this as it stores all the error logs in a file.
PHP Filter Module
This is a core module in Drupal 6 and 7 which allows us to add custom PHP code in several places like in block body, views contextual filter, etc. Using PHP codes in the website will take more time for the PHP code to execute which eventually slows down the website. Drupal 8 has removed this module from the core and is available as a contributed module so that you can use it only when it is really in need.
Always use optimized images and avoid using huge images in your website. The images take more and more time to load which will make the site appear to load really slow.
Make sure your database is well-indexed. This is recommended as it will reduce the fetch time when a resource is fetched from the database. This can increase the performance to a certain extent in all cases.