Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony2在多docker上的php7 fpm上运行极慢_Php_Symfony_Nginx_Docker_Docker Compose - Fatal编程技术网

Symfony2在多docker上的php7 fpm上运行极慢

Symfony2在多docker上的php7 fpm上运行极慢,php,symfony,nginx,docker,docker-compose,Php,Symfony,Nginx,Docker,Docker Compose,我正在尝试使用php7 fpm和nginx在多docker上设置symfony2环境 整件事都起作用了。然而,由于一些莫名其妙的原因,每个请求需要20-30秒才能完成(整个页面大约在5分钟内加载)。在加载过程中,CPU会出现峰值。我试着使用php fpm配置,nginx配置。甚至复制了我在另一个应用程序中使用的完全相同的应用程序,效果非常好。在这一点上,我被卡住了,我甚至不知道从哪里开始(继续) 我的docker-compose.yml如下所示: web: build: ./ conta

我正在尝试使用php7 fpm和nginx在多docker上设置symfony2环境

整件事都起作用了。然而,由于一些莫名其妙的原因,每个请求需要20-30秒才能完成(整个页面大约在5分钟内加载)。在加载过程中,CPU会出现峰值。我试着使用php fpm配置,nginx配置。甚至复制了我在另一个应用程序中使用的完全相同的应用程序,效果非常好。在这一点上,我被卡住了,我甚至不知道从哪里开始(继续)

我的docker-compose.yml如下所示:

web:
  build: ./
  container_name: indago_web
  external_links:
    - mysql:mysql
  volumes:
    - ./php-fpm/www.conf:/usr/local/etc/php-fpm.d/www.conf
    - ~/Dev/indago/indago:/var/www/indago
  environment:
    ING_DB_USER: priz_wp
    ING_DB_PASSWORD: Shurik_0(8
    ING_DB_NAME: priz_wp
    ING_DB_HOST: mysql
proxy:
  image: nginx
  container_name: indago_proxy
  links:
    - web:web
  ports:
    - "80:80"
  volumes:
    - ./web/nginx.conf:/etc/nginx/nginx.conf
    - ./web/default.conf:/etc/nginx/conf.d/default.conf
webapp的Dockerfile:

FROM php:7-fpm

RUN apt-get update && apt-get install -y vim \
    libxml2-dev libicu-dev \
    && rm -rf /var/lib/apt/lists/* && apt-get autoremove

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer --version

# Set timezone
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/America/Vancouver /etc/localtime
RUN "date"

RUN docker-php-ext-install pdo pdo_mysql opcache ctype json xml tokenizer mbstring iconv posix intl

RUN { \
        echo 'opcache.memory_consumption=128'; \
        echo 'opcache.interned_strings_buffer=8'; \
        echo 'opcache.max_accelerated_files=4000'; \
        echo 'opcache.revalidate_freq=2'; \
        echo 'opcache.fast_shutdown=1'; \
        echo 'opcache.enable_cli=1'; \
    } > /usr/local/etc/php/conf.d/opcache-recommended.ini


RUN { \
        echo 'upload_max_filesize = 100M'; \
        echo 'post_max_size = 100M'; \
    } > /usr/local/etc/php/conf.d/cutom.ini


CMD mkdir -p /var/www/indago

VOLUME /var/www/indago

CMD chown -R www-data:www-data /var/www/indago

WORKDIR /var/www/indago

#RUN usermod -u 1000 www-data
#USER www-data

CMD ["php-fpm"]
和default.conf

server {
    server_name indago-local.com www.indago-local.com;
    root /var/www/indago/web;

    location / {
        # try to serve file directly, fallback to app.php
        try_files $uri /app_dev.php$is_args$args;
    }
    # DEV
    # This rule should only be placed on your development environment
    # In production, don't include this and don't deploy app_dev.php or config.php
    location ~ ^/(app_dev|config)\.php(/|$) {
        fastcgi_pass web:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    # PROD
    location ~ ^/app\.php(/|$) {
        fastcgi_pass web:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/app.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }

    # return 404 for all other php files not matching the front controller
    # this prevents access to other php files you don't want to be accessible.
    location ~ \.php$ {
      return 404;
    }

    error_log /var/log/nginx/project_error.log;
    access_log /var/log/nginx/project_access.log;
}
在www.conf I中更新了
pm.max_children=20

nginx.conf非常简单(事实上,它不会改变任何东西)

作为一些补充信息,fpm容器上的memmory不会交换,我也不会在任何地方出现任何错误(在我计算孩子的数量之前,我已经把他们累坏了)


提前感谢您提供有关如何解决此问题的任何想法。

这对我来说并不清楚“在加载期间,CPU峰值。”-CPU遇到了一些峰值,或者在处理请求期间已完全加载?我脑海中有一个建议-由于DNS/主机配置不当,我在linux服务器上遇到了类似的问题。它不是Docker服务器,但可能会有帮助…@HonzaRydrych几乎完全加载,但如果我运行
top
,在执行过程中,每个正在运行的fpm进程约占15%。@HonzaRydrych不确定您在OS X或Windows上使用Docker是什么意思。您可以尝试删除容器并在没有任何卷的情况下重新启动它们(在
Dockerfile
docker compose.yml
中),特别是对于
供应商
var
文件夹,因为symfony应用程序强烈要求它们。
user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
  worker_connections  2048;
  multi_accept on;
  use epoll;
}

http {
  server_tokens off;
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 15;
  types_hash_max_size 2048;
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  access_log on;
  error_log on;
  gzip on;
  gzip_disable "msie6";
  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-available/*;
  open_file_cache max=100;
}