Memcached number of threads showing more than what were set

memcached

I started memcached server using 8 threads. Then I checked threads using ps -eLf | grep memcached

shantanu  2758     1  2758  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv
shantanu  2758     1  2759  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv
shantanu  2758     1  2760  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv
shantanu  2758     1  2761  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv
shantanu  2758     1  2762  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv
shantanu  2758     1  2763  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv
shantanu  2758     1  2764  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv
shantanu  2758     1  2765  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv
shantanu  2758     1  2766  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv
shantanu  2758     1  2767  0   10 11:17 ?        00:00:00 memcached -d -l 10.90.15.104 -p 11311 -t 8 -vv

Now as you can see, there are 10 number of threads showing when -t was set 8. I dont understand this. Am I doing some mistake in ps command? Please help me understand this phenomenon.

Best Answer

Check your memcached statistics, check threads.

telnet localhost 11211

stats

STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0

By default and all other setups i saw that memcached was allocating 2 threads for himself, without the -t parameter, so i guess memcached works by threads = 2 + threads_configured.

Try to increase or decrease to see if this explanation applies to your setup.