Benefits of Server Side Caching

bsoremsugar —  September 18, 2008 — 13 Comments

We have been running load test after load test in the Sugar Labs to determine the performance of Sugar 5.1 and where to focus on improving performance in the future.  You will see performance benefits in 5.1 with the new logger utility, SugarLogger, that greatly reduces the CPU load and the revamped internal handling of custom fields that both reduces the amount of code as well as database queries. We already have a list of improvements we’ll be making to 5.2 and 6.0 as well.

We just finished analyzing one of our load tests that we felt the community would find interesting. This test was geared towards showing the benefits of operation code (op-code) caching as well as external data caching with SugarCRM. We ran a load test geared towards the sales automation functionality with a PHP accelerator, and then we ran it again the with the accelerator disabled.

The database was run on a separate server to ensure that it had no impact on the Web server CPU utilization.

What is Operation Code Caching?

When a user requests a PHP page, most PHP Accelerators will compile the PHP code for the requested page into bytecode. It will then save that bytecode in a cache either on the file system or in shared memory that allows the PHP Accelerator to skip the compile step the next time that PHP page is requested. This greatly reduces CPU utilization since a PHP script no longer needs to be compiled on every round trip.

What is External Data Cache?

An External Data Cache is either shared memory or file based storage that many PHP accelerators have that allow for storing data across round trips and sharing data between multiple users. SugarCRM has an API that takes advantage of these and can currently support APC, Zend Platform, and Memcache. This reduces file I/O as well as round trips to the database.

The Results:

We saw that with caching enabled, our test server completed more requests per second and the requests completed faster. Once we disabled caching we saw the average server response time shift from sub .5 second response times to around .75 second response times. You will also note in the graph below how much longer the tail of the chart is without cache. This indicates that there was a noticeable increase in the number of responses that took greater than 1 second response time without the cache enabled.

The biggest factor is the improvement in CPU utilization when you utilize a PHP accelerator. We saw a drop in CPU utilization from around 75% down to around 40% when utilizing both the op-code caching and the external data cache.

Conclusion:

If you are not running SugarCRM with a PHP accelerator, you really should be. You will see dramatic improvements in performance as well as scalability leading to better user productivity and reduced hardware needs. You can check out our wiki page on PHP Accelerators for more information.



13 responses to Benefits of Server Side Caching

  1. 

    Hi Majed,
    1.What’s the difference between the cache function which is now used in sugarcrm500 and these two cache?
    2.Which tool should I use if I want do the same load test?

    Thanks,
    J

  2. 

    Hi Majed,
    1.What’s the difference between the cache function which is now used in sugarcrm500 and these two cache?
    2.Which tool should I use if I want do the same load test?

    Thanks,
    J

  3. 

    Nice writeup, Majed. Question for you regarding the External Data Cache: what Sugar data is stored in this cache? Is it only data that originates from the DB or is it also data that originates from the filesystem?

    Thanks,

    Andy

  4. 

    Nice writeup, Majed. Question for you regarding the External Data Cache: what Sugar data is stored in this cache? Is it only data that originates from the DB or is it also data that originates from the filesystem?

    Thanks,

    Andy

  5. 

    Hey J,

    So there are two parts to the results. This first primarily shows the difference in op-code caching v.s. no op-code caching which can be taken advantage of in any PHP application.

    The second is the advantages of external data cache v.s. non-external data cache. Here in 5.0 we added memcache support as well which provides an in memory area for storing data. The API for this goes through include/utils/external_cache.php and the primary functions needed are sugar_cache_put($key, $value) which stores a key value pair and sugar_cache_retrieve($key) that will retrieve the data back. SugarCRM will automatically detect what external caches you have available and utilize them if they are available. While the API has remained consistent since 4.5.1, we have continually improved the application through re factoring code to take advantage of this cache. So you should see continual improvement in this area in every release.

  6. 

    Hey J,

    So there are two parts to the results. This first primarily shows the difference in op-code caching v.s. no op-code caching which can be taken advantage of in any PHP application.

    The second is the advantages of external data cache v.s. non-external data cache. Here in 5.0 we added memcache support as well which provides an in memory area for storing data. The API for this goes through include/utils/external_cache.php and the primary functions needed are sugar_cache_put($key, $value) which stores a key value pair and sugar_cache_retrieve($key) that will retrieve the data back. SugarCRM will automatically detect what external caches you have available and utilize them if they are available. While the API has remained consistent since 4.5.1, we have continually improved the application through re factoring code to take advantage of this cache. So you should see continual improvement in this area in every release.

  7. 

    Oh and we use jmeter to drive our load tests

  8. 

    Oh and we use jmeter to drive our load tests

  9. 

    Is JMeter working well for this or are there shortcomings for what you would like to see? Thanks,

    Roger

  10. 

    Is JMeter working well for this or are there shortcomings for what you would like to see? Thanks,

    Roger

  11. 

    It might be worth nothing that opcode caches can reduce the size of web server processes as well. This was a bit of a surprise to me, since it’s not mentioned anywhere… As an example, I was able to add 20-25% additional processes on my own PHP prefork server. I wrote about my experience here: https://surniaulula.com/2012/11/22/save-memory-with-alternative-php-cache-apc/

    js.

Trackbacks and Pingbacks:

  1. Sugar Developer Blog » Blog Archive » Managing the PHP external cache - November 19, 2008

    [...] additional configuration options available for your Sugar installation with regards to utilizing PHP external caches.  The new options to add to your config_override.php file [...]

  2. Managing the PHP external cache | CRM Solution | CRM Software | Free CRM | Mobile CRM | Sugar CRM - February 6, 2009

    [...] additional configuration options available for your Sugar installation with regards to utilizing PHP external caches.  The new options to add to your config_override.php file [...]

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