When connecting to a local MySQL instance, you have two commonly used methods: use TCP/IP protocol to connect to local address – “localhost” or 127.0.0.1 – or use Unix Domain Socket.
If you have a choice (if your application supports both methods), use Unix Domain Socket as this is both more secure and more efficient.
How much more efficient, though? I have not looked at this topic in years, so let’s see how a modern MySQL version does on relatively modern hardware and modern Linux.
Benchmarking TCP/IP Connection vs Unix Domain Socket for MySQL
I’m testing Percona Server for MySQL 8.0.19 running on Ubuntu 18.04 on a Dual Socket 28 Core/56 Threads Server. (Though I have validated results on 4 …[Read more]