
Introduction
Memcached is among the high-performance, distributed memory caching systems intended to improve the performance of dynamic database-driven websites by caching data and objects in RAM. This mitigates the frequency with which the database or API is prone to being slammed and thus speeds up the process of the data retrieval. This in turn can be used in combination with various CMS packages and programming languages that include PHP, Perl, Ruby, and Python. This makes it very versatile and fast at the same time, since it operates from the memory.
Installation
For the setup of Memcached:
apt-get install memcached -y
Configuration
The configuration can be done through the configuration file located at /etc/memcached.conf
:
nano /etc/memcached.conf
There are some configuration parameters that may need to be edited from the configuration file:
- p: The port to listen on (default is 11211).
- m: The amount of memory to use for the cache (default is 64 MB).
- c: The maximum number of allowed connections (default is 1024).
For instance, to make Memcached listen at port 12345, consume 2 GB of RAM, and allow a maximum of 1024 open connections, edit the file so that it contains the following:
memcached default config file
2003 - Jay Bonci
This configuration file is read by the start-memcached script provided as
part of the Debian GNU/Linux distribution._
Run memcached as a daemon.
Log memcached's output to /var/log/memcached
logfile /var/log/memcached.log_
Engage with a maximum of 2048 MB of memory
Listen on port 11211
Run the daemon as the memcache
user
Listening on localhost only
Set the maximum number of simultaneous incoming connections
Finalizing
When it's ready, start Memcached; enter:
service memcached start
If the program runs correctly, you should see something like this
You have set up and configured Memcached—the phenomenal tool and great deal of server efficiency is settling locally with commonly accessed data being cached in the memory. This should increase your server performance by minimizing loads from your database or whatever other sources of data you might have externally.