PHP 5.5. has zend opcache support in core. Since APC is not updated from long time, we made a switch to new Zend Opcache. Below is our config and web-based stats viewer.
PHP’s Zend Opcache Config
php.ini or depending on your PHP version
zend_extension=opcache.so opcache.memory_consumption=512 opcache.max_accelerated_files=50000 ;following can be commented for production server opcache.revalidate_freq=0 opcache.consistency_checks=1
Unlike APC, for Zend Opcache there are plenty of web-based viewer. May be reason being zend opcache’s official status has something to do with it. Below is list to choose from.
#1. Opcache-Status by Rasmus Lerdorf
This is by PHP creator himself. Very beautiful.
cd /var/www/example.com/htdocs wget https://raw.github.com/rlerdorf/opcache-status/master/opcache.php
#2. opcache-gui by amnuts
Responsive. Feature-rich. Notably option to enable real-time stats and and option to reset/flush opcache.
If you are going to use this, make sure it is protected by some security layer.
cd /var/www/example.com/htdocs/ wget https://raw.github.com/amnuts/opcache-gui/master/index.php -O op.php
#3. ocp.php by ck-on
Has best way to analyse/explore file-based cache. UI is more old-style.
We are using all 3 for now! We will update this post if we add or remove anything from our list.
Hi i really like your tests on php5.5 wish my shared hosti g had it installed. As well be able to use wordpress with memcached setup to really have a performance boost even tough shared hosting with a cdn setup is really fast.
Why wish when you can get VPS with SSD at $5/month from https://www.digitalocean.com/pricing
CDN only helps offloading static content. Nginx, PHP & VPS can speed-up entire site at many different levels.
Question is if the vps is a shared vps and used up resources hhow ever memcached option be nice
It’s a KVM based VPS which means you’re getting guaranteed resources. I’m testing the smallest Digital Ocean VPS right now.
If you want to know what could be missing try Digital Ocean’s UserVoice to see what other people are missing.
@Spazl Here is link – https://digitalocean.uservoice.com/ @Michael is talking about.
It’s actually wise to use one of these web based viewers so you can better adjust cache values, depending on your configuration. I like the live feed of the opcache-gui by amnuts, myself
Yep. I check stats pages like per week.
If I see free memory going below 10MB, I increase RAM allocation.
What’s happens to things if memory is exhausted though?
Is there a similar tuning script for memcached as well, that you know of?
@Martin Any kind of caching mechanism starts flushing cached entries as soon as storage limit is reached.
Please check our memcache config here – https://rtcamp.com/tutorials/php/memcache/
@Michael Agree with you. I am more concerned about hit rate. About RAM, I try to give away as much as possible to caches.
I’d rather look at the hit rate. Depending on your site’s content you’ll come to a point where the cacheable amount of data is larger than your server’s memory.
An interesting set of observations between APC and Zend Opcache which suggests Opcache is a memory hog and not as effective as APC. Just thought I’d go digging a bit
How did you conclude that? APC also caches user data by the way. So make sure you are not using APC user-cache while running any benchmarks.
The problem with APC and it’s user cache is that the cache is created n times for n PHP processes like php-fpm or Apache process. If you want to scale you need lots of processes to serve the increasing amount of users. That’s why one cache (e.g. memcache) for n PHP processes is more economically.
I think Martin is comparing APC’s opcocde caching feature v/s PHP’s new built-in zend opcode cache in terms of memory.
i tried most of caching tool to increase my site performance (and reduce my server load) but i wasn’t able to find anything “good”, i have a vps with some site on it (wordpress, custom made cms, and so) and no caching system was good, lastly i tried zend opcache, and it made the load of server dramatically drop, but some thing in wordpress were broken (jetpack stats for example) and a “hand made” site loaded partially and become useless (i guess it is something about ajax, but i have no idea on where to check)… so i reverted, and that is really a pity, because using opcache it was all so fast and i have a real unloaded server…
Jetpack breaking is unexpected.
Did you try?
For non-logged in users, if your PHP app is on Nginx, try fastcgi-cache – https://rtcamp.com/wordpress-nginx/tutorials/single-site/fastcgi-cache-with-purging/
thank you rahul,
i tried your suggestion, but all the wp-admin site become useless (page unavailable) with opcache installed, and some other site i host arent working properly; it’s really a pity beacuse on fronte end side, opcache really speed up!
I am really clueless. This and every site we are running is using PHP Zend Opcache.
Do you have any ioncube encrypted plugin?
Following your instructions, i updated to php 5.5 and i managed to have this:
PHP 5.5.9-1+sury.org~precise+1 (cli) (built: Feb 13 2014 15:53:53)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
thank you thank you thank you
I’m a bit confused here… how to I put some security on these pages? I don’t need everyone being able to see them. How do I limit access to just me, like I did with phpmyadmin?
Also… after installing easyengine and using it… I love it. Thanks you guys. One problem I have though is that WordPress now asks over and over again for FTP settings in order to do anything for me. I have to change W3TC settings manually (it warns me to make changes), and WordPress themes and plugins will not update without that information.
I figured this easy-to-install package wouldn’t have that issue. It does likely have to do with the fact that I imported my old database from my other host into this site. How do I fix it?
Also, as an added note… It looks like my RAM is at 100% usage. How can I stop that from happening? I have only 1GB of RAM on the server, and I have the “ideal” cache settings in W3 (using memcache). Am I simply under-powered, or is my settings messed up? It’s the $10 box at Digital Ocean.
If you are seeing 100% usage in Zend Opcache, simply increase it’s size.
What is your current size?
You can use HTTP AUTH to protect these pages. If you are using EasyEngine, then these pages must be under `/ee` which is already protected location.
For all file-transfer purpose, you should use `www-data` user (if following my tutorials). Make sure you chown all files under `/var/www` to `www-data` user/group so your FTP issue might get fixed.
Then for SFTP…
Set a password for www-data and use that user over SFTP (not normal FTP).
Not for file transfer purposes. I mean, when I visit http://pryormedia.net/opcache.php – I can see it. It’s publicly viewable. I’m sorry to ask this, as I’m sure it’s like Linux 101 stuff… but what can I do to password protect this viewing/page? Restrict it to a username and password. What are the steps I can take? I know they are probably simple, but I don’t know the linux commands to use. Thank you for your time.
You can use HTTP Auth from webserver to protect any URL at server level.
I refered to your article before actually having our server used opcache. We now have one, and phpinfo indicates that its up and running, but its not actually caching anything. Aside from the default config, I only edited minimum config variables as suggested in the recommended settings: http://www.php.net/manual/en/opcache.installation.php
Someone at stackoverflow has the same problem, but noone is answering. The server is mint, PHP has just been upgraded from 5.4 to 5.5.10. Where do you think I should start looking to fix this?
Try using config I posted in above article. Use site for a while. Check opcache stats again from webserver.
You should see cache usage. If not, there could be some issue with php-build as config part is very small.
I am not sure how did you install php, but if you are using wordpress and nginx – try https://rtcamp.com/easyengine . PHP it installs definiely have zend opcache cache working.
Comments are closed.