Jump to content

* * * * * 1 votes

[SE4] "5" Speed Enhancement Tips of Socialengine

  • Please log in to reply
No replies to this topic

#1 Les


    Blue Team Lima 1

  • Moderators
  • Level
  • 5,168 points
  • 3,447 posts
    • Gender:Male
    • Location:Westland, Michigan U.S.A.
    • Software:SE 5.x

Users Awards

Posted 19 February 2019 - 02:50 PM

5 Speed Enhancement Tips for SocialEngine 



SocialEngine, with a great speed, is always what we need to make our users happy. In this tutorial, I will show you 5 simple tips to make SocialEngine fast as possible.




1. Install an opcode cache

One of the most important things you can do to improve SocialEngine’s performance is to install an opcode cache on your server. An opcode cache stores the compiled state of PHP scripts in shared memory, and uses it when the script is requested. This removes one big chunk of the PHP interpreter’s job, which is to convert PHP code to opcode. By itself, this can improve the performance of SocialEngine by as much as 5 times. There are a few opcode cache extensions for PHP (Xcache, eAccelorator and APC), however we generally recommend choosing APC.

Some of the newer releases of APC have been buggy and we would not suggest using them. Of all the versions of APC available, we would suggest using APC 3.0.19, 3.1.3p1 or 3.1.9.


2. Cache to memory, not to files

Of all the caching features supported by SocialEngine, File-based caching is by far the slowest. All the other caching features within SocialEngine cache to memory, and memory access speeds are many orders of magnitude faster than file access speeds.


3. Tweak APC’s configuration for better results

If you use APC as your caching feature within SocialEngine, edit your php.ini file on your server and raise the apc.shm_size directive to 128MB:

apc.shm_size = 128 If you install APC 3.1.9, use the following instead: apc.shm_size = 128M
apc.shm_size = 128 If you install APC 3.1.9, use the following instead: apc.shm_size = 128M

This needs to be done to avoid high fragmentation, which reduces the performance of APC.

A bit of warning, on some unix/linux servers, you may need to manually raise the value of the kernel.shmmax resource in order to allow APC to allocate 128M of memory. To do this, locate the sysctl config file on your server, usually /etc/sysctl.conf, and make the following change:

kernel.shmmax = 134217728
kernel.shmmax = 134217728

This change needs to be made prior to raising the value of the apc.shm_size directive.

On production machines, consider disabling the apc.stat directive ( which removes stat checks on PHP files. Please be advised that when this directive is disabled, any changes made to PHP files, will require APC’s cache to be cleared manually, in order for the file to be recompiled and the opcode cache updated.


4. Keep an eye out for PHP errors. Check your logs.

Errors or exceptions from SocialEngine are automatically logged in SocialEngine’s error logs, located in the temporary/log directory — you can check errors from the Stats > Log Browser page in the admin panel. If SocialEngine is excessively writing to log files, the increase in file writes can quickly effect performance. Some of the more common causes for errors are:

The use of two PHP extensions with opcode caching capabilities on a server (ie. APC, Xcache, eAccelerator or Zend Optimizer). If you plan on using APC or Xcache, all other opcode caching extensions should be disabled.
MySQli losing connection to the MySQL database. Usually fixed by enabling the mysqli.reconnect directive.
MySQL max connection errors. Usually fixed by lowering the value of the interactive_timeout and wait_timeout MySQL variables to 30 seconds.
If you come across an error and require assistance isolating the cause, please submit a support ticket.


5. Use mod_php5, or mod_fastcgid with APC

One of the common problems we see when APC is used, is the use of mod_fcgid with PHP, which on multi-core systems is a bad idea. Consider the scenario where there are 2 quad-core processors on a server. With 8 available cores, and mod_fcgid being used as the Server API, APC allocates 8 buckets in memory to store data. If you have APC configured to use 128MB of shared memory, APC 1GB of memory (8*128MB=1024MB = 1GB) end up being allocated. The presence of 8 APC caches leads to an increased cache misses, which puts more strain on the CPU.

To avoid this problem, you can use either mod_fastcgid or mod_php5 with Apache. If you have SocialEngine running on a server with no other websites, mod_php5 will prove better performance. If you have multiple websites however, where each website is under a separate user account for security reasons, you can use mod_fastcgid. 128M of memory for apc.shm_size — see #3, APC will be using 1gig of memory . Additionally, PHP will randomly use one of the shared memory containers created by APC for caching, resulting in increased cache misses and putting strain on the CPU.

Edited by Les, 19 February 2019 - 03:03 PM.

:emo: Please don't forget to  27-AwardsImgIcon.png "LIKE" if you like this post or if it is helpful to you. This is a way to show gratitude for the help that you received. After all, the "LIKE" costs you nothing. Don't you agree? Also, any and all modules, plug-ins, themes, widgets, or DB entries that are shared or posted by me are for educational purposes. Please visit the developers websites and purchase legitimately, if you like them. Thanks, Les




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

All the resources listed here are just for testing purpose and they shouldn't be used at any commercial environment without a valid license.
Those are for users who wants to try them before buy. Help the developer to build it better by purchasing them from original authors.