XenForo + caching = AMAZING

One other thing - are you supposed to remove memcache.so and replace it with memcached.so or can you use them both at the same time?

If you have to remove memcache.so how do you do it?

Also, do you need to update your XF config.php and replace the backend cache name with Libmemcached?

Cheers,
Shaun :D
 
One other thing - are you supposed to remove memcache.so and replace it with memcached.so or can you use them both at the same time?

If you have to remove memcache.so how do you do it?

Also, do you need to update your XF config.php and replace the backend cache name with Libmemcached?

Cheers,
Shaun :D

Yes, you need to change the config to use Libmemcached. Floren posted a copy of a config in a previous thread. I've removed memcache.so, by deleting the line in PHP.ini.

Not sure if they can be run in parallel though?
 
Not sure if they can be run in parallel though?
Yes, you can enable both of them. In my rpm's the common params are commented by default so the value falls into standard PHP settings (session.save_handler and session.save_path). Not sure how Memcached will react if you run both memcached and libmemcached in parallel while using the same IP/port, is been a long time I stopped using the deprecated memcache library. You can assign a different port to prevent any possible conflicts.

I spent some time today and did some cleanup of my PECL .ini settings. This is the new structure, compliant with the PHP standards (not the crazyiness you find on the Internet). :giggle:
Those are not copy/paste values, don't go crazy and paste them, right? Is a reference to the default settings found in Axivo rpm's, properly formatted to PHP standards (yes, I repeat myself). In other words, is what PHP provides by default as values. The settings need to be adjusted and match your server specs, site usage, etc. Note the boolean values used inside each configuration, no more crazy integers when we deal with an actual bool.

/etc/php.d/apc.ini
(relocated the apc.serializer from igbinary.ini to apc.ini with a default setting to avoid conflicts)
; Enable PECL apc extension module
extension = apc.so

[apc]
; Enable APC
; valid values: On, Off
; the default value is On
apc.enabled = On

; Number of shared memory segments
; If APC is running out of shared memory but apc.shm_size
; is set as high as the system allows, raising this value
; might prevent APC from exhausting its memory.
; the default value is 1
apc.shm_segments = 1

; Size of each shared memory segment, in megabytes
; the default value is 32 megabytes
apc.shm_size = 32M

; Optimization level
; Higher values use more aggressive optimizations, with
; modest speed improvements. This is experimental.
; the default value is 0
apc.optimization = 0

; Number of distinct source files to store
; the default value is 1000
apc.num_files_hint = 1000

; Number of distinct user cache variables to store
; the default value is 4096
apc.user_entries_hint = 4096

; Time a cache entry can idle in a slot
; the default value is 0 seconds
apc.ttl = 0

; Time an user cache entry can idle in a slot
; the default value is 0 seconds
apc.user_ttl = 0

; Time a cache entry is on garbage-collection list
; the default value is 3600 seconds
apc.gc_ttl = 3600

; Enable cache by default
; valid values: On, Off
; Can be set to Off and used in conjunction with
; positive apc.filters so that files are only cached
; if matched by a positive filter.
; the default value is On
apc.cache_by_default = On

; Comma-separated list of POSIX regular expressions
apc.filters

; File mask passed to the MMAP module
; /dev/zero - anonymous mmap usage
; /apc.shm.XXXXXX - POSIX-style shm_open mmap usage
; /tmp/apc.XXXXXX - straight file-backed mmap usage
; the default value is /dev/zero
apc.mmap_file_mask = "/dev/zero"

; Time delay for caching brand new files
; the default value is 2 seconds
apc.file_update_protection = 2

; Enable APC for the CLI version of PHP
; valid values: 0, 1
; This is mostly for testing and debugging.
; the default value is 0
apc.enable_cli = 0

; Prevent files larger than this value to be cached
; the default value is 1 megabyte
apc.max_file_size = 1M

