Linking nginx and php-fpm container together for fast interaction in docker prod

余生颓废 提交于 2019-12-08 02:05:48

问题


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 ...

来源:https://stackoverflow.com/questions/49009616/linking-nginx-and-php-fpm-container-together-for-fast-interaction-in-docker-prod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!