2

For my symfony project i am using a classic nginx/mysql/php-fpm image combination. For both (fpm and nginx) i use a local mount to the docker container to make the source code available. So that is very slow, but bearable with nfs extension for docker.

In prod environment i prepare the images so, that the local src code is copied to the php-fpm image and a named volume is afterwards created in the docker compose file for the nginx container. So i can connect php-fpm and nginx to make them using the same php files.

Thats basically working.

My problem is, that its still slow to get a site response although i thought that the reason was the slow file mount on my local machine. But still on a native linux production environment, its still slow. And partially slower than on my local dev environment with docker under mac!

For example: - Loading a symfony page displaying 192 Entities on my local machine with mount and nfs mount extension tooks 12 seconds.

  • On the previouse natively installed prod environment without docker (installed all middleware manually) the same view tooks 1-2 seconds to render.

  • now on prod environment with docker it takes 16(!) seconds to load this view.

What can i do to run my system faster?

Is the problem still the mount between nginx and php-fpm? Or this this an generally problem with communication over multiple docker container?

One thought was to don't use fpm/nginx combination at all, instead going for apache with php module. So only one container is needed. We are not especially bound to nginx or apache.

Another question: Is it really needful to have the source code in both images (php/nginx)? Or can i save up

Update:

I deinstalled xdebug, that save 1-2 seconds, but its still around 10 seconds ... thats too slow!

For staging its fine, but later for production its very bad ...

Jim Panse
  • 2,220
  • 12
  • 34
  • If you don't need separate containers - one for nginx and one for php-fpm, why don't you create single container with it ? [DockerHub - nginx+php-fpm](https://hub.docker.com/r/richarvey/nginx-php-fpm/) – Alexey Chuhrov Feb 27 '18 at 13:28
  • 3
    Because i wanted to follow the dockerish way to create single container for each task. Therefore i could also ask me, why i don't use just one container for all (mysql,php,fpm..) – Jim Panse Feb 27 '18 at 13:45
  • I'm experiencing the same issue. I'm getting seconds of latency for an application that normally returns a response in <100ms. Seems I will need to combine PHP + Nginx but this means not doing things the Docker way and not being able to use official images. 10 seconds is very slow though. If you're on a Mac you should add "cached" or "delegate" after you mount your volume, this helped Mac users I was working with. – alvinc Aug 02 '18 at 17:27
  • Did you ever learn more about this? I wonder if it was a socket vs tcp/ip issue? Your original prod server probably had something like `fastcgi_pass unix:/var/run/php-fpm.sock;` in the nginx config, but with nginx in a different container you would need something like `fastcgi_pass :9000` which as I understand it would be a tcp/ip connection. [There should be *some* performance difference](https://stackoverflow.com/questions/42704763/what-are-the-differences-from-running-php-fpm-over-an-unix-socket-vs-a-tcp-ip-so), but not as much as you were seeing, I think ... ? – Don't Panic Apr 04 '19 at 08:56

0 Answers0