Gabriel Torres Posted July 6, 2014 Posted July 6, 2014 Hi, We use Xcache on our installation. On another topic, Grumpy recommended: Installing php opcache (like zend opcache) Installing user cache (like APCu) Xcache is already a PHP code optimizer, PHP code cache, and PHP variable cache. I wonder if Xcache alone is enough of if I should replace it with other solutions. Your thoughts? Thanks, Gabriel.
Grumpy Posted July 6, 2014 Posted July 6, 2014 I recommend zend opcache over alternatives because of vast performance improvement. apc & xcache is roughly equal. zend opcache like... blows them out. In terms of performance, it's not even a competition. It will win by such a big margin no matter what kind of data sample you give (or at least all the samples tried...). On the user cache side, it matters less, it seems. Whether you use apcu/acp/xcache, shouldn't matter much. Just be sure to turn off the opcache portion so that it doesn't conflict with zend opcache. From php5.5+, zend opcache is built in, and only need to be turned on in php configuration to use. It's really the only future at this point. xcache & apc's developments are dead mostly now.
Gabriel Torres Posted July 6, 2014 Author Posted July 6, 2014 Thank you for the prompt reply, will play with this right away!
Dmacleo Posted July 6, 2014 Posted July 6, 2014 would be interested in seeing someones php.ini opcode_cache settings. or did this one use a conf file? I don't remember right now. using xcache now but with it built in to 5.5 was planning on using it.
Gabriel Torres Posted July 6, 2014 Author Posted July 6, 2014 Dmacleo, It is configured at php.ini. On PHP <5.5 you can download and compile it, with PHP 5.5 the only difference is that you add --enable-opcache at the ./configure line to compile the module together with PHP. You still need to add the zend_extension = /path/to/opcache.so in the php.ini file as you would on PHP < 5.5. Gabriel.
Grumpy Posted July 7, 2014 Posted July 7, 2014 would be interested in seeing someones php.ini opcode_cache settings. or did this one use a conf file? I don't remember right now. using xcache now but with it built in to 5.5 was planning on using it. Here's the full config with descriptions. ; Enable Zend OPcache extension module zend_extension=/usr/lib64/php/modules/opcache.so ; Determines if Zend OPCache is enabled opcache.enable=1 ; Determines if Zend OPCache is enabled for the CLI version of PHP ;opcache.enable_cli=0 ; The OPcache shared memory storage size. opcache.memory_consumption=1024 ; The amount of memory for interned strings in Mbytes. opcache.interned_strings_buffer=8 ; The maximum number of keys (scripts) in the OPcache hash table. ; Only numbers between 200 and 100000 are allowed. opcache.max_accelerated_files=4000 ; The maximum percentage of "wasted" memory until a restart is scheduled. ;opcache.max_wasted_percentage=5 ; When this directive is enabled, the OPcache appends the current working ; directory to the script key, thus eliminating possible collisions between ; files with the same name (basename). Disabling the directive improves ; performance, but may break existing applications. ;opcache.use_cwd=1 ; When disabled, you must reset the OPcache manually or restart the ; webserver for changes to the filesystem to take effect. ;opcache.validate_timestamps=1 ; How often (in seconds) to check file timestamps for changes to the shared ; memory storage allocation. ("1" means validate once per second, but only ; once per request. "0" means always validate) ;opcache.revalidate_freq=2 ; Enables or disables file search in include_path optimization ;opcache.revalidate_path=0 ; If disabled, all PHPDoc comments are dropped from the code to reduce the ;size of the optimized code. ;opcache.save_comments=1 ; If disabled, PHPDoc comments are not loaded from SHM, so "Doc Comments" ; may be always stored (save_comments=1), but not loaded by applications ; that don't need them anyway. ;opcache.load_comments=1 ; If enabled, a fast shutdown sequence is used for the accelerated code opcache.fast_shutdown=1 ; Allow file existence override (file_exists, etc.) performance feature. ;opcache.enable_file_override=0 ; A bitmask, where each bit enables or disables the appropriate OPcache ; passes ;opcache.optimization_level=0xffffffff ;opcache.inherited_hack=1 ;opcache.dups_fix=0 ; The location of the OPcache blacklist file (wildcards allowed). ; Each OPcache blacklist file is a text file that holds the names of files ; that should not be accelerated. opcache.blacklist_filename=/etc/php.d/opcache*.blacklist ; Allows exclusion of large files from being cached. By default all files ; are cached. ;opcache.max_file_size=0 ; Check the cache checksum each N requests. ; The default value of "0" means that the checks are disabled. ;opcache.consistency_checks=0 ; How long to wait (in seconds) for a scheduled restart to begin if the cache ; is not being accessed. ;opcache.force_restart_timeout=180 ; OPcache error_log file name. Empty string assumes "stderr". ;opcache.error_log= ; All OPcache errors go to the Web server log. ; By default, only fatal errors (level 0) or errors (level 1) are logged. ; You can also enable warnings (level 2), info messages (level 3) or ; debug messages (level 4). ;opcache.log_verbosity_level=1 ; Preferred Shared Memory back-end. Leave empty and let the system decide. ;opcache.preferred_memory_model= ; Protect the shared memory from unexpected writing during script execution. ; Useful for internal debugging only. ;opcache.protect_memory=0
ASTRAPI Posted July 7, 2014 Posted July 7, 2014 zend opcache is for opcode caching only and not for data also as the APC.
Dmacleo Posted July 7, 2014 Posted July 7, 2014 Dmacleo, It is configured at php.ini. On PHP <5.5 you can download and compile it, with PHP 5.5 the only difference is that you add --enable-opcache at the ./configure line to compile the module together with PHP. You still need to add the zend_extension = /path/to/opcache.so in the php.ini file as you would on PHP < 5.5. Gabriel. yup, I am compiled with it and disabled in php.ini right now. Here's the full config with descriptions. I have seen that, should have clarified I was meaning what people are actually running. I had issues with xcache and this and didn't get a chance to troubleshoot (was about 2 months ago or so) so disabled this for now. pretty sure its one of the options I just need to see what one, wondering if anyone running xcache and this together.
Gabriel Torres Posted July 7, 2014 Author Posted July 7, 2014 Yes, I am running Xcache and the Zend Opcode together here without any issues. However, you need to disable the optimizer and the code cacher from Xcache, leaving enabled only the var cache. This can be accomplished by changing those settings on php.ini: xcache.size = 0 (disables code caching) xcache.optimizer = Off (disables code optimizer) Make sure you have the variable cache enabled, though: xcache.var_size = 8M xcache.var_count = 8 xcache.var_slots = 8K (These are the values I use here and work fine) Gabriel.
Dmacleo Posted July 7, 2014 Posted July 7, 2014 that makes sense, I suspected it was code cache part of xcache doing it but had not had a chance to look deeply.
Dmacleo Posted July 8, 2014 Posted July 8, 2014 https://rtcamp.com/tutorials/php/zend-opcache/ got all 3 and am comparing. install was a lot easier then xcache admin LOL
Gabriel Torres Posted July 8, 2014 Author Posted July 8, 2014 Thanks for sharing. I will try them out.
Makoto Posted July 8, 2014 Posted July 8, 2014 either of you use any webgui to monitor? Yep, I used the very same script you linked. It works wonderfully. The visualize partition option is utterly awesome as well.
Dmacleo Posted July 8, 2014 Posted July 8, 2014 the realtime on this one is pretty cool https://github.com/amnuts/opcache-gui have not done much tweaking but do have a 99.5% hit rate so far, xcache enabled also as discussed few posts up. do also have mod_pagespeed running (minimal tweaking) and stuff seems to work ok. I do know I need to reduce some image sizes and stuff on main content page for initial visit speeds but all in all its still decent. forum index, with lot of hooks and stuff, loads quick. the few ads actually to seem to be the slow downs, not much I can do there.
Makoto Posted July 8, 2014 Posted July 8, 2014 ~98.36% hit rate for me, opcache_enabled true cache_full true restart_pending false restart_in_progress false used_memory 125.41 MB free_memory 13.23 kB wasted_memory 2.58 MB current_wasted_percentage 2.01% num_cached_scripts 1694 num_cached_keys 1725 max_cached_keys 7963 hits 124062964 start_time Sun, 06 Jul 14 16:19:17 -0400 last_restart_time Sun, 06 Jul 14 18:53:56 -0400 oom_restarts 1 hash_restarts 0 manual_restarts 0 misses 2070255 blacklist_misses 0 blacklist_miss_ratio 0.00% opcache_hit_rate 98.36%
Dmacleo Posted July 8, 2014 Posted July 8, 2014 mines not been running long (90 min or so) so I need to watch but I think I can dump memory down a lot, will know more tomorrow Used Memory 56.2M Free Memory 959.7M Wasted Memory 8.1M Current Wasted Percentage 0.8 Num Cached Scripts 610 Num Cached Keys 659 Max Cached Keys 7963 Hits 56414 Oom Restarts 0 Hash Restarts 0 Manual Restarts 0 Misses 655 Blacklist Misses 0 Blacklist Miss Ratio 0 Opcache Hit Rate 98.9
Codehusker Posted July 9, 2014 Posted July 9, 2014 @Kirito, can you give opcache any more memory? You had an OOM restart within two days of starting, so can probably increase the hit rate with a little more memory and avoid the cold cache reload on each restart. With IPS and Drupal on the server: opcache_enabled true cache_full false restart_pending false restart_in_progress false used_memory 120.81 MB free_memory 123.74 MB wasted_memory 11.45 MB current_wasted_percentage 4.47% buffer_size 8388608 used_memory 8.00 MB free_memory 40 bytes number_of_strings 159896 num_cached_scripts 1757 num_cached_keys 1797 max_cached_keys 7963 hits 36009458 start_time Mon, 30 Jun 14 11:43:02 -0500 last_restart_time Mon, 30 Jun 14 21:45:53 -0500 oom_restarts 0 hash_restarts 0 manual_restarts 1 misses 25378 blacklist_misses 0 blacklist_miss_ratio 0.00% opcache_hit_rate 99.93%
Dmacleo Posted July 9, 2014 Posted July 9, 2014 Yes, I am running Xcache and the Zend Opcode together here without any issues. However, you need to disable the optimizer and the code cacher from Xcache, leaving enabled only the var cache. This can be accomplished by changing those settings on php.ini: xcache.size = 0 (disables code caching) xcache.optimizer = Off (disables code optimizer) Make sure you have the variable cache enabled, though: xcache.var_size = 8M xcache.var_count = 8 xcache.var_slots = 8K (These are the values I use here and work fine) Gabriel. are these the only xcahce settings you have?
Makoto Posted July 9, 2014 Posted July 9, 2014 @Kirito, can you give opcache any more memory? You had an OOM restart within two days of starting, so can probably increase the hit rate with a little more memory and avoid the cold cache reload on each restart. Yeah, I'll up it to 192MB later tonight and see how that goes, thanks for the tip.
Gabriel Torres Posted July 10, 2014 Author Posted July 10, 2014 are these the only xcahce settings you have? [xcache] xcache.shm_scheme = "mmap" xcache.size = 0 xcache.var_size = 8M xcache.var_count = 8 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 xcache.var_namespace_mode = 0 xcache.var_namespace = "" xcache.readonly_protection = Off xcache.mmap_path = "/dev/zero" xcache.coredump_directory = "" xcache.disable_on_crash = Off xcache.experimental = Off xcache.cacher = On xcache.stat = On xcache.optimizer = Off [xcache.coverager] xcache.coverager = Off xcache.coverager_autostart = On xcache.coveragedump_directory = "" I also have the GUI installed, so with that you can monitor for any OOMs and readjust as necessary. Thanks for mentioning mod_pagespeed, I didn't know this one, I will take a look at it. Gabriel
Dmacleo Posted July 10, 2014 Posted July 10, 2014 those look (going off memory right now) similar to my settings, thanks.
Dmacleo Posted July 10, 2014 Posted July 10, 2014 still playing around with pagespeed settings but once I learn it all can post my configs for you. need to make changes, test and evaluate on some items, then change back as needed LOL
Gabriel Torres Posted July 11, 2014 Author Posted July 11, 2014 I will open a new topic on pagespeed... Too many options there...
Dmacleo Posted July 11, 2014 Posted July 11, 2014 yup lot of way to screw things up too, and since I am using directadmin its also a pita to update which I see I need to do LOL
Recommended Posts
Archived
This topic is now archived and is closed to further replies.