daxio / k8s-lemp

LEMP stack in a Kubernetes cluster
GNU General Public License v3.0
80 stars 44 forks source link

Configure PHP to listen on a UNIX socket #2

Closed chepurko closed 7 years ago

chepurko commented 7 years ago

Configure PHP to listen on a UNIX socket instead of port 9000 and pass the socket file to the fastcgi_pass parameter in NGINX.

All that would need to be done is for the socket file to be on a shared volume between the NGINX and WP-FPM containers which are already inside of one pod. Then make the adjustment in the NGINX conf.

chepurko commented 7 years ago

Closing as we've switched to the standard WP/Apache image for simplicity.

Edit: we’re back to NGINX 😁

gentisaliu commented 6 years ago

This issue should be reopened as it is still relevant. Use sockets for less overhead.

chepurko commented 6 years ago

It would be more relevant on a traditional single machine with PHP and NGINX both running on it, as they are using the same file system, and the socket turns out to be just a file on the file system which both apps have access to.

In the Kubernetes case, we would need a PersistentVolume mounted or shared so both containers could access it - all for a little old socket file... Obviously the “overhead” of another mount is unnecessary.

Additionally I realised that the container and Kubernetes architecture overall is network-based, so this is akin to running the apps on separates machines (the apps can’t tell the difference between being in a container or on an actual machine). So network communication is the obvious choice.

Regarding overhead, remember that the containers are talking on the same physical machine, basically like it’s just localhost - no networking leaving the machine. So most likely not much slower or faster than using a single machine with socket communication.