; Check scripts on each request to verify their modified status
; valid values: 0, 1
; Be careful when setting this value.
; On production servers where script files rarely change,
; a performance boost can be achieved by disabling stats.
; the default value is 1
apc.stat = 1

; Enable write lock
; valid values: On, Off
; Only one process will compile and cache an uncached script.
; the default value is On
apc.write_lock = On

; Log scripts excluded from being cached
; valid values: On, Off
; the default value is Off
apc.report_autofilter = Off

; Optimize include_once and require_once calls
; valid values: On, Off
; Be careful when setting this value, is experimental.
; the default value is Off
apc.include_once_override = Off

; Create an upload_key user cache entry
; valid values: On, Off
; the default value is Off
apc.rfc1867 = Off

; Key prefix to use for user cache entry
apc.rfc1867_prefix = "upload_"

; Hidden form entry name that activates APC upload progress
apc.rfc1867_name = "APC_UPLOAD_PROGRESS"

; Frequency that updates should be made to user cache entry
; This can take the form of a percentage of the total
; file size or a size in bytes optionally suffixed with
; "k", "m", or "g" for kilobytes, megabytes, or gigabytes
; the default value is 0
apc.rfc1867_freq = "0"

; Time a rfc1867 entry is allowed to idle in a slot
; the default value is 3600 seconds
apc.rfc1867_ttl = 3600

; Enable lock-free local shadow-cache processes
; valid values: On, Off
; the default value is Off
apc.localcache = Off

; Number of local shadow-cache processes
; Should be set to a sufficiently large value, approximately
; half of apc.num_files_hint setting.
; the default value is 512
apc.localcache.size = 512

; Enable APC handling of signals
; valid values: On, Off
; This setting may improve system stability when fatal signals
; are received and a large APC shared memory segment is configured.
; the default value is Off
apc.coredump_unmap = Off

; Use ctime timestamps, instead of mtime
; valid values: 0, 1
; the default value is 0
apc.stat_ctime = 0

; Canonicalize relative paths in no-stat mode
; valid values: On, Off
; the default value is On
apc.canonicalize = On

; Not documented
apc.preload_path

; Use SAPI request start time for TTL
; valid values: On, Off
; the default value is On
apc.use_request_time = On

; Record the md5 hash of files
; valid values: On, Off
; the default value is Off
apc.file_md5 = Off

; Enable lazy loading for functions
; valid values: 0, 1
; the default value is 0
apc.lazy_functions = 0

; Enable lazy loading for classes
; valid values: 0, 1
; the default value is 0
apc.lazy_classes = 0

; Default serializer for new cached objects
; valid values: php, igbinary
; the default value is php
apc.serializer = "php"
 
/etc/php.d/igbinary.ini
; Enable igbinary extension module
extension = igbinary.so

; Enable compact duplicate strings
; availabale options: On, Off
; the default option is On
igbinary.compact_strings = On

; Default serializer for new sessions
; availabale options: php, igbinary
; the default option is igbinary
session.serialize_handler = "igbinary"

/etc/php.d/memcache.ini
; Enable PECL memcache extension module
extension = memcache.so

; Use memcache as a session handler
; valid values: files, memcache
; the default value is memcache
;session.save_handler = "memcache"

; Comma separated list of servers to use for session storage
;session.save_path = "tcp://127.0.0.1:11211"

[memcache]
; Transparent failover to other servers, on errors
; valid values: On, Off
; the default value is On
memcache.allow_failover = On

; Maximum number of failover attempts
; Used only in conjunction with memcache.allow_failover option.
; the default value is 20
memcache.max_failover_attempts = 20

; Memory chunk size
; the default value is 32768
memcache.chunk_size = 32768

; Default TCP port number
; the default value is 11211
memcache.default_port = "11211"

; Hash strategy
; valid values: consistent, standard
; Set this value to consistent to enable consistent hashing which
; allows servers to be added or removed from the pool without
; causing keys to be remapped.
; the default value is consistent
memcache.hash_strategy = "consistent"

