56quarters / mtop

mtop: top for Memcached
GNU General Public License v3.0
12 stars 1 forks source link

Support connection via unix sockets #191

Open pacohope opened 3 weeks ago

pacohope commented 3 weeks ago

Hi there, this looks like a cool tool.

I have some systems where I have a web server, MariaDB server, and memcached all running on the same VM. To reduce overhead and to improve security, I use Unix sockets to communicate with memcached. I launch memcached like: memcached -s /var/run/memcached/memcached.sock.

When configured to listen on a unix socket, memcached does not use TCP/UDP. So it's not an option to have my web process use the unix socket and have mtop connect via TCP/IP. memcached makes it one or the other.

There is a blog (admittedly 8 years old) that suggests unix sockets perform much faster than TCP/IP to localhost. I intuitively think its probably right, though I haven't performed my own benchmarks.

mtop would need to support unix sockets for me to monitor my memcached processes on these systems. It's not possible to specify /var/run/memcached/memcached.sock on the command line. mtop just tries to look that up as a hostname.

A couple ways to do it. A separate option like -s /path/to/socket where the -s indicates unix sockets, or simply look at what was provided as a hostname. If it begins with a /, interpret it to mean a unix socket, otherwise interpret it to be a hostname.

56quarters commented 3 weeks ago

Sounds reasonable to me :+1: