The server for the worm is running on a standalone basis. It is estimated that php-fpm and redis can coexist on a single machine for a long time, in addition to MySQL. (say that the server has already reached a single day 20 million + dynamic request, so I am very optimistic about the large flow of the single-machine to get the worm)
If it is a stand-alone service, actually do not need to use IP even 127.0.0.1 such IP to connect mysql/redis/php, because even 127.0.0.1 is to go to the TCP/IP layer.
UNIX provides a UNIX socket for single-machine port access, and many articles refer to using a UNIX socket to increase connection speed.
I tested it briefly, 200 Redis requests take 38ms, if changed to UNIX socket, immediately dropped to 27ms. This is almost instantaneous, 10ms gap is enough to let us have the power to change the IP to UNIX socket mode.
Mysql (PDO) method for enabling UNIX sockets
1. In the PDO DSN: Original write host:xxx, change to Unix_socket:/var/run/mysqld/mysqld.sock (of course you can be in my.cnf inside set into another)
2. Give MySQL user name @localhost, set access rights. Because Unix_socket is not the host, so using the UNIX socket connection Mysql,mysql will be forced to think that the user is from localhost, so be sure to [email protected] Set permissions, not [email Protected] '% '
Redis (Phpredis) method for enabling UNIX sockets
1.redis does not open the UNIX socket by default and needs to be modified in/etc/redis/redis.conf. Note Unixsocketperm 777
Unixsocket/var/run/redis/redis.sockunixsocketperm 777
2. Connect with Phpredis:
$redis->connect ('/var/run/redis/redis.sock ')
Nginx + php-fpm How to enable UNIX sockets
1.PHP-FPM in the pool configuration file:
Listen =/var/run/php5-fpm.sock;
In the 2.nginx sites configuration file:
Fastcgi_pass Unix:/var/run/php5-fpm.sock;
Because of the number of Redis connections, Redis uses UNIX sockets the most obvious, MySQL second, PHP basically no use of sock are almost
Turn: Use UNIX sockets to accelerate PHP-FPM, MySQL, and Redis connections