; Hash function
; valid values: crc32, fnv
; Controls which hash function to apply when mapping keys to servers,
; crc32 uses the standard CRC32 hash, while fnv uses FNV-1a.
; the default value is crc32
memcache.hash_function = "crc32"

; Protocol
; valid values: ascii, binary
; The binary protocol results in less traffic and is more efficient.
; the default value is ascii
memcache.protocol = "ascii"

; Redundancy
; valid values: 0, 1
; the default value is 1
memcache.redundancy = 1

; Session redundancy
; the default value is 2
memcache.session_redundancy = 2

; Data compression threshold
; the default value is 20000
memcache.compress_threshold = 20000

; Lock timeout
; the default value is 15
memcache.lock_timeout = 15

/etc/php.d/memcached.ini
; Enable PECL memcached extension module
extension = memcached.so

; Use memcached as a session handler
; valid values: files, memcached
; the default value is memcached
;session.save_handler = "memcached"

; Comma separated list of servers to use for session storage
;session.save_path = "127.0.0.1:11211"

[memcached]
; Use session locking
; valid values: On, Off
; the default value is On
memcached.sess_locking = On

; Session spin lock retry wait time in microseconds
; Be carefull when setting this value.
; valid values: integers, where 0 is interpreted as default
; Negative values result in a reduced locking to a try lock.
; the default value is 150000
memcached.sess_lock_wait = 150000

; Session key prefix
; valid values: strings less than 219 bytes long
; the default value is "memc.sess.key."
memcached.sess_prefix = "memc.sess.key."

; Session binary mode
memcached.sess_binary = Off

; Compression type
; valid values: fastlz, zlib
; the default value is fastlz
memcached.compression_type = "fastlz"

; Compression factor
; Store compressed value only if the compression
; factor (saving) exceeds the set limit.
; Store compressed if:
; plain_len > comp_len * factor
; the default value is 1.3 (23% space saving)
memcached.compression_factor = "1.3"

; Compression threshold
; Do not compress serialized values below this threshold.
; the default value is 2000 bytes
memcached.compression_threshold = 2000

; Default serializer for new memcached objects
; valid values: php, igbinary, json, json_array
; json - standard php JSON encoding. This serializer
; is fast and compact but only works on UTF-8
; encoded data and does not fully implement
; serializing. See the JSON extension.
; json_array - as json, but decodes into arrays
; php - the standard php serializer
; igbinary - a binary serializer
; the default value is igbinary
memcached.serializer = "igbinary"

/etc/memcached.conf
# Memcached Configuration Settings

# IP address to listen on
# the default value is INARR_ANY, any network interface
HOST="127.0.0.1"

# TCP port to listen on
# the default value is 11211
TCP_PORT="11211"

# UDP port to listen on
# Can be disabled by setting it to 0.
# the default value is 11211
UDP_PORT="11211"

# Unix socket path to listen on
# Using a socket will automatically disable networking support.
# the default value is /var/run/memcached/memcached.sock
SOCKET=""

# Client binding protocol
# available options: auto, ascii, binary
# the default value is auto
PROTOCOL="auto"

# Number of threads used to process incoming requests
# Not useful to set higher than the number of server CPU cores.
# the default value is 4
THREADS="4"

# Maximum memory to use for object storage
# the default value is 64 megabytes
MAX_BYTES="64"

# Maximum simultaneous connections
# the default value is 1024
MAX_CONNECTIONS="1024"

# Maximum sequential requests
# Prevents client starvation by setting a limit to the number
# of requests the server will process from a client connection.
# the default value is 20
MAX_REQUESTS="20"

# Multiplier factor for computing the size of item memory chunks
# the default value is 1.25
CHUNK_FACTOR="1.25"

# Minimum number of bytes for an item memory chunk
# the default value is 48 bytes
CHUNK_SIZE="48"

# Default size of each slab page
# Adjusting this value changes the item size limit, increases
# the number of slabs and overal memory usage.
# Choose a value between is 1 kilobyte and 128 megabytes.
# the default value is 1 megabyte
SLAB_SIZE="1m"

