How To Install Memcached on Debian 11

how to install memcached on Debian

In this short article we will learn how to install Memcache on Debian 11 operating system.

Introduction

In the world of web applications and database-driven systems, performance is often a critical factor. To achieve blazing-fast response times, developers turn to various optimization techniques, and one such technique is caching. Memcached, a popular open-source, high-performance, distributed memory caching system, plays a vital role in accelerating data retrieval for applications. In this article, we’ll delve into Memcached, its features, use cases, and how to set it up on a Linux environment.

What is Memcached?

Memcached is an open-source, in-memory key-value store that acts as a cache to speed up data retrieval by storing frequently accessed data in RAM (Random-Access Memory). It was originally developed by Brad Fitzpatrick in 2003 and has since become a critical component of many high-traffic websites and applications.

Key Features of Memcached

1. In-Memory Data Storage
Memcached stores data in RAM, which is significantly faster to access than traditional disk-based storage. This makes it ideal for caching data that is frequently accessed.
2. Simple Key-Value Store
Memcached uses a simple key-value data model. You store data with a unique key, and you can later retrieve that data by specifying the same key.
3. Distributed Architecture
Memcached can be distributed across multiple servers, which enables horizontal scaling. This means that as your traffic grows, you can add more servers to handle the increased load.
4. Data Expiration
You can set a time-to-live (TTL) for each data item, so it’s automatically removed from the cache after a specific period. This helps ensure that you’re always working with fresh data.
5. High Performance
Memcached is known for its incredible speed. It’s designed to serve a high volume of requests quickly, making it a perfect choice for speeding up database queries and reducing load times for web applications.

How To Install Memacached On Debian 11

In this section we will install Memcached on Debian 11 operating system using APT package manager. The Memcached installation process on the Debian operating system consists of several steps, namely:

  1. Update Debian System
  2. Install Memcached and Libmemcached-tools on Debian
  3. Start and Enable Memcached

Step 1: Update Debian 11 System

It is a good habit to update the system first, before we install new package or applications. This task is to make sure if we are accessing the latest packages versions. This task will cut down the installation time. To update our packages software we will use command line :

$ sudo apt update
$ sudo apt upgrade

These commands will update our package list and upgrade outdated packages to the latest versions.

Step 2: Install Memcached and Libmemcached-tools on Debian

By default, Debian has equipped with Memcached in its repositories, making installation simple. To install Memcached on Debian 11 is only to run the following command:

$ sudo apt install memcached libmemcached-tools

Output :

ramansah@otodiginet:~$ sudo apt install memcached libmemcached-tools
[sudo] password for ramansah:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
memcached is already the newest version (1.6.9+dfsg-1).
The following packages were automatically installed and are no longer required:
fonts-lato libgmp-dev libgmpxx4ldbl libgnutls-dane0 libjs-jquery
libunbound8
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libmemcached11 libmemcachedutil2
The following NEW packages will be installed:
libmemcached-tools libmemcached11 libmemcachedutil2
0 upgraded, 3 newly installed, 0 to remove and 402 not upgraded.
Need to get 202 kB of archives.
After this operation, 625 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://deb.debian.org/debian bullseye/main amd64 libmemcached11 amd64 1.0.18-4.2 [94.5 kB]
Get:2 http://deb.debian.org/debian bullseye/main amd64 libmemcachedutil2 amd64 1.0.18-4.2 [22.3 kB]
Get:3 http://deb.debian.org/debian bullseye/main amd64 libmemcached-tools amd64 1.0.18-4.2 [85.1 kB]
Fetched 202 kB in 3s (58.7 kB/s) 
Selecting previously unselected package libmemcached11:amd64.
(Reading database ... 209077 files and directories currently installed.)
Preparing to unpack .../libmemcached11_1.0.18-4.2_amd64.deb ...
Unpacking libmemcached11:amd64 (1.0.18-4.2) ...
Selecting previously unselected package libmemcachedutil2:amd64.
Preparing to unpack .../libmemcachedutil2_1.0.18-4.2_amd64.deb ...
Unpacking libmemcachedutil2:amd64 (1.0.18-4.2) ...
Selecting previously unselected package libmemcached-tools.
Preparing to unpack .../libmemcached-tools_1.0.18-4.2_amd64.deb ...
Unpacking libmemcached-tools (1.0.18-4.2) ...
Setting up libmemcached11:amd64 (1.0.18-4.2) ...
Setting up libmemcachedutil2:amd64 (1.0.18-4.2) ...
Setting up libmemcached-tools (1.0.18-4.2) ...
Processing triggers for libc-bin (2.31-13+deb11u2) ...
Processing triggers for man-db (2.9.4-2) …

After the installation is completed done, then we need to verify it. To verify the Memcached installation we will use the following command line :

$ sudo apt-cache policy memcached

Output :

ramansah@otodiginet:~$ sudo apt-cache policy memcached
memcached:
Installed: 1.6.9+dfsg-1
Candidate: 1.6.9+dfsg-1
Version table:
*** 1.6.9+dfsg-1 500
500 http://deb.debian.org/debian bullseye/main amd64 Packages
100 /var/lib/dpkg/status

Step 3: Start and enable the Memcached service

In this section, we will make Memcached started and enable on the system. For this purpose we will use the following command line :

$ sudo systemctl start memcached
$ sudo systemctl enable memcached
$ sudo systemctl status memcached

Output :

ramansah@otodiginet:~$ sudo systemctl start memcached
ramansah@otodiginet:~$ sudo systemctl enable memcached
Synchronizing state of memcached.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable memcached
ramansah@otodiginet:~$ sudo systemctl status memcached
● memcached.service - memcached daemon
Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-10-11 00:06:20 EDT; 3h 51min ago
Docs: man:memcached(1)
Main PID: 603 (memcached)
Tasks: 10 (limit: 4623)
Memory: 2.5M
CPU: 2.866s
CGroup: /system.slice/memcached.service
└─603 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1 -P /var/run/memcached/memcac>

Start and enable Memcached

Conclusion

Memcached is a powerful tool for optimizing the performance of web applications and databases. By providing a blazing-fast, distributed, and in-memory caching system, Memcached significantly reduces the load on your database servers, leading to improved response times and an enhanced user experience. Whether you’re managing a high-traffic website, a database-driven application, or a complex API, integrating Memcached into your infrastructure can be a game-changer in terms of speed and scalability. In this article we have shown you how to install Memcached on Debian 11 operating system.

(Visited 88 times, 1 visits today)

Leave a Reply

Your email address will not be published. Required fields are marked *