2

Our memcached.conf has the following directive:

-m 7168

And the server has 8GB of RAM. However, despite heavy use, memory usage never goes above 2GB:

# free
             total       used       free     shared    buffers     cached
Mem:       8178532    2067308    6111224          0     109092     434916
-/+ buffers/cache:    1523300    6655232
Swap:            0          0          0

What are we missing?

Seth
  • 433
  • 1
  • 4
  • 8
  • 2
    What makes you think you are caching enough object in memcached to consume more than that? – EEAA Nov 10 '15 at 19:04
  • Good question. Which memcstat counters would help me determine that? – Seth Nov 10 '15 at 19:09
  • No idea - I've never managed a memcached system. You should just wire up a little test script to continually add items to memcached and see what happens to memory usage. – EEAA Nov 10 '15 at 19:10

1 Answers1

4

Normally, memcached uses only as much memory as it needs, even if you give a maximum limit. It's not like the Linux system buffers that by design can expand to fill all the available memory in order to improve system performance.

You can telnet to your memcache and issue the commands

stats
stats slabs
stats malloc

which should give you an idea about how many objects of which sizes are in your memcache and how much memory they occupy.

If memcached does not have enough memory to store all your objects, it will evict older objects, which will increment the "evictions" counter returned by slabs. If "evictions" is at 0, then your memcache has enough memory.

You can find many other useful commands and solutions at "the memcached cheat sheet" at http://lzone.de/cheat-sheet/memcached

Law29
  • 3,557
  • 1
  • 16
  • 28