This article provides performance and speed enhancement tips for the SocialEngine platform.
Choosing the right hosting package is the most important decision you will make when building your SocialEngine community. Social networking websites generate a lot of activity on a server. You’ll want to make sure that you have sufficient resources available to handle that activity.
Shared hosting packages are usually the most inexpensive of hosting packages. However, they are not suitable for high traffic websites. Shared hosting packages work by hosting as many websites as possible on a single server and these websites share all of the available resources. In some cases, a shared server may contain hundreds or even thousands of active websites on the same server which can quickly affect your website’s performance. At the same time, hosting providers place strict restrictions on shared hosting packages which can often result in frequent errors. Shared hosting packages are best suited for light or static content. Heavily dynamic applications such as SocialEngine should be hosted on either a virtual private server (VPS) or a dedicated server.
As mentioned previously, VPS and Dedicated server packages are your best choice when considering hosting packages. However, there are a few caveats to them.
First, most hosting providers provide either a managed or un-managed plan for their VPS and dedicated servers. With managed plans, hosting providers assume the responsibility of assisting you with making changes to your server's configuration and will assist you in cases of malfunctioning server software. However, this is done at an increased cost. Unmanaged plans on the other hand are completely hands off and you should only choose them if you have experience with managing servers.
Choose a plan that comes with at least 2 gigs of memory. If your hosting provider offers a VPS or Dedicated server plan with 4 gigs of memory, and your budget can support it, choose that option. The reason for this is that SocialEngine uses the MySQL InnoDB storage engine for many of its database tables. InnoDB uses memory to store its indexes, as well as a cache of frequently accessed data which allows most of SocialEngine's SQL queries to execute in milliseconds.
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 five 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.
Of all the caching features supported by SocialEngine, File-based caching is by far the slowest. All of the other caching features within SocialEngine cache to memory, and memory access speeds are many orders of magnitude faster than file access speeds.
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
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
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 (http://us.php.net/manual/en/apc.configuration.php#ini.apc.stat), 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.
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 affect performance. Some of the more common causes for errors are:
If you come across an error and require assistance isolating the cause, please submit a support ticket.
One of the common problems we see when APC is used is the use of mod_fcgid with PHP. On multi-core systems this is a bad idea. Consider the scenario where there are two 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 provide better performance. If you have multiple websites, 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.
This affects the website's speed drastically.
In your Admin Panel navigate to Settings > Performance & Caching.
Enable the setting “Translation Performance” and click “Save Changes” to save the setting.
Great work! Please feel free to contact us if you have any questions or need further tutorials. Visit our community to have more interactions with us and other clients or third party developers. We’d love to see you there!