APC, XCache and eAccelerator available on Shared Hosting
Remember that one time you asked your host for APC or eAceelerator? Most probably they have directed you to their VPS or Dedicated servers because Opcode caching is not compatible with shared hosting. Well, we have to admit we did this too. We did not like it but that was the reality back then. Not anymore!
We are glad to announce the successful implementation of mod_lsapi on all shared hosting servers which will greatly improve your website performance and introduce some great new features. But before we go into this any further, let’s first discuss some common problems, so we can give real context to this announcement.
Of course, the ultimate goal when we speak about website optimization is faster page speed and lower resource consumption, so your website can handle more simultaneous visitors without the need to upgrade your plan. Still, every improvement has some sort of trade-off. For example, OpCode Caching such as APC, XCache, and eAccelerator is not compatible with suPHP, which provides a security layer on the shared hosting environment. So, usually the problem is performance, security, compatibility – pick two – you can’t have them all.
Some pretty secure and fast configurations are simply incompatible with some Open Source applications which are a huge problem for the shared hosting environment as different customers use different software platforms to build their websites.
The most secure and user-friendly setup, on the other hand, does not really provide the performance and features we need.
And last but not least, a high-performance host with great compatibility is pretty much useless if it is not secure.
After reviewing a large number of different options and our current infrastructure, we were pretty unhappy with this “pick-two” situation:
- RUID2 + mod_php – is a giant security hole that lets any user get a root account
- MPM ITK – is very slow, as it kills processes after each request
- suPHP & CGI – are both slow, as they start PHP on each request. They are also incompatible with opcode caching.
- FastCGI – creates a lot of stability issues, hard to configure due to the way it handles processes, and doesn’t use opcode caching optimally.
- PHP-FPM – needs a socket/startup per customer, not that stable with Apache and creates a mess when we tried to integrate it with PHP Selector – as now PHP selector would have to restart PHP-FPM processes.
What is OpCode Caching
For those of you that are not familiar with opcode caching, OpCache caches are a performance enhancing extension for PHP. They do this by injecting themselves into the execution lifecycle of PHP and caching the results of the compilation phase for later reuse. It is not uncommon to see a 3x performance increase just by enabling an OpCode cache.
This is achieved by skipping the compilation of already compiled PHP scripts as shown in the diagram below:
Almost all of the most popular applications such as Magento, PrestaShop, Boonex Dolphin and Joomla support OpCaches which makes it extremely important to deliver this feature to our customers, so they can get full advantage of both their hosting service and application built-in optimization features.
After a long research process and testing, we decided to implement the CloudLinux solution – mod_lsapi – a new Apache module to serve PHP.
Some of the benefits of mod_lsapi comparing to other ways to serve PHP:
- Speed – it is faster than any other way to serve PHP with Apache (or at least on cPanel-based host)
- Stability – it doesn’t suffer from stability issues in process management like PHP-FPM
- Utilizes full benefits of opcode caching – Yes, you can have APC, eAccelerator, and XCache now!
- MPM Worker & Event compatible
- Support for PHP directives in .htaccess files (no more error 500 for you)
- Drop-in replacement for existing ways to serve PHP (Extremely easy to implement)
- Fully compatible with PHP Selector – a very important note so you can still change your account PHP version!
- PHP version can be altered per directory – You can have different PHP versions for different folders of your account!
How Does It Work
mod_lsapi is a part of Apache;
Apache passes handling for PHP request to
liblsapi to transfers request
sulsphp is used to do security checks and start process pool;
lsphp processes request and return data to
Each user has
lsphp processes in separate CageFS/LVE;
If there are no requests for
lsapi_backend_pgrp_max_idle seconds, lsphp process is terminated;
lsphp processes available when new request comes, new
lsphp process is created;
lsphp can process requests
With the newly deployed setup configuration, all FastComet clients on our shared hosting environment can take full advantage of opcode caching without sacrificing security. Additionally, with the new mod_lsapi, your website should run faster that with any other Apache PHP handler. So far we have tested more than 150 Open Source applications and the results are more than promising. Still, if you experience any difficulties with the new setup or need help to take full advantage of the OpCode caching, feel free to contact our 24/7 technical support. Thanks to the flexible setup we can revert or apply changes per account base so you will never be stuck with one or another solution.
Very soon we will publish full-length tutorials on how to enable all new features and optimize your website performance for the most popular platforms such as Magento, PrestaShop, WordPress, Dolphin and many more so stay tuned for further updates.
The latest tips and news from the industry straight to your inbox!
Join 30,000+ subscribers for exclusive access to our monthly newsletter with insider cloud, hosting and WordPress tips!