Optimize Synology DSM for ZurmoCRM


It’s not easy to install ZurmoCRM and that’s why I encourage to Test your ZurmoCRM with VirtualBox. You need to manually edit configuration files before setup on Synology DSM.

This post will be updated when I found more optimization in the future.

DSM 4.3

It provides Alternative PHP Cache which may accelerate LAMP by caching and optimizing PHP intermediate code and Memcached which is an interface to memcached. memcached will cache database result and lower database loading in LAMP.

ZurmoCRM default uses Memcache not Memcached. You need to edit configuration to enable support for Memcached.

  1. Increase memory_limit in php.ini to 256.
  2. Increase max_execution_time in php.ini to 2000.
  3. In [Control Panel]→[Web Services]→[PHP Settings] tab, Enable PHP cache and select to enable following PHP extensions: mcrypt, memcached, and optional ldap.
  4. Increase apc.shm_size in apc.ini to 64M with 1GB and 128M with 2GB installed.
  5. Execute or create a shell script to load memcached automatically during startup. Use -m 128 for 1GB and -m 256 for 2GB installed. Then follow Enable Memcahed after Installation to manually enable Memcached.
memcached -u root -l 127.0.0.1 -P 11211 -m 128 -d

Use ps | grep memcached to confirmed it has been loaded into memory.

Enable Alternative PHP Cache after Installation

It is default on. There is no need to change after you enable Alternative PHP Cache.

If you are not comfortable with the performance, check the [where you installed ZurmoCRM]/app/protected/config/debug.php file and look for $phpLevelCaching. It should be true by default.

Unless you need to disable Alternative PHP Cache during debug, please keep it true.

Enable Memcahed after Installation

Edit the [where you installed ZurmoCRM]/app/protected/config/perInstance.php file and fill in memcached information. It should match to parameters to launch memcached.

$memcacheServers  = array( // An empty array means memcache is not used.          
                        array(                                                        
                            'host'   => '127.0.0.1',                                  
                            'port'   => 11211,  // This is the default memcached port.
                            'weight' => 100,                             
                        ),                                                         
                    );

Edit the [where you installed ZurmoCRM]/app/protected/config/debug.php file and change $memcacheLevelCaching to true to enable.

Edit the [where you installed ZurmoCRM]/app/protected/modules/zurmo/components/BeginRequestBehavior.php file and change public function handleApplicationCache($event) as highlighted by bold.

public function handleApplicationCache($event)                                
        {                                                              

            if (MEMCACHE_ON)                                
            {                                                                
                //Yii::import('application.core.components.ZurmoMemCache');            
                $memcacheServiceHelper = new MemcacheServiceHelper();              
            //    if ($memcacheServiceHelper->runCheckAndGetIfSuccessful())        
                {                                                            
                    $cacheComponent = Yii::createComponent(array(          
                        'class'     => 'CMemCache',                        
                        'keyPrefix' => ZURMO_TOKEN,                        
                        'useMemcached'=>true,                                       
                        'servers'   => Yii::app()->params['memcacheServers']));     
                    Yii::app()->setComponent('cache', $cacheComponent);        
                }                                                              
                // todo: Find better way to append this prefix for tests.                 
                // We can't put this code only in BeginRequestTestBehavior, because for API tests we are using
                if (defined('IS_TEST'))                                                                       
                {                                                                                             
                    ZurmoCache::setAdditionalStringForCachePrefix('Test');                                    
                }
            }                                                                                                 
        }

The $memcacheServiceHelper->runCheckAndGetIfSuccessful() calls runCheckAndGetIfSuccessful() in [where you installed ZurmoCRM]/app/protected/modules/install/serviceHelpers/MemcacheServiceHelper.php to check if Memcache has been load.

If you don’t want to skip checking and preferred Memcached, change the following code marked bold in [where you installed ZurmoCRM]/app/protected/modules/install/serviceHelpers/MemcacheServiceHelper.php to force checking for “memcached” instead of “memcache”.

if (extension_loaded('memcached'))

You may use the System Diagnostics in [Administration]→[Developer Tools] to test if it may pass the check for Memcache. I plan to commit extra codes to simplified the use of Memcached in 2014 March.

On my DS214SE, it takes 34 seconds to display one contact in detail without Memcached and shrinks to 10 seconds if you enable the support.

Don’t forget to load memcached before use.

Notes

  1. Size for apc.shm_size and memcached may vary depends on systems environments and usage scenario.
  2. If you use less than 900 in max_execution_time, you might fail to install demo data. You may set it to a smaller number than 2000 after installation.
  3. If you are looking for files, please read Synology DSM Configuration and Executable Files.

Reference

  1. ZurmoCRM
  2. Test your ZurmoCRM with VirtualBox
  3. Synology: DSM for Business
  4. PHP: PHP Manual: Appendices: php.ini directives
  5. PHP: PHP Manual: Appendices: php.ini directives: memory_limit
  6. PHP: PHP Manual: Appendices: php.ini directives: post_max_size
  7. PHP: PHP Manual: Appendices: php.ini directives: upload_max_filesize
  8. PHP: PHP Manual: Appendices: php.ini directives: max_execution_time
  9. PHP: PHP Manual: Function Reference: Date and Time Related Extensions: Date/Time: Installing/Configuring: Runtime Configuration: date.timezone
  10. PHP: Alternative PHP Cache
  11. Wiki: LAMP (software bundle)
  12. PHP: PHP Manual: Function Reference: Affecting PHP’s Behavior: APC: Installing/Configuring: Runtime Configuration
  13. PHP: PHP Manual: Function Reference: Affecting PHP’s Behavior: APC: Installing/Configuring: Runtime Configuration: apc.shm_size
  14. PHP: PHP Manual: Function Reference: Other Services: Memcache
  15. PHP: PHP Manual: Function Reference: Other Services: Memcached
  16. memcached
  17. Oracle: Docs: 15.6.2 Using memcached
  18. Web Developer Juice: 10 baby steps to install Memcached Server and access it with PHP
  19. Asustor ADM Configuration and Executable Files
  20. Synology DSM Configuration and Executable Files
  21. Zurmo: Forums: Enable Memcache after install
  22. Zurmo: Zurmo Cache System Explained
  23. Synology: DS214SE

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s