Jump to content

Xcache vs. other solutions


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites



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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

~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%
Link to comment
Share on other sites

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

Link to comment
Share on other sites

@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%

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...