Improving On-Site Performance With PHP Caching
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 APC for Apache and WinCache for IIS. For more information about recommended stack components, please refer to the Supported Platforms page.
- 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
If your instance is running on Apache, you will want to use APC. Use the following instructions to install APC on your server:
- To install APC, you will first need to use either Yum (for Red Hat-based Linux such as CentOS) or apt-get (for Debian-based Linux distribution like Ubuntu) to install the PHP Pear environment on your server, which is a package manager for PHP tools.
Red Hat-based Linux:
yum install php-pear php-devel httpd-devel pcre-devel gcc makeDebian-based Linux:
apt-get install php-pear php5-dev httpd-dev libpcre3-dev gcc make
- Install APC with the following command:
pecl install apc
- After APC has been installed, run either of these commands depending on the Linux environment you are using.
Red Hat-based Linux:
echo "extension=apc.so" >> /etc/php.d/apc.iniDebian-based Linux.
echo "extension=apc.so" >> /etc/php5/apache2/php.ini
- The final step is restart your Apache server.
Red Hat-based Linux:
service httpd restartDebian-based Linux:
service apache2 restart
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.
- After unpacking the package, copy the php_wincache.dll file to the PHP "ext\" directory.
This is typically in C:\Program Files\PHP\ext, but can vary from system to system.
- Use a text editor to open your php.ini (often found in C:\Program Files\PHP ), add the following line, and save the file.
- 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_apc'] = true; // Disables APC $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 APC, 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.
APC Guidelines and Settings
Sugar recommends using the following guidelines and settings when configuring APC for use with your Apache server:
- Use the latest stable version.
- apc.shm size should be close to your program size. For Sugar, that's at least 150 MB (default for apc.shm is 32 MB). When in doubt, more is always better.
- If your installation of Sugar is located on a network filesystem such as NFS or CIFS, make sure apc.stat is enabled.
- apc.ttl should be set to 0. This parameter disables garbage collection and can cause fragmentation. Earlier APC releases had locking issues that made caches with many entries take forever to be garbage collected.
- apc.shm_segments should be set to the default of 1. If you think you really need multiple shm_segments, you must also read the documentation on apc.mmap_file_mask as well and understand and set that value accordingly. If you don't understand apc.mmap_file_mask, you should leave apc.shm_segments at the default value.
- APC ships with an additional apc.php file that, when hit with a browser, will show settings, cache information, and fragmentation. If you suspect APC problems, this is a great tool to start checking things out.
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.
Last modified: 2018-05-18 16:34:47