Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support connection via unix sockets #191

Open
pacohope opened this issue Oct 26, 2024 · 2 comments
Open

Support connection via unix sockets #191

pacohope opened this issue Oct 26, 2024 · 2 comments

Comments

@pacohope
Copy link

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
Copy link
Owner

Sounds reasonable to me 👍

@56quarters
Copy link
Owner

Rough plan of the code changes needed for this:

  • ServerName needs to be optional on the Server struct
  • TcpClientFactory needs to return an error if ServerName is None and --tls-server-name isn't supplied to prevent misuse
  • Add a From<Path> implementation for ServerID
  • Add a UnixClientFactory for creating clients from Unix sockets
  • Add logic to Discovery that creates servers from path-like things
  • Add logic anywhere MemcachedClient is created to possibly create a UnixClientFactory
  • Most of this needs to be gated behind Unix-only compile flags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants