Memcached: open-source In-Memory DataStore
Memcached is a general-purpose distributed memory-caching system.
It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source must be read.
Written in: C
Project Goals
- Memcached's APIs provide a very large hash table distributed across multiple machines.
- When the table is full, subsequent inserts cause older data to be purged in least recently used (LRU) order.
- Applications using Memcached typically layer requests and additions into RAM before falling back on a slower backing store, such as a database.
Project Features
- Memcached uses a client-server architecture.
- It maintains a key-value associative array. The clients populate this array and query it by key.
- If all client libraries use the same hashing algorithm to determine servers, then clients can read each other's cached data.
Project Design and Security
- Clients use client-side libraries to contact the servers which, by default, expose their service at port 11211. Both TCP and UDP are supported.
- Each client knows all servers; the servers do not communicate with each other. If a client wishes to set or read the value corresponding to a certain key, the client's library first computes a hash of the key to determine which server to use. This gives a simple form of sharding and scalable shared-nothing architecture across the servers.
- Most deployments of Memcached are within trusted networks where clients may freely connect to any server. However, sometimes Memcached is deployed in untrusted networks or where administrators want to exercise control over the clients that are connecting. For this purpose Memcached can be compiled with optional SASL authentication support. The SASL support requires the binary protocol.
Sample Configuration
## Sample Configuration for Memcached @ /etc/memcached.conf
# Run memcached as a daemon
-d
# Run memcached as unprivileged user
-u memcached
# Default connection port is 11211 (TCP and UDP)
-p 11211
-U 11211
# IP address to listen on
-l 127.0.0.1
# Log file
logfile /var/log/memcached.log
# Set total memory for memcached to 64 megabytes
-m 64
# Set max object size to 4 megabytes (default is 1 megabyte)
-I 4m
# Limit the number of simultaneous incoming connections (default is 1024)
-c 512
## END