Are there any drawbacks to running memcached on a Unix domain socket instead of the network (assuming one server)?

I’m setting up a Django website to use memcached to cache its pages.

(The content of each page won’t change very often at all, so I’m hoping that most of the site will be served from memcached most of the time, and thus be able to handle a lot of traffic reasonably well.)

Both the website and memcached will run on one virtual server, running on Debian Squeeze.

Given that set-up, I thought I might set memcached to listen via a Unix domain socket (see http://code.google.com/p/memcached/wiki/NewConfiguringServer#Unix_Sockets), instead of over a network interface. Although my virtual server is pretty extensively firewalled, as I only need memcached to be to be accessible by a single local user (i.e. the Django site), I figure I might as well keep it restricted.

Are there any drawbacks to having memcached listen over a Unix domain socket, when both memcached and its client are on the same server? E.g. might a Unix domain socket be slower than listening on 127.0.0.1?

(Apologies for such a newbie question — as you can probably tell, I haven’t used memcached before, or done much with Unix/Linux.)


Typically the unix socket versus network port question breaks down like this:

Unix Socket Drawbacks

Can only be accessed localy

Unix Socket Benefits

Eliminates TCP/IP overhead

Network Drawbacks

Security TCP/IP overhead

Network Benefits

Services can be accessed over the network

I use this as a general guide to nearly any service, including memcached, MySQL, and other services.

This is drastically over simplified but is where I start.


If you are accessing memecached only locally, it IS recommended to listen only to the local IP address 127.0.0.1 or use unix socket.

This is a good practice even if you have a firewalled and protected environment. Image that you have moved your server out of this network to another untrusted network. So, you have to worry about securing your memcached port.