dongluanguang4774 2018-09-25 08:52
浏览 51

用户的多个过程

I looking how allow run multiple process for one user in symfony. I have this behavior in Symfony / Nginx / Php FPM but I test in clean symfony and php webserver:

composer create-project symfony/website-skeleton my-project

this is docker config :

version: "3.1"
services:
    webserver:
      image: nginx:alpine
      container_name: viz-webserver
      working_dir: /application
      volumes:
          - .:/application
          - ./docker/nginx/nginx_all.conf:/etc/nginx/nginx.conf
      networks:
           itb_net:
             ipv4_address: 10.2.0.6

    php-fpm:
      build: itb_docker/php-fpm
      container_name: php-fpm
      working_dir: /application
      networks:
        itb_net:
          ipv4_address: 10.2.0.8
      volumes:
      - ~/.ssh/:/root/.ssh/
      - .:/application
      - ./docker/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini
      - ./.aws/credentials:/var/www/.aws/credentials

php-ini-overrides.ini

upload_max_filesize = 200M
post_max_size = 208M
memory_limit =  4048M

php-fpm Dockerfile

FROM phpdockerio/php72-fpm:latest
WORKDIR "/application"

# Fix debconf warnings upon build
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get -y --no-install-recommends install php-zip php-xdebug php-gd php-xml php7.2-mysql php7.2-intl php7.2-tidy php7.2-xmlrpc php7.2-soap php7.2-bcmath php-mbstring php-curl\
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*



# Install git
RUN apt-get update \
    && apt-get -y install git acl wkhtmltopdf xvfb \
    && apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*

nginx

user nginx;
worker_processes  2;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /dev/stdout  main;

    #sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    gzip  on;


 server {


   #  limit_conn conn_limit_per_ip 10;

   #  limit_req zone=req_limit_per_ip burst=10 nodelay;

    fastcgi_keep_conn on;
    #proxy_buffering off;
    gzip off;

     listen 80 default;

     client_max_body_size 208M;

     access_log /var/log/nginx/application.access.log;

     root /application/public;

     rewrite ^/index\.php/?(.*)$ /$1 permanent;

     try_files $uri @rewriteapp;

     location @rewriteapp {
         rewrite ^(.*)$ /index.php/$1 last;
     }

     # Deny all . files
     location ~ /\. {
         deny all;
     }

     location ~ ^/(index)\.php(/|$) {
         fastcgi_pass php-fpm:9000;
         fastcgi_split_path_info ^(.+\.php)(/.*)$;
         fastcgi_index app_dev.php;
         send_timeout 1800;
         fastcgi_read_timeout 1800;
         fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
         fastcgi_param PHP_VALUE "error_log=/var/log/nginx/application_php_errors.log";
         fastcgi_buffers 16 16k;
         fastcgi_buffer_size 32k;
         include fastcgi_params;
     }

     # Statics
         location /(bundles|media) {
         access_log off;
         expires 30d;
         try_files $uri @rewriteapp;
     }}

}

test controller:

class TestController extends Controller
{

    /**
     * @Route("/test1")
     */
    public function aAction(){

        $i = 0;
        while($i<50){

            echo "$i<BR>";
            $i++;
            sleep(2);

        }
    }

    /**
     * @Route("/test2")
     */
    public function bAction(){

        return new Response('OK');
    }

}

and same result - go to /test1 and test2 in second tab = second tab wait to first finish.

  • 写回答

1条回答 默认 最新

  • douyanjing0822 2018-09-25 08:55
    关注

    The built-in PHP server is single-threaded. If you get a long or hanged request it can't serve the next request until the thread is free to serve the incoming request.

    As per http://php.net/manual/en/features.commandline.webserver.php

    The web server runs a only one single-threaded process, so PHP applications will stall if a request is blocked.

    评论

报告相同问题?

悬赏问题

  • ¥15 overleaf中论文编辑,报错`pages' is a missing field, not a string, for entry 4
  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么