Speed up socialengine using Memcached / APC /Xcache

2 May 2011

Speed up socialengine using Memcached / APC /Xcache

Recently we were working on the migration of socialengine v2 to socialengine v4.1.4 for one of our clients. The current socialengine website was loading very slowly even though there were not much users on the site. We tried to speed up the site by using the APC opcode, compressing the html, js and css but couldn’t improve the performance much. There were various reasons for the slowdown but main reason was due to unorganized and inefficient customized source code developer by the earlier vendor. The customized code was tightly coupled with the socialengine’s core code that we couldn’t migrate it to socialengine v4.1.4 using the migration scripts. We had to rewrite the customize code from the scratch for the obvious reasons after migrating the socialengibe v2 to v4.1.4. We shall discuss about the social migration in different article and in this article would focus on speeding up the socialengine v4.x using the caching.

Caching is the vital part of any website and helps website to respond quickly. Social engine allows variety of caching solutions like file based, memcache, APC (Alternative Php cache) and Xcache for the platform. Using one of the caching solution would speed up performance of the socialengine 4. If you don’t have configured the memcached or APC or Xcache then you can use file system based caching but its much slower than the other caching solutions. We would recommend to use one of the caching solution to speed up the socialengine. In this article, we should show the instructions to install and configure caching for socialengine. We assume that the socialengine is running on the production mode.

Memcache is a distributed caching which can be used in a scenario where application is running on several web servers. All the data stored in memcached would be distributed across the all webservers. Since it requires dealing with network protocols in order to support the distributed part of caching, it is slower compared to APC/XCache cache in case of application is running on single server. While using APC/Xcache on distributed system would require manual copy of data on all the servers. APC/XCache are non distributed cache and data can be stored on the local web-server only. APC/XCache op-code caching saves on the compile and execution times of PHP thus loading of the socialengine become faster. Some people got confused whether Memcached can be used with the APC/Xcache (opcode). We can use the combination of MEMcached (as data storage) and APC/Xcache (as opcode for php).

Now we are going to show the installation and configuration of Memcached, APC and Xcache for socialengine on Centos.

Install and Configure Memcached with socialengine

1) Install memcached

2) Install PHP Extension.

Download and install latest stable memcache version from PECL.

memcache.so will be install in php modules directory, now enable memcache.so extension in php.ini

To find out your php.ini location, execute following command

save the file and restart httpd server.

To check is memcache extension loaded inphp, execute following command.

3) Configure memcached in socialengine

1. Go to http://yourserver/index.php/admin/core/settings/performance
2. Enable caching with memcached and add parameters specific to memcached.
3. Save the changes

Install and Configure APC with socialengine
By default there can be one opcode caching for php so if there is already any opcode (eaccelerator etc.) then disable that to allow APC to act as opcode.

1) Install APC

To check is APC extension loaded in php, execute following command.

2) Configure APC in socialengine

1. Go to http://yourserver/index.php/admin/core/settings/performance
2. Enable caching with APC option.
3. Save the changes

Install and Configure Xcache with socialengine

1) Install Xcache

You would need to change timelib_structs.h to install Xcache
Find line:

Replace / update as follows:

Create one password for Xcache administration:

# echo -n “yourpassword”| md5sum

Then open php.ini, and add the following append configuration directives.

2) Configure Xcache in socialengine

1. Go to http://yourserver/index.php/admin/core/settings/performance
2. Enable caching with Xcache option and add user’s credentials.
3. Save the changes

We found Xcache little faster than the Memcached/APC for socialengine 4 and used it for our client’s website.

Please feel free to comments or suggest other technique of caching.

It is possible to do performance tuning by yourself, or getting developers to do this. However, in our experience, the community owners are really more focused on making their community an engaging experience via functionality or graphics. Similarly, most developers can write PHP code, but very few have the experience of various tools for improving performance. One of the solutions we thought was to bake this optimization right into the hosting, so we have teamed up with Acenet hosting to provide you hosting for SocialEngine and Phpfox with built-in PHP, web server and database performance enhancements. Custom optimization may be required when your community grows huge, but that is different for everyone and we will continue to provide it as a separate service.

Our Work

Please check out our socialengine performance tuning at:



Speed up socialengine using Memcached / APC /Xcache was last modified: May 17th, 2015 by Kapil Jain
  • http://www.snetts.com/blogs Victor Okech


    Great article.

    Could you please confirm that Xcache is still the best option for SE performance especially with the improvements in the newer versions of SE like version 4.6.


  • http://www.ipragmatech.com/ Kapil Jain

    Yes Victor, Xcache/apc are still better options than the memcache with SE 4.6. In our test benchmark performance of Xcache was little better than apc.

  • http://www.snetts.com/blogs Victor Okech

    Thanks Kapil, I have this dedicated server with a little more than 30k users. The specs are as follows:

    CPU: Intel i5-3570S
    RAM: 16GB
    HDD: 2x2TB
    100Mbps Uplink

    Could you possibly advice me on some APC settings that would be more efficient on this server.


  • http://www.ipragmatech.com/ Kapil Jain

    Hi Victor,

    I think it would be better for you to move to optimized socialengine hosting. You can try dedicated plan from http://socialfoxhosting.com/plans.html or from hostiso.com or setweaks.com rather than optimizing it yourself.

    Let me know if you have any question.


  • http://www.snetts.com/blogs Victor Okech

    Thanks Kapil, I appreaciate your offer and I have forwarded your recommendations to the owner of the site, but at the moment he is not in a position to acquire the hosting but once we are in a better position then we will give the socialengine hosting a shot.

    In the meantime could you please just give us the optimal settings for xcache for the above stated server. We will highly appreciate.

  • http://www.ipragmatech.com/ Kapil Jain

    Hi Victor,

    Thx for recommending socialfoxhosting to site owner. Sorry we can’t share optimal Xcache settings for Socialengine but you can find closer setting on google.