Recommended memcached installation method for multi-user support

SimpleTechGuy

Well-Known Member
Mar 22, 2021
64
21
8
United States
cPanel Access Level
Root Administrator
Hi, I've got a server with about 9 or 10 wordpress installations; looking at memcached as an object caching solution but still a little unclear on the proper method of installation.

The goal is to have memcached working for all of the wordpress based user accounts. From what I can tell it sounds like there are at least a couple of different methods of installing memcached on Almalinux8. It looks like I could install it directly on the server, or through podman with containers.

If I go with the container approach, it sounds like I would need to first setup EasyApache 4 Containers , then I would need to add the ea-php*-php-memcached extension in EA4 tools and install the ea-memcached16 package to each account container individually (is there a easy way to bulk install for all users?). This is where I get a little confused. How would I get wordpress to recognize memcached? This method would allow each account to have it's own seperate instance of memcached (great for security), but this would also use up more system resources as each account would need to have a dedicated container. Using this method is it possible to control how much memory is allocated to each individual user?

Alternatively, memcached could be installed directly on the server, but as far as I can tell, this approach only works for the server, and each individual user account would not have access, or if they were somehow given access, they would all be sharing the same resources which could lead to unfair memory usage and/or data leaks between accounts.

Wondering if anyone could suggest a recommended solution. Also, if you are using memcached; how did you install it and have you experienced any issues with functionality and or security?

Thanks,

References:
 
Last edited by a moderator:

ResellerWiz

Well-Known Member
Mar 24, 2023
150
66
103
USA
cPanel Access Level
Root Administrator
Twitter
It's pretty easy to install memcached.

Run the following command as root:

yum -y install memcached

Then use EA4 to install the phpXX-php-memcached PHP modules for the PHP versions you need it.
 

SimpleTechGuy

Well-Known Member
Mar 22, 2021
64
21
8
United States
cPanel Access Level
Root Administrator
Awesome, thank you @ResellerWiz! That is definitely easy enough lol, looks like the method for installing server wide. I guess I'm trying to figure out if there is any built in security with this option that would prevent memory leaks between user accounts and to control how much memory us available per user.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,505
2,605
363
cPanel Access Level
Root Administrator
You might want to check the "Creating a Secure Memcached Configuration" option in our post here to see one way to secure that:


However, like any server without CloudLinux, there aren't going to be ways to control memory limits at the user level.
 
  • Like
Reactions: SimpleTechGuy

SimpleTechGuy

Well-Known Member
Mar 22, 2021
64
21
8
United States
cPanel Access Level
Root Administrator
Thank you @cPRex, that blog post confirmed exactly what I was worried about. Specifically this:

Before we begin, a word of warning: the method outlined here should only be used on single-tenant dedicated servers, such as cPanel solo and virtual server hosting. It is not suitable for multi-tenant shared hosting environments without additional configuration to enable authentication or encryption.
it's really starting to sound like the best option for a multi-user / multi-tenant setup is to install EasyApache 4 Containers (ea-podman) and use memcached (ea-memcached16) as a socket inside the container. This way each user has it's own version of memcached which is isolated by the socket inside the container registered to that user account.

So. I'm thinking the install would look something like this:

Install EasyApache 4 Container package on the root server:
dnf install ea-podman-repo
dnf install ea-podman
dnf install ea-tomcat100


Login to each user account via ssh and install EA4 memcached package into the users container:
/usr/local/cpanel/scripts/ea-podman install ea-memcached16

Get the container name:
/usr/local/cpanel/scripts/ea-podman containers

Figure out how to get wordpress to recognize the new socket:
To use Memcached with your applications, direct your application to use the ~/container-name/memcache.sock socket.

Does this sound about right?
 

ResellerWiz

Well-Known Member
Mar 24, 2023
150
66
103
USA
cPanel Access Level
Root Administrator
Twitter
That all does sound right to me, although I still think you'd have more CPU and RAM control with CloudLinux.
Agreed. Was going to suggest CloudLinux as well.
 
  • Like
Reactions: SimpleTechGuy

WorkinOnIt

Well-Known Member
Aug 3, 2016
312
54
78
UK
cPanel Access Level
Root Administrator
Jumping in to ask a question:

Before we begin, a word of warning: the method outlined here should only be used on single-tenant dedicated servers, such as cPanel solo and virtual server hosting. It is not suitable for multi-tenant shared hosting environments without additional configuration to enable authentication or encryption.
Why is it not suitable for a shared server? I thought the whole point of memcached was to try to reduce server resources being used - and that's typical of a shared server.

... It is not suitable for multi-tenant shared hosting environments without additional configuration to enable authentication or encryption.
I'd like to install on my test server and have a play: So where can I find out the additional configuration needed to enable operation on a shared server?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
16,505
2,605
363
cPanel Access Level
Root Administrator