Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring xcache cacher

Tags:

php

vps

xcache

I've just setup xcache on a vps server.

I have the admin section running and it is showing that xcache is running.

I am however a bit unsure about some of the settings - the documentation doesn't dwell very far into what each setting mean.

Notes that may be useful:

  • In the current setup I'm only interested in the basic opcode cacher, not the var data component.

  • The server is a VPS with 2GB memory (not sure about CPU config but could find out if critical to know) and it's running a CentOS 5.x OS with cPanel/WHM.

  • I have root access and the server will only host one website.

The version of php is:

PHP 5.4.21 (cli) (built: Nov 15 2013 10:15:53) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with XCache v3.0.3, Copyright (c) 2005-2013, by mOo
    with XCache Cacher v3.0.3, Copyright (c) 2005-2013, by mOo

Question 1

The default settings from the installation has:

xcache.shm_scheme = mmap
xcache.mmap_path = /dev/zero

Why is mmap_path set to /dev/zero? doesn't this negate the whole thing? should it be set to a fixed file path.

Question 2

The other "size" settings are:

cache.size = 16M
xcache.slots = 8K
xcache.count = 1

Is there a methodical approach that can be used to work out the best configuration for these?

The stats are currently as such:

xcache summary

xcache summary continued

Note: I have seen it maxed out 100% usage previously.

Question 3

What does xcache.optimizer do?

The FAQ says

Currently only the "cacher" and "coverager" modules are implemented, tested and known to be working, the "optimizer" does nothing. it will be available only in XCache version 2, which is in an early development stage.

But i somehow appear to have XCache 3.0.3 installed o_O

like image 670
Ben Avatar asked Jan 12 '23 21:01

Ben


1 Answers

The Xcache documentation is very poorly maintained, and I recently did my best to work through what is available, answering a similar question. I'll paraphrase a bit to hit your specific points.

xcache.mmap_path

If this is set to an empty or invalid path the cacher will turn off. I believe this should be a writeable directory. (On linux servers the default /dev/zero/ should work; on OSX this failed so I successfully used /tmp/xcache/ instead)

Opcode cacher: size, count, slots

  • xcache.count refers to the number of cache threads and correlates to the number of CPU cores you want to utilize — the idea is that multithreading should be faster if you have a multicore processor
    • valid values are 2^n like 1, 2, 4, 8
    • 0 will disable the cacher
    • non-valid values will be rounded to the nearest valid value
      • i.e. 3 will become 4
      • i.e. 5 will become 8
  • xcache.size refers to the aggregate memory of all cache threads. So, each thread gets roughly size/count amount of memory
  • xcache.slots defaults 8k unless you want to improve something specific
    • more slots (more granular) should lead to more efficient use of space (fit more data in the cache)
    • fewer slots (less granular) should lead to faster read times and more overall stability

The cacher also allows for a user controlled variable cache, with analogous settings and consequences.

Optimizer

This feature seems to be abandoned, or indefinitely under development — ignore it.

like image 92
Mark Fox Avatar answered Jan 16 '23 21:01

Mark Fox