edoceo

How To: Memcached Installation & Configuration

Installing memcached §

~ # emerge -pv memcached
[ebuild   R   ] net-misc/memcached-1.4.5  USE="-debug -sasl -slabs-reassign -test" 0 kB

~ # emerge memcached

Configuring memcached §

Memcached configuration file lives in /etc/conf.d/memcached. Here's a reasonable example, 1GiB on internal network only.

MEMCACHED_BINARY="/usr/bin/memcached"
MEMUSAGE="1024"
MEMCACHED_RUNAS="memcached"
MAXCONN="2048"
LISTENON="10.101.105.109"
PORT="11211"
UDPPORT="${PORT}"
PIDBASE="/var/run/memcached/memcached"

Configure memcached to start on boot & start it now.

~ # rc-update -a memcached
~ # /etc/init.d/memcached start

Checking Status §

Memcache keeps track of the status of objects in the system, you can find this information using it's administrative interface

~ $ echo -en "stats\nquit\n" | nc -q1 localhost 11211
~ $ echo -en "stats\nquit\n" | nc -q1 -U /path/to/socket/file

Tuning memcached §

This is a larger subject than can be covered here but methods include:

  • Using persistent connections
  • Using special expirations for long persisting objects - in some cases 24h (or more) is acceptable
  • Using Multiple memcached Segements and/or Servers

See Also

Loading Comments from Disqus...