# Additional server options
OPTIONS=""
 
Thanks for the heads up on installing these...
Can you make me a favor and check the memcached stats? Let me know how is your waste, mines is HUGE on 1.1.14 with slab_reassign and slab_automove enabled. Deebs is gone missing in action, heh. See my previous post, related to this matter.
 
Thanks for the above posts Floren. I've made a few other changes to add Igbinary as the session.serialize_handler for PHP, and also changed APC apc.mmap_file_mask. I was previously using file backed mmap:

apc.mmap_file_mask = "/tmp/apc.XXXXXX"

I've now set this to a shared memory mmap

apc.mmap_file_mask = "/apc.shm.XXXXXX"

and straight away, disk IO has dropped quite a bit!

diskstats_iops-day.webp

Can you make me a favor and check the memcached stats? Let me know how is your waste, mines is HUGE on 1.1.14 with slab_reassign and slab_automove enabled. Deebs is gone missing in action, heh. See my previous post, related to this matter.

memcached_stats.webp
 
No, setting it to apc.shm uses shared memory. The previous setting I had was putting the files into the /tmp directory. They are now going into memory using the POSIX-style shm_open/mmap

If compiled with MMAP support by using --enable-mmap this is the mktemp-style file_mask to pass to the mmap module for determining whether your mmap'ed memory region is going to be file-backed or shared memory backed. For straight file-backed mmap, set it to something like /tmp/apc.XXXXXX (exactly 6 Xs). To use POSIX-style shm_open/mmap put a .shm somewhere in your mask. e.g. /apc.shm.XXXXXX. You can also set it to /dev/zero to use your kernel's /dev/zero interface to anonymous mmap'ed memory. Leaving it undefined will force an anonymous mmap.
 
No, setting it to apc.shm uses shared memory. The previous setting I had was putting the files into the /tmp directory. They are now going into memory using the POSIX-style shm_open/mmap
OK, I will update the .ini files into rpm's, as well here. :)

Edit: Done and done, the above settings updated and the rpm's for Redhat 5 and 6 generated and synced online... 8minutes, not bad, but I think you were faster than me. :)
 
Start memcached with -o slab_reassign,slab_automove and let me know if the waste is lower... your is double than mines, LOL.
Thanks, have changed my config file:

Code:
#Memory 32MB
-m 32
# default port
-p 11211
# user to run daemon nobody/apache/www-data
-u nobody
# only listen locally
-l 127.0.0.1
# Set Options
-o slab_reassign,slab_automove

and restarted
Code:
nobody   18265     1  0 08:46 pts/0    00:00:00 /usr/local/bin/memcached -u root -m 32 -p 11211 -u nobody -l 127.0.0.1 -o slab_reassign slab_automove
 
Code:
nobody  18265    1  0 08:46 pts/0    00:00:00 /usr/local/bin/memcached -u root -m 32 -p 11211 -u nobody -l 127.0.0.1 -o slab_reassign slab_automove
You are missing a comma? -o slab_reassign,slab_automove NOT -o slab_reassign slab_automove
Never mind, top is yanking the comma for myself also:
/usr/bin/memcached -d -l 127.0.0.1 -p 11211 -U 11211 -u memcached -P /var/run/memcached/memcached.pid -t 4 -m 64 -c 1024 -n 48 -f 1.25 -o slab_reassign slab_automove

How is the graph, is the waste lower?
 
Same here. How is your waste on the server? Even if I have the slabs set to auto recycle, I get a high waste:

View attachment 32661

It does not makes sense to me, is the waste managed when the max memory threshold hits? So far there is about 50% of allocated memory marked as free so maybe that why the slabs are sitting there...
I too have a lot of wasted space and also a large amount of free memory, to be honest I am not worrying about it. What I will do is telnet to the daemon and check the stats incase it is the GUI app getting confused.
 
Top Bottom