cPanel & WHM Version 94 has been released, and brings a slew of great updates. Take a look at what is included, and then upgrade today!

Plugin for per user memcached instance

Monarobase shared this idea 6 years ago
Open Discussion

Running a single instance of memcached on a shared cPanel server isn't safe and shouldn't be done.


Memcached can be run on a unix socket. If the socket is owned by a user then other users can't access his memcached cache.


We would like cPanel to create a memcached plugin so that each user could enable and disable memcached from their cPanel interface and also flush their cache.


Enabeling Memcached would create a new config file for memcached running as that user and using a unix socket in that users home dir.


From this plugin the user would need to be able to enable, disable and flush memcached memory. The plugin would also make sur that the process starts when the server starts if memcached is enabled.

Best Answer
photo

After a long planning session, we've decided to hold back on this a bit. While this was one of the initial caching systems we wanted to provide with EasyApache 4, we feel that our time is better served getting Nginx and other caching systems out the door quicker. I hope that we'll be able to assist anyone with their Plugins to get them working that will allow other customers and users the ability to spin up memcached instances for their users. We'll revisit this later down the line in hopes we'll be able to get this going.

Comments (8)

photo
1

We are hoping to hear other opinions on this request. Implementing memchache instances for each user would be a very heavy burden on the server's memory which could make this very difficult to deploy.


Have you considered how to deal with the memory demands of multiple memcache instances?

photo
2

We are currently programming such a plugin with help of your support.


For each memcached instance you can limit the number of keys and the amount of memory. Using a seperate config file for each user the plugin could be able to enven vary the amount of memory allowed based on a value chosen for each user.


For large hosts I don't think memory is rearly an issue. I've seen servers with up to 1TB of ram and we currently have 256GB on our servers.


We will run each memcached instance as the actual user, this will allow us to limit them to their Cloudlinux continer limit.


To give an idea, MySQL on our cPanel servers often uses up to 70GB of cache. If we were to allow users to use 128MB in memcached, out of say 1500 users, only 500 would proably enable it using up say 50% of their allowed memory on average so that makes around 32GB of Ram on a large server (1500 users).


The idea is to disable memcached for users by default and have them enable it.


Our plugin that we will give to cPanel once it all works currently allows to restart and stop memcached as well as show stats and flush cache from a user account and we're close to being able to enable / disable it for the users by adding and removing a config file.


Our idea is to finish the plugin for our usage and provide it to cPanel so cPanel has got a working "proof of concept" if they decide to implement it.

photo
1

I am interested in the plugin when you get something running.

photo
1

Hello,


Our plugin never made it to the finished working stage due to lack of time and the complexity of allowing a user to run a secure /etc/init.d/memcached username start command from withing a plugin.


We had a command from root to enable memcached for a user, disable it, start, stop and restart for a user as well as start, stop, restart memcached for all users.


Our initial code for the plugin allowed you to view the memcached stats for that user (uptime, memory used etc) and clear that users cache but we never got the commands that had to be run with a root user working securly.


I've sent our files to Jacob at cPanel and hope they will be of some help in getting memcached per user officially included in cPanel.

photo
1

It's not secure as it's port based allowing anyone to access your memcached instance, empty and edit your cache if they just find your port.


Cpanel could maybe allow webhosts to specify if they want it to be port or socket based.


If I where to do this again, I think I would moniter the existance of a file in the users account to setup memcached for him if the file existed, but cpanel should be able to do this in a faster way so the user clicks enable memcached to start it, disable memcached to stop it and maybe even choose the amount of memory he requires within a limit set by his host

photo
photo
1

Hello,


We are now waiting to see what cPanel does on the plugin side, we might develop a simple plugin to just show memcached stats and allow the user to clear his cache if cPanel doesn't do something in the next few versions.


On CentOS 6 we have one init script for all users, service memcached start|stop|status|restart restarts, stops etc. memcached for all users, service memcached start|stop|restart|status USERNAME, starts memcached for only one user.


We created a simple shell script to generate user config filles so we call memcached_addconfig USER and memcached_delconfig USER in a post account creation hook (we do it manually for the moment). This scripts créeates .memcached/run folder in the user account so we can run the socket in ~/memcached/memcached.sock and put the pid file in .memcached/run/memcached.pid


On CentOS 7 we will be doing the same but with a seperate init script per user and a script to start|restart|stop|status all memcached_* scripts at the same time.


For the moment we're starting tests manually on CentOS 6 for a few customers and we'll work on the hooks later to setup memcached automaticaly on accounts if it all works well.


We would like to allow users further actions like enable or restart their own memcached instance, change the amount of memory for memcached and disable memcached if they don't need it. These would require root commands so we are leaving this to cPanel as we haven't found a way to do this safely from within a plugin.

photo
1

Any chance you can put the code on github so we can all lend a helping hand?

photo
1

Sorry, the plugin part is almost unusable, and the scripts would need to be completly rewritten for centos 7.


For centos 7 we currently are looking into creating a systemd memcached_USERNAME.service script per user, a folder in the user's account (.memcached) for the socket and the pid file, and create a shell script to stop, start and restart all .service scripts that begin with 'memcached_'.


Our plugin was never able to start services, so was completly useless and requires cPanel to implement this.

photo
1

I completely understand, however that's where the community can help. For example, I would completely avoid systemd, or initd scripts, and manage it all with cPanel hooks or maybe even an intermediary monitoring daemon. At no point should a user have direct access to restart a service.

photo
1

After a long planning session, we've decided to hold back on this a bit. While this was one of the initial caching systems we wanted to provide with EasyApache 4, we feel that our time is better served getting Nginx and other caching systems out the door quicker. I hope that we'll be able to assist anyone with their Plugins to get them working that will allow other customers and users the ability to spin up memcached instances for their users. We'll revisit this later down the line in hopes we'll be able to get this going.

photo
1

Memcached plus mod_ruid2 or itk is absolutely essential.

photo
1

Apples to oranges. Apache MPM's are completely unrelated to Memcached implementations :)

photo
1

How can you implement via EA?

photo
1

This feature request is not for PHP's memcache module but for memcached itself.


You can already install memcache in cPanel's module installer as it is a PECL extension. However the PHP memcache extension just allows PHP to communicate with memcached so you still need memcached to be installed.

photo
Leave a Comment
 
Attach a file