Menu

1 / 5

Unix Socket vs TCP Loopback Between Containers in One Kubernetes Pod

DEV Community: php·Radovan Šmitala·about 13 hours ago
#IeJQ2D7r
#devto#dev#socket#request#optimized
Reading 0:00
15s threshold

Test workload: Apache and PHP-FPM as two containers in one pod. PHP 8.4, three configuration profiles, 42.7 million requests in the main runs, plus an optimisation ablation, an overload test and a cross-check on a second VM.

The short version

Yes, a Unix socket is faster than TCP loopback between two containers in the same pod. Here it is measured with Apache and PHP-FPM. Whether that matters to you depends on a few things.

Both variants run in the same Kubernetes pod ( httpd:2.4-alpine + php:8.4-fpm-alpine ) and differ only in how Apache talks to PHP-FPM: 127.0.0.1:9000 or /var/run/php-fpm/wordpress.sock . Load: wrk -t12 -c100 -d30s , 3 runs per cell.

This is a "hello world" test. The PHP script is <?php echo "bench"; ?> : no database, no framework, no application logic. That isolates the connection between Apache and PHP-FPM, and that is all the percentages below describe. They are not the speed-up a real application will see.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.