You probably have heard about “memcached”, right? It’s a high-performance, distributed memory object caching server that can dramatically improve the performance of a database and web applications. Memcached is an open-source software that reduces the load on the database and thus, speeds things up.
Today, let’s get memcached ready on our Ubuntu machine.
At first, make sure that your system is ready with all the latest updates.
sudo apt update && sudo apt upgrade -y
Now, run the following command for installing memcached server –
sudo apt install memcached
Configuring memcached server
For configuring the memcached server, you have to edit “memcached.conf” file. Run the following command –
sudo gedit /etc/memcached.conf
At first, start up with a memory cap of 512MB –
For connection, the default port of memcached is 11211.
Now, it’s time to tell which IP address to listen on. By default, the memcached server will listen to all IP addresses. This is the only parameter you can configure for security. Make sure that the server is listening to a firewalled interface.
You can also cap the incoming simultaneous connections. The default daemon value is 1024. Let’s increase it to 2048.
Now, save the file and restart the memcached server.
Need to verify that memcached is running? We need the “libmemcached-tools” for testing purpose.
sudo apt install libmemcached-tools
Check if memcached connectivity is working –
Restart, stop and reload memcached
If you’re going to use memcached, you may need to perform the above actions.
- Start memcached
sudo systemctl start memcached
- Stop memcached
sudo systemctl stop memcached
- Restart memcached
sudo sytemctl restart memcached
- Memcached status
sudo systemctl status memcached
For enjoying memcached features in other languages, you need to get additional packages –
- ruby-dalli (Ruby client)
- php-memcached (PHP module)
- python3-pymemcache (Python 3.x implementation)
- python-memcache (Python client)
- libcache-memcached-libmemcached-perl – (Perl for Memcached::libmemcached)