Bläddra i källkod

Update php-ngx (#5572)

* Try opcache cli

* Less aggressive nginx.conf

* 4x workers per cpu core

* Separate the db tests
Joan Miquel 5 år sedan
förälder
incheckning
2911491443

+ 17 - 0
frameworks/PHP/php-ngx/benchmark_config.json

@@ -4,6 +4,23 @@
     "default": {
       "plaintext_url": "/hello",
       "json_url": "/json",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "None",
+      "framework": "None",
+      "language": "PHP",
+      "flavor": "PHP7",
+      "orm": "Raw",
+      "platform": "ngx_php",
+      "webserver": "nginx",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "PHP-raw-ngx",
+      "notes": "ngx_php",
+      "versus": "php"
+    },
+    "mysql": {
       "db_url": "/db",
       "query_url": "/query?queries=",
       "fortune_url": "/fortune",

+ 1 - 1
frameworks/PHP/php-ngx/deploy/conf/php.ini

@@ -1764,7 +1764,7 @@ ldap.max_links = -1
 opcache.enable=1
 
 ; Determines if Zend OPCache is enabled for the CLI version of PHP
-;opcache.enable_cli=0
+opcache.enable_cli=1
 
 ; The OPcache shared memory storage size.
 ;opcache.memory_consumption=128

+ 4 - 18
frameworks/PHP/php-ngx/deploy/nginx.conf

@@ -2,13 +2,13 @@ user www-data;
 worker_cpu_affinity auto;
 worker_processes  auto;
 error_log stderr error;
-worker_rlimit_nofile 1024000;
-timer_resolution 1000ms;
+#worker_rlimit_nofile 1024000;
+timer_resolution 1s;
 daemon off;
 pcre_jit on;
 
 events {
-    worker_connections 1000000;
+    worker_connections 100000;
 	multi_accept off;	 
 }
 
@@ -23,7 +23,7 @@ http {
     tcp_nodelay on;
     keepalive_timeout 65s;
     keepalive_disable none;
-    keepalive_requests 10000000;
+    keepalive_requests 100000;
 
     php_ini_path /deploy/conf/php.ini;
 
@@ -39,20 +39,6 @@ http {
 
         php_keepalive 256;
 
-        location = /hello {
-            content_by_php '
-                ngx_header_set("Content-Type", "text/plain");
-                echo "Hello, World!";
-            ';
-        }
-
-        location = /json {
-            content_by_php '
-                ngx_header_set("Content-Type", "application/json");
-                echo json_encode(["message" => "Hello, World!"]);
-            ';
-        }
-        
         location = /fortune {
 	        content_by_php '
                 fortune();

+ 2 - 2
frameworks/PHP/php-ngx/deploy/nginx_async.conf

@@ -7,7 +7,7 @@ daemon off;
 pcre_jit on;
 
 events {
-    worker_connections 1000000;
+    worker_connections 100000;
 	multi_accept off;	 
 }
 
@@ -21,7 +21,7 @@ http {
     tcp_nodelay on;
     keepalive_timeout 65s;
     keepalive_disable none;
-    keepalive_requests 10000000;
+    keepalive_requests 100000;
 
     php_ini_path /deploy/conf/php.ini;
 

+ 52 - 0
frameworks/PHP/php-ngx/deploy/nginx_default.conf

@@ -0,0 +1,52 @@
+user www-data;
+worker_cpu_affinity auto;
+worker_processes  auto;
+error_log stderr error;
+#worker_rlimit_nofile 1024000;
+timer_resolution 1s;
+daemon off;
+pcre_jit on;
+
+events {
+    worker_connections 100000;
+	multi_accept off;	 
+}
+
+http {
+    #include       /etc/nginx/mime.types;
+    access_log off;
+    server_tokens off;
+    msie_padding off;
+
+    sendfile off;
+    tcp_nopush off;
+    tcp_nodelay on;
+    keepalive_timeout 65s;
+    keepalive_disable none;
+    keepalive_requests 100000;
+
+    php_ini_path /deploy/conf/php.ini;
+
+    server {
+        listen       *:8080 backlog=65535 reuseport;
+
+        root /;
+        index  index.html;
+
+        php_keepalive 256;
+
+        location = /hello {
+            content_by_php '
+                ngx_header_set("Content-Type", "text/plain");
+                echo "Hello, World!";
+            ';
+        }
+
+        location = /json {
+            content_by_php '
+                ngx_header_set("Content-Type", "application/json");
+                echo json_encode(["message" => "Hello, World!"]);
+            ';
+        }
+    }
+}

+ 32 - 0
frameworks/PHP/php-ngx/php-ngx-mysql.dockerfile

@@ -0,0 +1,32 @@
+FROM ubuntu:19.10
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null
+RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php > /dev/null
+RUN apt-get update -yqq > /dev/null && \
+    apt-get install -yqq wget git unzip libxml2-dev cmake make systemtap-sdt-dev \
+                    zlibc zlib1g zlib1g-dev libpcre3 libpcre3-dev libargon2-0-dev libsodium-dev \
+                    php7.4 php7.4-common php7.4-dev libphp7.4-embed php7.4-mysql nginx > /dev/null
+
+ADD ./ ./
+
+ENV NGINX_VERSION=1.17.9
+
+RUN git clone -b v0.0.23 --single-branch --depth 1 https://github.com/rryqszq4/ngx_php7.git > /dev/null
+
+RUN wget -q http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
+    tar -zxf nginx-${NGINX_VERSION}.tar.gz && \
+    cd nginx-${NGINX_VERSION} && \
+    export PHP_LIB=/usr/lib && \ 
+    ./configure --user=www --group=www \
+            --prefix=/nginx \
+            --with-ld-opt="-Wl,-rpath,$PHP_LIB" \
+            --add-module=/ngx_php7/third_party/ngx_devel_kit \
+            --add-module=/ngx_php7 > /dev/null && \
+    make > /dev/null && make install > /dev/null
+
+RUN export WORKERS=$(( 4 * $(nproc) )) && \
+    sed -i "s/worker_processes  auto/worker_processes $WORKERS/g" /deploy/nginx.conf
+
+CMD /nginx/sbin/nginx -c /deploy/nginx.conf 

+ 4 - 3
frameworks/PHP/php-ngx/php-ngx-pgsql.dockerfile

@@ -28,6 +28,7 @@ RUN wget -q http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
 
 RUN sed -i "s|mysql:|pgsql:|g" /app.php
 
-CMD export WORKERS=$(( 3 * $(nproc) )) && \
-    sed -i "s/worker_processes  auto/worker_processes $WORKERS/g" /deploy/nginx.conf && \
-    /nginx/sbin/nginx -c /deploy/nginx.conf 
+RUN export WORKERS=$(( 4 * $(nproc) )) && \
+    sed -i "s|worker_processes  auto|worker_processes $WORKERS|g" /deploy/nginx.conf
+
+CMD /nginx/sbin/nginx -c /deploy/nginx.conf

+ 1 - 3
frameworks/PHP/php-ngx/php-ngx.dockerfile

@@ -26,6 +26,4 @@ RUN wget -q http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
             --add-module=/ngx_php7 > /dev/null && \
     make > /dev/null && make install > /dev/null
 
-CMD export WORKERS=$(( 3 * $(nproc) )) && \
-    sed -i "s/worker_processes  auto/worker_processes $WORKERS/g" /deploy/nginx.conf && \
-    /nginx/sbin/nginx -c /deploy/nginx.conf 
+CMD /nginx/sbin/nginx -c /deploy/nginx_default.conf