How to connect to Redis with Unix sockets in Docker

Click for: original source

Jonathan Baldie short tutorial addressing speed of Redis connection. Connecting to Redis via Unix sockets is usually faster than connecting via TCP/IP.

That’s because in general, Unix sockets have much less overhead. They’re essentially just files that Unix-based systems can read. The downside of that being that only local connections are possible.

A 14% speed difference is significant and we should take advantage of this even when using Docker.

The most systems based on Docker are set up to connect to Redis via Docker’s own TCP bridge networking. So how can we use Unix sockets? We can take advantage of shareable Docker volumes so we can use Unix sockets even in containers environment.

We can use the busybox image for this volume container because this container won’t actually be doing anything other than holding the volume. We also can use volumes_from option to extra the same volume from the busybox container. Good article with detailed code examples and explanation.

[Read More]

Tags docker containers kubernetes