Here is a quick guide for APC Configuration and Optimization for Rackspace Cloud Server PVHVM Performance Flavor. Warranted Great Result. It is actually not possible to say from just one Page Speed Test that the website is nicely tweaked or not. On Pingdom, you can see our this website loads at 2.39 seconds :p :
1 | http://tools.pingdom.com/fpt/#!/tOfoN/https://thecustomizewindows.com/2014/04/pvhvm-virtualzation-mode-faster-loading-servers/ |
First and foremost thing is that, webpagetest.org is the ONLY the standard, time tested, really regularly updated tool to test somewhat real experience, thats too after taking an average sampling more than 100 tests under various situation. There will be third party javascripts and other stuffs, usually from Google, which actually fails and increases the page loading speed. YSlow is definitely another great tool. Now look at this result of the same 2.39 seconds loading one on webpagetest :
1 | http://www.webpagetest.org/result/140416_K1_YYX/1/details/ |
Well, actually its possible to lower the 2.39 seconds to 1.6 seconds ! The Bible is Yahoo!’s an excellent guide on page speed optimization which everyone knows. If we flush the buffer at regular div interval, on WordPress it will actually show the website to be very fast (this is one of the sophisticated way how the Managed WordPress Hosting, WordPress Theme Creators make the consumers fool). Also note that, webpagetest.org is failing to detect the CDNs. Except Post Attachment images (for SEO) and one CSS (for dev purpose), all static contents are actually served from Cloud Files. So, this much junk is written to make you understand few things and shake your head => How the Heck I Will Understand That My APC Configuration and Optimization for Rackspace Cloud Server for PVHVM Performance Server is Optimum?
---
APC Configuration and Optimization for Rackspace Cloud Server (PVHVM)
We talked about PVHVM Virtualization Mode. You probably know about guide on How To Install WordPress on Ubuntu 13.10 on Rackspace Cloud Server. That is non-scalable one server setup. We actually prefer at least one separate MySQL server and one loadbalancer in front. Loadbalancers can make the script kiddies fool plus does the HTTP caching. Managed WordPress Hosting charges a HUGE for HTTP Caching.
Back to APC. As we are basically running PHP, which is one of the worst scripting language; together with a kind of crippled MySQL (MySQL actually is not so bad like it appears after using WordPress), we actually need to Optimize the Webserver Software (we prefer Apache2 as tweak can render it more secure and stable) and the way PHP is handled.
Alternative PHP Cache or APC is a PHP accelerator. PHP accelerator is nothing but a PHP extension developed to improve the performance of server side software applications written in the PHP. If properly configured, it bypasses the parsing to compiling steps done by PHP for the frontend. You must know that, the way of installing APC is actually 2 or 3 in number. APC is no longer available in PHP 5.5+. The new name is Opcache. We will perform a peck install of APC.
1 | sudo apt-get install php-apc |
The last command to install APC will be :
1 | sudo pecl install apc |
If it throws error (you might have hardened PHP or many other config is different), it usually solves :
1 | sudo pecl install apc-beta |
You will need to install these to run that last step :
1 2 3 4 5 6 7 8 9 | # two commands f sudo aptitude install php5-dev # and sudo apt-get install php-pear make libpcre3-dev # dependencies are (1) php-pear (2) php5-dev (3) make (4) libpcre3-dev # obviously the last step sudo pecl install apc # restart Apache2 sudo /etc/init.d/apache2 restart |
There is reason why aptitude install has been used instead of one liner :
1 | sudo apt-get install php-pear php5-dev make libpcre3-dev |
Search on this website if you want to know what is aptitude and what is apt-get. Open the php.ini
file and add the extension :
1 2 3 4 5 | sudo nano /etc/php5/apache2/php.ini # edit, add this and write out { ^ + O }, then exit { ^ + X } extension=apc.so # restart Apache2 sudo /etc/init.d/apache2 restart |
You will get a file here, its nice :
1 | http://jesin.tk/apc-php-download/ |
It will show you stat plus you will understand that it is working fine. Like this :
Actually, on Ubuntu 13.10 setup, the file should be here (you need not to download in that case, just move to public folder to run it on browser), location is this :
1 | /usr/share/php/ |
Delete the file or move to non-public area, its dangerous to keep it public. Again, open php.ini and add :
1 2 3 4 5 6 7 8 9 10 11 12 13 | sudo nano /etc/php5/apache2/php.ini # edit, add this and write out { ^ + O }, then exit { ^ + X } # add after the line you added ==> extension=apc.so extension=memcache.so extension=apc.so apc.shm_size=128M apc.stat=0 apc.ttl=3600 apc.user_ttl=7200 apc.gc_ttl=3600 apc.max_file_size=1M # restart Apache2 sudo /etc/init.d/apache2 restart |
Its for 2GB server, obviously increase 128M
proportionately.