memcached supports the following options:
If you start memcached as
root, use the
-uoption to specify the user for executing memcached:
shell> memcached -u memcache
Set the amount of memory allocated to memcached for object storage. Default is 64MB.
To increase the amount of memory allocated for the cache, use the
-moption to specify the amount of RAM to be allocated (in megabytes). The more RAM you allocate, the more data you can store and therefore the more effective your cache is.Warning
Do not specify a memory allocation larger than your available RAM. If you specify too large a value, then some RAM allocated for memcached uses swap space, and not physical RAM. This may lead to delays when storing and retrieving values, because data is swapped to disk, instead of storing the data directly in RAM.
You can use the output of the vmstat command to get the free memory, as shown in
shell> vmstat kthr memory page disk faults cpu r b w swap free re mf pi po fr de sr s1 s2 -- -- in sy cs us sy id 0 0 0 5170504 3450392 2 7 2 0 0 0 4 0 0 0 0 296 54 199 0 0 100
For example, to allocate 3GB of RAM:
shell> memcached -m 3072
On 32-bit x86 systems where you are using PAE to access memory above the 4GB limit, you cannot allocate RAM beyond the maximum process size. You can get around this by running multiple instances of memcached, each listening on a different port:
shell> memcached -m 1024 -p11211 shell> memcached -m 1024 -p11212 shell> memcached -m 1024 -p11213Note
On all systems, particularly 32-bit, ensure that you leave enough room for both memcached application in addition to the memory setting. For example, if you have a dedicated memcached host with 4GB of RAM, do not set the memory size above 3500MB. Failure to do this may cause either a crash or severe performance issues.
Specify a network interface/address to listen for connections. The default is to listen on all available address (
shell> memcached -l 192.168.0.110
Support for IPv6 address support was added in memcached 1.2.5.
Specify the TCP port to use for connections. Default is 18080.
shell> memcached -p 18080
Specify the UDP port to use for connections. Default is 11211, 0 switches UDP off.
shell> memcached -U 18080
Specify a Unix socket to listen on.
If you are running memcached on the same server as the clients, you can disable the network interface and use a local Unix socket using the
shell> memcached -s /tmp/memcached
Using a Unix socket automatically disables network support, and saves network ports (allowing more ports to be used by your web server or other process).
Specify the access mask to be used for the Unix socket, in octal. Default is 0700.
Specify the maximum number of simultaneous connections to the memcached service. The default is 1024.
shell> memcached -c 2048
Use this option, either to reduce the number of connections (to prevent overloading memcached service) or to increase the number to make more effective use of the server running memcached server.
Specify the number of threads to use when processing incoming requests.
By default, memcached is configured to use 4 concurrent threads. The threading improves the performance of storing and retrieving data in the cache, using a locking system to prevent different threads overwriting or updating the same values. To increase or decrease the number of threads, use the
shell> memcached -t 8
Run memcached as a daemon (background) process:
shell> memcached -d
Maximize the size of the core file limit. In the event of a failure, this attempts to dump the entire memory space to disk as a core file, up to any limits imposed by setrlimit.
Return an error to the client when the memory has been exhausted. This replaces the normal behavior of removing older items from the cache to make way for new items.
Lock down all paged memory. This reserves the memory before use, instead of allocating new slabs of memory as new items are stored in the cache.Note
There is a user-level limit on how much memory you can lock. Trying to allocate more than the available memory fails. You can set the limit for the user you started the daemon with (not for the
-u useruser) within the shell by using ulimit -S -l NUM_KB
Verbose mode. Prints errors and warnings while executing the main event loop.
Very verbose mode. In addition to information printed by
-v, also prints each client command and the response.
Extremely verbose mode. In addition to information printed by
-vv, also show the internal state transitions.
Print the help message and exit.
Print the memcached and
Specify the maximum size permitted for storing an object within the memcached instance. The size supports a unit postfix (
mfor megabytes). For example, to increase the maximum supported object size to 32MB:
shell> memcached -I 32m
The maximum object size you can specify is 128MB, the default remains at 1MB.
This option was added in 1.4.2.
Set the backlog queue limit. The backlog queue configures how many network connections can be waiting to be processed by memcached. Increasing this limit may reduce errors received by the client that it is not able to connect to the memcached instance, but does not improve the performance of the server. The default is 1024.
Save the process ID of the memcached instance into
Set the chunk size growth factor. When allocating new memory chunks, the allocated size of new chunks is determined by multiplying the default slab size by this factor.
To see the effects of this option without extensive testing, use the
-vvcommand-line option to show the calculated slab sizes. For more information, see Section 220.127.116.11, “memcached Logs”.
The minimum space allocated for the key+value+flags information. The default is 48 bytes.
On systems that support large memory pages, enables large memory page use. Using large memory pages enables memcached to allocate the item cache in one large chunk, which can improve the performance by reducing the number misses when accessing memory.
Disable the use of compare and swap (CAS) operations.
This option was added in memcached 1.3.x.
Set the default character to be used as a delimiter between the key prefixes and IDs. This is used for the per-prefix statistics reporting (see Section 16.2.4, “Getting memcached Statistics”). The default is the colon (
:). If this option is used, statistics collection is turned on automatically. If not used, you can enable stats collection by sending the
stats detail oncommand to the server.
This option was added in memcached 1.3.x.
Sets the maximum number of requests per event process. The default is 20.
Set the binding protocol, that is, the default memcached protocol support for client connections. Options are
auto. Automatic (
auto) is the default.
This option was added in memcached 1.4.0.