Difference between revisions of "Maximising Performance"

From WHMCS Documentation

(Software Related)
(Software Related)
 
(17 intermediate revisions by 6 users not shown)
Line 1: Line 1:
If you grow to have a large client base then you might start to find page loads begin to slow down. This is to be expected, because the more data you have, the larger the database becomes, and so calculating and looping through the data will naturally take longer. However there are some things you can do to help keep things fast...
+
If you grow to have a large client base, page loads may become slower. This is because the more data you have, the larger the database becomes, and so calculating and looping through the data will naturally take longer.  
 +
 
 +
The following steps can help you maintain faster speeds:
  
 
==Software Related==
 
==Software Related==
  
1. '''Disable Sidebar Stats''' - The sidebar stats in WHMCS are calculated on every page load. Normally this is no problem but when you get big, it can start to take longer.  So to avoid that, simply disable the "Sidebar Statistics" admin role group permission in Setup > Administrator Roles for any roles you use and then the stats won't be loaded.  And all the stats can still be obtained via the actual reports section anyway when you need them.
+
=== Disable Ticket Counts ===
  
2. '''Disable Ticket Counts''' - When you have a lot of tickets, calculating the number of tickets per status to display each time you open a ticket can slow things down. So to avoid that you can disable the ticket counts by adding the following line to your WHMCS configuration.php file:
+
When you have a lot of tickets, calculating the number of tickets per status to display each time you open a ticket can slow things down.  
  
$disable_admin_ticket_page_counts = true;
+
To avoid that, disable the ticket counts by adding the following line to your WHMCS <tt>configuration.php</tt> file:
  
3. '''Logging''' - In WHMCS, there are quite a few things you can enable that will log things such as SQL errors, Hooks loading, Module commands, etc.  You can find these under '''Setup >> General Settings >> Other Tab :: SQL Error Reporting | Hooks Debug''', '''Utilities > Logs > Module Debug Log'''. Ensure that these are disabled when not needed for debugging errors that may occur as they can/will increase the database size exponentially.
+
<div class="source-cli">
 +
$disable_admin_ticket_page_counts = true;
 +
</div>
  
4. '''Large Log Tables''' - WHMCS maintains a number of logs for record-keeping and auditing purposes which are stored in a table within the MySQL database. These logs can become very large, which might cause your installation to slow whilst trying to manipulate a large table.
+
=== Disable Client List Services Count ===
 +
 +
If you have a large number of services, calculating the number of services for each client might increase the load time when you visit '''Clients > View/Search Clients'''.  
 +
 +
To avoid this, add the following line to your <tt>configuration.php</tt> file:
 +
 +
<div class="source-cli">
 +
$disable_clients_list_services_summary = true;
 +
</div>
  
Navigate to '''Utilities > System > Database Status''' and make note of the following tables sizes:
+
=== Logging ===
  
* tblactivitylog
+
In WHMCS, you can enable logging for, for example, SQL errors, hooks loading, or module commands.
* tbladminlog
 
* tblgatewaylog
 
* tblmodulelog
 
* tblemaillog
 
* tblticketmaillog
 
