PHP-FPM + Nginx on Kubernetes PHP-FPM + Nginx on Kubernetes kubernetes kubernetes

PHP-FPM + Nginx on Kubernetes


This is a good question because there is an important distinction that gets elided in most coverage of container architecture- that between multithreaded or event-driven service applications and multiprocess service applications.

Multithreaded and event-driven service applications are able with a single process to handle multiple service requests concurrently.

Multiprocess service applications are not.

Kubernetes workload management machinery is completely agnostic as to the real request concurrency level a given service is facing- agnostic in the sense that different concurrency rates by themselves do not have any impact on automated workload sizing or scaling.

The underlying assumption, however, is that a given unit of deployment- a pod- is able to handle multiple requests concurrently.

PHP in nearly all deployment models is multiprocess. It requires multiple processes to be able to handle concurrent requests in a single deployment unit. Whether those processes are coordinated by FPM or by some other machinery is an implementation detail.

So- it's fine to run nginx + FPM + PHP in a single container, even though it's not a single process. The number of processes itself doesn't matter- there is actually no rule in Docker about this. The ability to support concurrency does matter. One wants to deploy in a container/pod the minimal system to support concurrent requests, and in the case of PHP, usually putting it all in a single container is simplest.


Concept of micro-service architecture is to run every service individually in different clusters i.e., a cluster of nginx and a cluster of php-fpm. (Cluster > Pod > Containers)

Now these clusters should be communicating with other so that nginx and php-fpm can work properly.

As for the main part, where to put my code.For this you can use many plugins working based on api i.e., digitalocean, s3 etc.If you want to mount them on your drive, then are mountpoints parameter available in kubernetes.