Improving On-Site Performance With PHP Caching
Overview
When running Sugar on-site, it is important to optimize your server to get the best performance possible. In this article we will show you a couple of performance-optimizing options, primarily PHP caching. PHP caching is used in combination with PHP and the web server to build and store dynamic information. This allows for PHP to operate more efficiently. For more information, please refer to the PHP Caching documentation in the Performance pages of the Developer Guide specific to your Sugar version.
While there are various caching options for PHP, we recommend Redis for Linux and Windows and WinCache for IIS. For more information about recommended stack components, please refer to the Supported Platforms page.
Prerequisites
- You have an on-site instance.
- You have admin access to the server hosting your on-site Sugar instance.
- You have experience administrating your web server and installing and configuring stack components.
Steps to Complete
Installing Redis
If your instance is running on Linux or Windows, you will want to use Redis. For more information on installing Redis on your server, refer to the Install Redis page on the Redis website. Please note that PHP may be missing the Redis extension out of the box, but it can be installed using the instructions on this PHP page.
Once Redis is installed, be sure to configure the following config options in Sugar:
$sugar_config['external_cache_disabled'] = false;
$sugar_config['external_cache_disabled_redis'] = false;
$sugar_config['external_cache']['redis']['host'] = 127.0.0.1; // address of the redis server
$sugar_config['external_cache']['redis']['port'] = 6379; // Only required if port different than the default 6379
Installing WinCache
If your instance is running on a Windows server using IIS, you will want to use WinCache. Use the following instructions to install WinCache on your server:
- Download the package from Microsoft's site.
http://www.iis.net/downloads/microsoft/wincache-extension - After unpacking the package, copy the
php_wincache.dll
file to the PHP "ext\" directory.
This is typically inC:\Program Files\PHP\ext
, but can vary from system to system. - Use a text editor to open your
php.ini
(often found inC:\Program Files\PHP
), add the following line, and save the file.extension=php_wincache.dll
- Restart IIS services. WinCache should now be fully functioning.
Disabling External Cache
In server configurations where you have multiple external caches enabled for other applications and services, you may want to ensure only specific external caching is configured for your Sugar instance. To disable one or more external caches, you can edit the ./config_override.php file and enter any combination of the following lines of code:
$sugar_config['external_cache_disabled'] = true; // Disables all external caching $sugar_config['external_cache_disabled_memcache'] = true; // Disables Memcache $sugar_config['external_cache_disabled_memcached'] = true; // Disables Memcached $sugar_config['external_cache_disabled_redis'] = true; // Disables Redis $sugar_config['external_cache_disabled_smash'] = true; // Disables sMash $sugar_config['external_cache_disabled_wincache'] = true; // Disables Wincache $sugar_config['external_cache_disabled_zend'] = true; // Disables Zend
Note: If you are installing Redis, WinCache, or another cache specifically to improve Sugar performance, you should not include the corresponding configuration line from above in your ./config_override.php
. Doing so would prevent your Sugar instance from utilizing the desired caching service.
Other Performance Tips
A final tip is to always make sure that your server has adequate memory and processor processing power to run the operating system, web server (Apache or IIS), Database, and SugarCRM's PHP pages. As the Sugar administrator, you can usually check your running services to determine the overall load on the server. From there, you should be able to determine the appropriate actions to take, whether it be upgrading the server hardware, software, etc.
Note: If you are running an on-site instance, we have an XHProf tool that can help profile the performance of PHP pages within your instance in more detail. For more information please, reference the PHP Profiling documentation in the Application Framework and Performance pages of the Developer Guide specific to your version of Sugar.