* tblwhoislog
 
  
If any of these tables are particularly large (more than several hundred MB) consider performing some [[System_Utilities#System_Cleanup|system maintenance to prune these logs]].
+
The following settings control debug logging:
  
The tblmodulelog table can be emptied via the '''Utilities > Logs > Module Log''' page.
+
* '''SQL Error Reporting''' in the '''[[Other Tab|Other]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''.
 +
* '''Hooks Debug''' in the '''[[Other Tab|Other]]''' tab at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > System Settings > General Settings''' or, prior to WHMCS 8.0, '''Setup > General Settings'''.
 +
* '''Module Debug Log''' at '''Configuration (<i class="fa fa-wrench" aria-hidden="true"></i>) > [[System Logs]]''' or, prior to WHMCS 8.0, '''Utilities > Logs > Module Debug Log'''.
  
5. '''Hooks/Addons''' - Third party customizations, while a great addition to functionality, can at times slow performance of WHMCS.  Ensure that any customization that you are using is up to date and functionality wise, works with the version of WHMCS you are running.
+
Make sure to disable these when you are not actively debugging an issue, since they can and will increase the database size exponentially.
 +
 
 +
=== Customizations ===
 +
 
 +
Third party customizations can slow the performance of WHMCS.  Ensure that any customization (for example, hooks and addons) that you are using is up-to-date and works with the version of WHMCS you are running.
 +
 
 +
=== Database Backups ===
 +
 
 +
The database backup process can be CPU, memory, and disk intensive while the entire database is exported, compressed, and uploaded or emailed. If performance issues are observed at the same time every day during the database backup process, this could be a potential cause.
 +
 
 +
For more information, see [[Backups#Limitations|Backups]].
  
 
==Server Related==
 
==Server Related==
  
1. '''MySQL Tweaks - ''' When it comes to performance, a lot of WHMCS performance is dependent upon MySQL being set up properly. Especially on larger databases. All changes need to be made to the server's my.cnf file under the mysqld section, usually in /etc/my.cnf (cPanel serves and most others). As a starting point, they may want to set max_connections to a low value like 50 and increase based on their available RAM. Other important setting are:
+
=== Email Provider ===
* '''wait_timeout''' (at least 300, so MySQL doesn't drop connections too soon)
+
 
* '''sort_buffer''' (2-4M seems to be good)
+
Long loading times when performing an action involving sending an email (for example, placing an order, opening or replying to a support ticket, or publishing an invoice) are often caused by connection issues to the chosen email provider.  
* '''read_buffer''' (2-4M seems to be good)
+
 
* '''max_allowed_packet''' (16M is usually fine).
+
To diagnose and resolve this, see [https://help.whmcs.com/m/troubleshooting/l/1261469-troubleshooting-email-sending-problems Troubleshooting Email Problems].
 +
 
 +
Consider switching to an external mail provider such as MailGun, SendGrid or SparkPost, as these are often more performant than SMTP systems. For further information see [[Mail_Tab#Configuring_a_Mail_Provider_in_WHMCS_8.0_and_later|Configuring a Mail Provider]].
  
<div class="docs-alert-info"><i class="fa fa-info-circle fa-fw"></i>In the above values for MySQL, '''M''' means megabytes</div>
+
=== MySQL® ===
  
Once this has been done, restart MySQL and let it run for at least 48 hours. Then you can look into something like MySQLTuner to do an automatic check and see if it makes any suggestions on improvements: http://mysqltuner.com/
+
WHMCS performance is largely dependent on a correct MySQL® configuration, especially for larger databases. Make any changes to the server's <tt>my.cnf</tt> file under the <tt>mysqld</tt> section, usually in <tt>/etc/my.cnf</tt> (cPanel servers and most others).
  
As always with MySQL, the above are just general starting guidelines. Ultimately, the best possible performance will require a thorough review and optimization by a qualified database administrator, but this should at least be a good start.
+
* As a starting point, set <tt>max_connections</tt> to a low value like <tt>50</tt> and increase based on the available RAM.
 +
* When you are configuring this and the following other important settings, restart MySQL and let it run for 48 hours:
 +
** <tt>wait_timeout</tt> (at least 300, so MySQL doesn't drop connections too soon)
 +
** <tt>sort_buffer_size</tt> (2–4 MB)
 +
** <tt>read_buffer_size</tt> (2–4 MB)
 +
** <tt>max_allowed_packet</tt> (16 MB)
  
[[File:Videotutorial.png‎|center|link=https://www.youtube.com/watch?v=CxQoRhefC8U|MySQL Tuning]]
+
=== System Tweaks ===
  
 +
WHMCS is a PHP MySQL script, and so the more RAM or SWAP memory and raw processing power you have at your disposal, the better the performance from your installation. 
  
2. '''System Tweaks - '''As WHMCS is a PHP/MySQL script, by nature the more RAM/SWAP and raw Processing power you have at your disposal will also help with better performance from your installation.  We have our System Requirements set here https://docs.whmcs.com/System_Requirements and do recommend using the higher set values and modules under the '''Recommended Settings''' for best results.
+
* For more information, see [[System Requirements]].  
 +
* We recommend using the higher set values and modules under the '''Recommended Settings''' for best results.

Latest revision as of 12:41, 4 June 2023

If you grow to have a large client base, page loads may become slower. This is because the more data you have, the larger the database becomes, and so calculating and looping through the data will naturally take longer.

The following steps can help you maintain faster speeds:

Software Related

Disable Ticket Counts

When you have a lot of tickets, calculating the number of tickets per status to display each time you open a ticket can slow things down.

To avoid that, disable the ticket counts by adding the following line to your WHMCS configuration.php file:

$disable_admin_ticket_page_counts = true;

Disable Client List Services Count

If you have a large number of services, calculating the number of services for each client might increase the load time when you visit Clients > View/Search Clients.

To avoid this, add the following line to your configuration.php file:

$disable_clients_list_services_summary = true;

Logging

In WHMCS, you can enable logging for, for example, SQL errors, hooks loading, or module commands.

The following settings control debug logging:

  • SQL Error Reporting in the Other tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings.
  • Hooks Debug in the Other tab at Configuration () > System Settings > General Settings or, prior to WHMCS 8.0, Setup > General Settings.
  • Module Debug Log at Configuration () > System Logs or, prior to WHMCS 8.0, Utilities > Logs > Module Debug Log.

Make sure to disable these when you are not actively debugging an issue, since they can and will increase the database size exponentially.

Customizations

Third party customizations can slow the performance of WHMCS. Ensure that any customization (for example, hooks and addons) that you are using is up-to-date and works with the version of WHMCS you are running.

Database Backups

The database backup process can be CPU, memory, and disk intensive while the entire database is exported, compressed, and uploaded or emailed. If performance issues are observed at the same time every day during the database backup process, this could be a potential cause.

For more information, see Backups.

Server Related

Email Provider

Long loading times when performing an action involving sending an email (for example, placing an order, opening or replying to a support ticket, or publishing an invoice) are often caused by connection issues to the chosen email provider.

To diagnose and resolve this, see Troubleshooting Email Problems.

Consider switching to an external mail provider such as MailGun, SendGrid or SparkPost, as these are often more performant than SMTP systems. For further information see Configuring a Mail Provider.

MySQL®

WHMCS performance is largely dependent on a correct MySQL® configuration, especially for larger databases. Make any changes to the server's my.cnf file under the mysqld section, usually in /etc/my.cnf (cPanel servers and most others).

  • As a starting point, set max_connections to a low value like 50 and increase based on the available RAM.
  • When you are configuring this and the following other important settings, restart MySQL and let it run for 48 hours:
    • wait_timeout (at least 300, so MySQL doesn't drop connections too soon)
    • sort_buffer_size (2–4 MB)
    • read_buffer_size (2–4 MB)
    • max_allowed_packet (16 MB)

System Tweaks

WHMCS is a PHP MySQL script, and so the more RAM or SWAP memory and raw processing power you have at your disposal, the better the performance from your installation.

  • For more information, see System Requirements.
  • We recommend using the higher set values and modules under the Recommended Settings for best results.