Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Using Sockets

darkalchemy edited this page Nov 3, 2019 · 10 revisions

When setting SOCKET = true, it will use sockets for memcached, redis and MySQL. So, be sure that you have those servers configured to use sockets. MySQL and redis can be configured to use both port and unix socket. But, memcached can not, it must be either one, not both.

I use '/dev/shm' since its in ram and should be faster to connect to, you can change this to any location, as needed.

I have read that connecting via socket can be as much as 30% faster than through TCP.

mysql.cnf

socket   = /var/run/mysqld/mysqld.sock

memcached.conf

#-p 11211
#-l 127.0.0.1
-s /dev/shm/memcached.sock
-a 664
-c 10240

redis.conf

port 0
unixsocket /dev/shm/redis.sock
unixsocketperm 664

for both memcached and redis, you may need to add www-data and your username to the others group

sudo usermod -a -G memcache www-data
sudo usermod -a -G www-data memcache
sudo usermod -a -G redis www-data
sudo usermod -a -G www-data redis

sudo usermod -a -G memcache $USER
sudo usermod -a -G $USER memcache
sudo usermod -a -G redis $USER
sudo usermod -a -G $USER redis

After this, you may need to restart the server for this to take effect.