How Alternative PHP Cache Enhances PHP Web Application performance
In this post we’re going to look at the Alternative PHP Cache plug-in and how you can use it boost the overall performance of your website. The Alternative PHP Cache is a free, open sourceframework that helps websites store the byte code of PHP files so that it can be utilized later to enhance performance. How does it do that? It’s quite simple. When the file is executed the first time around, the Alternative PHP Cache stores the byte code of that PHP file, and each time that same file is been used again, the Alternative PHP Cache provides the byte code of that file, saving the site from having to load it again and again. This cycle continues unless a change is made in the file, in which case the Alternative PHP Cache saves the updated byte code of the file and the process continues as before. As a result of this caching activity, the performance of the website can be enhanced up to 3X because you don’t need to compile and execute the same file each time.
How It Works
If you don’t have the Alternative PHP Cache plug-in installed and a request comes to the server, the request is processed in the following manner.
On the other hand, if you have the Alternative PHP Cache plug-in installed, and a request comes to the server, the Alternative PHP Cache saves the byte code of that PHP file after the first execution and then keeps on providing that byte code for all further requests for that same file, as shown below.
Why Should You Use Alternative PHP Cache?
Suppose you have a dynamic website developed in PHP. Every time there is a new request for a web page, your server first parses the file and then compiles and executes it. This sort of processing flow adds to the overhead on the server and really impact its performance, especially if you’re getting hundreds of thousands of web page requests (or hits).
In such cases, the Alternative PHP Cache offers the best solution as it’s designed to prevent exactly such a scenario. It’s really handy tool if you’re dealing with a dynamic website developed in PHP and are performance issues due to increased traffic.
Setting up the Alternative PHP Cache is also easy. The default settings work fine for most users but if you really performance conscious and have website that gets a lot of traffic, you can customize the default settings to ones more suitable to your needs. Here are the default settings.
apc.cache_by_default = On
apc.enable_cli = Off
apc.enabled = On
apc.file_update_protection = 2
apc.gc_ttl = 3600
apc.include_once_override = Off
apc.max_file_size = 1M
apc.num_files_hint = 1000
apc.optimization = Off
apc.report_autofilter = Off
apc.shm_segments = 1
apc.shm_size = 30
apc.slam_defense = 0
apc.stat = On
apc.ttl = 0
While customizing the settings you should keep two things in mind. The first being the cache size and the second being whether you want the Alternative PHP Cache to check the file on each request? These two things are controlled by the following files: apc.shm_size and apc.stat.
The default value for apc.shm_size is 32MB. 64MB is a more optimal setting but you can change its value based on the requirements of your web site.
The default value for apc.stat is “1”. This basically means that the Alternative PHP Cache will check the file on each request. But be careful while changing this setting, since if you do that, you’ll need to either restart the server or manually delete the cache, in order for the changes to take effect.
The Alternative PHP Cache is a very useful tool for boosting the performance of PHP based dynamic websites since it prevents the recompilation of the requested files with each data request, which greatly reduces the processing overhead on the server. And it’s highly customizable so you can change its default settings according to the requirements of your website.
As a leading software development company, we specialize in developing enterprise and consumer oriented web applications and websites. We also provide website and web application UI and UX design services. If you have a website development or web application development project that you’d like to discuss or would like to know more about our web development expertise, please Contact Us
Latest posts by Bilal Rao (see all)
- How Alternative PHP Cache Enhances PHP Web Application performance - October 1, 2015
- How to Select the Right Free Push Notification Services - August 6, 2015