14 | {% endblock %}
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/001_apache_modphp/apache.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:8.3-apache
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
8 |
9 | RUN chmod +x /usr/local/bin/install-php-extensions && \
10 | install-php-extensions \
11 | exif \
12 | intl \
13 | opcache \
14 | pdo_pgsql \
15 | tidy \
16 | gd \
17 | bcmath \
18 | sockets \
19 | zip && \
20 | install-php-extensions @composer;
21 |
22 | COPY ./runtimes/001_apache_modphp/sites-enabled/symfony7site.conf /etc/apache2/sites-available/symfony7site.conf
23 | RUN a2ensite symfony7site
24 |
25 | COPY ./runtimes/001_apache_modphp/mods-available/mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.conf
26 | COPY ./runtimes/001_apache_modphp/mods-available/status.conf /etc/apache2/mods-available/status.conf
27 |
28 | COPY "./project" "/var/www/symfony"
29 |
30 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini;
31 | COPY ./runtimes/001_apache_modphp/php.ini /usr/local/etc/php/conf.d/custom-php.ini
32 |
33 | WORKDIR /var/www/symfony
34 |
35 | RUN rm -rf vendor && \
36 | cp .env.example .env.local && \
37 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
38 | composer dump-autoload --no-dev --classmap-authoritative && \
39 | composer check-platform-reqs && \
40 | php bin/console cache:clear && \
41 | php bin/console cache:warmup
42 |
43 |
44 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/001_apache_modphp/docker-compose-dev.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | apache_modphp_prefork:
3 | image: php:8.3-apache
4 | container_name: apache_modphp_prefork_dev
5 | hostname: symfony7site.dev
6 | volumes:
7 | - ./sites-enabled:/etc/apache2/sites-enabled
8 | - ./mods-available/status.conf:/etc/apache2/mods-available/status.conf
9 | - ./mods-available/mpm_prefork.conf:/etc/apache2/mods-available/mpm_prefork.conf
10 | - ../../projects/symfony-7:/var/www/symfony
11 | ports:
12 | - "80:80"
13 | networks:
14 | - php-benchmarks
15 | deploy:
16 | resources:
17 | limits:
18 | cpus: '1'
19 | memory: '1gb'
20 |
21 |
22 | networks:
23 | php-benchmarks:
24 |
25 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/001_apache_modphp/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 001_apache_modphp:
3 | build:
4 | context: ../../
5 | dockerfile: ./runtimes/001_apache_modphp/apache.Dockerfile
6 | image: 001_apache_modphp
7 | container_name: 001_apache_modphp
8 | hostname: symfony7site
9 | ports:
10 | - "80:80"
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 | networks:
22 | php-benchmarks:
23 | name: php-benchmarks
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/001_apache_modphp/mods-available/mpm_prefork.conf:
--------------------------------------------------------------------------------
1 | # prefork MPM
2 | # StartServers: number of server processes to start
3 | # MinSpareServers: minimum number of server processes which are kept spare
4 | # MaxSpareServers: maximum number of server processes which are kept spare
5 | # MaxRequestWorkers: maximum number of server processes allowed to start
6 | # MaxConnectionsPerChild: maximum number of requests a server process serves
7 |
8 | StartServers 5
9 | MinSpareServers 5
10 | MaxSpareServers 10
11 | MaxRequestWorkers 512
12 | MaxConnectionsPerChild 0
13 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/001_apache_modphp/mods-available/status.conf:
--------------------------------------------------------------------------------
1 | # Allow server status reports generated by mod_status,
2 | # with the URL of http://servername/server-status
3 | # Uncomment and change the "192.0.2.0/24" to allow access from other hosts.
4 |
5 | #
6 | # SetHandler server-status
7 | # Require local
8 | # #Require ip 192.0.2.0/24
9 | #
10 |
11 | # CUSTOM
12 |
13 | SetHandler server-status
14 | Require all granted
15 |
16 | # /CUSTOM
17 |
18 | # Keep track of extended status information for each request
19 | ExtendedStatus On
20 |
21 | # Determine if mod_status displays the first 63 characters of a request or
22 | # the last 63, assuming the request itself is greater than 63 chars.
23 | # Default: Off
24 | #SeeRequestTail On
25 |
26 |
27 |
28 | # Show Proxy LoadBalancer status in mod_status
29 | ProxyStatus On
30 |
31 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/001_apache_modphp/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 |
6 | memory_limit = 128M
7 |
8 | realpath_cache_size=4096K
9 | realpath_cache_ttl=600
10 |
11 | [opcache]
12 | opcache.enable=1
13 | opcache.jit_buffer_size=256M
14 | opcache.jit=tracing
15 | opcache.preload=/var/www/symfony/config/preload.php
16 | opcache.preload_user=www-data
17 | opcache.validate_timestamps=0
18 | opcache.memory_consumption=256
19 | opcache.max_accelerated_files=20000
20 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/001_apache_modphp/sites-enabled/symfony7site.conf:
--------------------------------------------------------------------------------
1 |
2 | ServerName localhost
3 | ServerAlias symfony7site
4 |
5 | DocumentRoot /var/www/symfony/public
6 |
7 | AllowOverride None
8 | Require all granted
9 | FallbackResource /index.php
10 |
11 |
12 | # ErrorLog /var/log/apache2/project_error.log
13 | # CustomLog /var/log/apache2/project_access.log combined
14 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/002_apache_phpfpm/apache/apache.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu/apache2
2 |
3 | COPY ./runtimes/002_apache_phpfpm/apache/sites-available/symfony7site.conf /etc/apache2/sites-available/symfony7site.conf
4 | #COPY ./runtimes/002_apache_phpfpm/apache/mods-available/mpm_event.conf /etc/apache2/mods-available/mpm_event.conf
5 | COPY ./runtimes/002_apache_phpfpm/apache/mods-available/status.conf /etc/apache2/mods-available/status.conf
6 |
7 | COPY "./project" "/var/www/symfony"
8 |
9 | RUN a2enmod proxy_fcgi && \
10 | a2enmod rewrite && \
11 | a2ensite symfony7site
12 |
13 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/002_apache_phpfpm/apache/mods-available/mpm_event.conf:
--------------------------------------------------------------------------------
1 | # event MPM
2 | # StartServers: initial number of server processes to start
3 | # MinSpareThreads: minimum number of worker threads which are kept spare
4 | # MaxSpareThreads: maximum number of worker threads which are kept spare
5 | # ThreadsPerChild: constant number of worker threads in each server process
6 | # MaxRequestWorkers: maximum number of worker threads
7 | # MaxConnectionsPerChild: maximum number of requests a server process serves
8 | StartServers 2
9 | MinSpareThreads 25
10 | MaxSpareThreads 75
11 | ThreadLimit 64
12 | ThreadsPerChild 25
13 | MaxRequestWorkers 512
14 | MaxConnectionsPerChild 0
15 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/002_apache_phpfpm/apache/mods-available/status.conf:
--------------------------------------------------------------------------------
1 | # CUSTOM
2 |
3 | SetHandler server-status
4 | Require all granted
5 |
6 | # /CUSTOM
7 |
8 | ExtendedStatus On
9 |
10 |
11 | ProxyStatus On
12 |
13 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/002_apache_phpfpm/apache/sites-available/symfony7site.conf:
--------------------------------------------------------------------------------
1 | LoadModule proxy_module modules/mod_proxy.so
2 | LoadModule rewrite_module modules/mod_rewrite.so
3 | LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
4 |
5 |
6 | ServerName localhost
7 | ServerAlias symfony7site
8 |
9 |
10 | SetHandler proxy:fcgi://002_phpfpm:9000
11 |
12 |
13 | DocumentRoot /var/www/symfony/public
14 |
15 | AllowOverride None
16 | Require all granted
17 | FallbackResource /index.php
18 |
19 |
20 |
21 | Require all granted
22 | ProxyPass "fcgi://002_phpfpm:9001/fpm-status"
23 |
24 |
25 | # ErrorLog /var/log/apache2/project_error.log
26 | # CustomLog /var/log/apache2/project_access.log combined
27 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/002_apache_phpfpm/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 002_apache:
3 | build:
4 | context: ../../
5 | dockerfile: ./runtimes/002_apache_phpfpm/apache/apache.Dockerfile
6 | image: 002_apache
7 | container_name: 002_apache
8 | hostname: symfony7site
9 | ports:
10 | - "80:80"
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 | 002_phpfpm:
22 | build:
23 | context: ../../
24 | dockerfile: ./runtimes/002_apache_phpfpm/fpm/phpfpm.Dockerfile
25 | image: 002_phpfpm
26 | container_name: 002_phpfpm
27 | ports:
28 | - "9001:9001"
29 | networks:
30 | - php-benchmarks
31 | deploy:
32 | resources:
33 | limits:
34 | cpus: '1'
35 | memory: '1gb'
36 | reservations:
37 | cpus: '1'
38 | memory: '1gb'
39 |
40 | networks:
41 | php-benchmarks:
42 | name: php-benchmarks
43 |
44 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/002_apache_phpfpm/fpm/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 |
6 | memory_limit = 128M
7 |
8 | realpath_cache_size=4096K
9 | realpath_cache_ttl=600
10 |
11 | [opcache]
12 | opcache.enable=1
13 | opcache.jit_buffer_size=256M
14 | opcache.jit=tracing
15 | opcache.preload=/var/www/symfony/config/preload.php
16 | opcache.preload_user=www-data
17 | opcache.validate_timestamps=0
18 | opcache.memory_consumption=256
19 | opcache.max_accelerated_files=20000
20 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/002_apache_phpfpm/fpm/phpfpm.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:8.3-fpm
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
8 |
9 | RUN chmod +x /usr/local/bin/install-php-extensions && \
10 | install-php-extensions \
11 | exif \
12 | intl \
13 | opcache \
14 | pdo_pgsql \
15 | tidy \
16 | gd \
17 | bcmath \
18 | sockets \
19 | zip && \
20 | install-php-extensions @composer;
21 |
22 | COPY "./project" "/var/www/symfony"
23 |
24 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini;
25 | COPY ./runtimes/002_apache_phpfpm/fpm/php.ini /usr/local/etc/php/conf.d/custom-php.ini
26 | COPY ./runtimes/002_apache_phpfpm/fpm/www.conf /usr/local/etc/php-fpm.d/www.conf
27 |
28 | WORKDIR /var/www/symfony
29 |
30 | RUN cp .env.example .env.local
31 |
32 | RUN rm -rf vendor && \
33 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
34 | composer dump-autoload --no-dev --classmap-authoritative && \
35 | composer check-platform-reqs && \
36 | php bin/console cache:clear && \
37 | php bin/console cache:warmup
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/002_apache_phpfpm/fpm/www.conf:
--------------------------------------------------------------------------------
1 | ; Start a new pool named 'www'.
2 | ; the variable $pool can be used in any directive and will be replaced by the
3 | ; pool name ('www' here)
4 | [www]
5 |
6 | ; Per pool prefix
7 | ; It only applies on the following directives:
8 | ; - 'access.log'
9 | ; - 'slowlog'
10 | ; - 'listen' (unixsocket)
11 | ; - 'chroot'
12 | ; - 'chdir'
13 | ; - 'php_values'
14 | ; - 'php_admin_values'
15 | ; When not set, the global prefix (or NONE) applies instead.
16 | ; Note: This directive can also be relative to the global prefix.
17 | ; Default Value: none
18 | ;prefix = /path/to/pools/$pool
19 |
20 | ; Unix user/group of the child processes. This can be used only if the master
21 | ; process running user is root. It is set after the child process is created.
22 | ; The user and group can be specified either by their name or by their numeric
23 | ; IDs.
24 | ; Note: If the user is root, the executable needs to be started with
25 | ; --allow-to-run-as-root option to work.
26 | ; Default Values: The user is set to master process running user by default.
27 | ; If the group is not set, the user's group is used.
28 | user = www-data
29 | group = www-data
30 |
31 | ; The address on which to accept FastCGI requests.
32 | ; Valid syntaxes are:
33 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
34 | ; a specific port;
35 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
36 | ; a specific port;
37 | ; 'port' - to listen on a TCP socket to all addresses
38 | ; (IPv6 and IPv4-mapped) on a specific port;
39 | ; '/path/to/unix/socket' - to listen on a unix socket.
40 | ; Note: This value is mandatory.
41 | listen = 127.0.0.1:9000
42 |
43 | ; Set listen(2) backlog.
44 | ; Default Value: 511 (-1 on Linux, FreeBSD and OpenBSD)
45 | ;listen.backlog = 511
46 |
47 | ; Set permissions for unix socket, if one is used. In Linux, read/write
48 | ; permissions must be set in order to allow connections from a web server. Many
49 | ; BSD-derived systems allow connections regardless of permissions. The owner
50 | ; and group can be specified either by name or by their numeric IDs.
51 | ; Default Values: Owner is set to the master process running user. If the group
52 | ; is not set, the owner's group is used. Mode is set to 0660.
53 | ;listen.owner = www-data
54 | ;listen.group = www-data
55 | ;listen.mode = 0660
56 |
57 | ; When POSIX Access Control Lists are supported you can set them using
58 | ; these options, value is a comma separated list of user/group names.
59 | ; When set, listen.owner and listen.group are ignored
60 | ;listen.acl_users =
61 | ;listen.acl_groups =
62 |
63 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
64 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
65 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
66 | ; must be separated by a comma. If this value is left blank, connections will be
67 | ; accepted from any ip address.
68 | ; Default Value: any
69 | ;listen.allowed_clients = 127.0.0.1
70 |
71 | ; Set the associated the route table (FIB). FreeBSD only
72 | ; Default Value: -1
73 | ;listen.setfib = 1
74 |
75 | ; Specify the nice(2) priority to apply to the pool processes (only if set)
76 | ; The value can vary from -19 (highest priority) to 20 (lower priority)
77 | ; Note: - It will only work if the FPM master process is launched as root
78 | ; - The pool processes will inherit the master process priority
79 | ; unless it specified otherwise
80 | ; Default Value: no set
81 | ; process.priority = -19
82 |
83 | ; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
84 | ; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
85 | ; or group is different than the master process user. It allows to create process
86 | ; core dump and ptrace the process for the pool user.
87 | ; Default Value: no
88 | ; process.dumpable = yes
89 |
90 | ; Choose how the process manager will control the number of child processes.
91 | ; Possible Values:
92 | ; static - a fixed number (pm.max_children) of child processes;
93 | ; dynamic - the number of child processes are set dynamically based on the
94 | ; following directives. With this process management, there will be
95 | ; always at least 1 children.
96 | ; pm.max_children - the maximum number of children that can
97 | ; be alive at the same time.
98 | ; pm.start_servers - the number of children created on startup.
99 | ; pm.min_spare_servers - the minimum number of children in 'idle'
100 | ; state (waiting to process). If the number
101 | ; of 'idle' processes is less than this
102 | ; number then some children will be created.
103 | ; pm.max_spare_servers - the maximum number of children in 'idle'
104 | ; state (waiting to process). If the number
105 | ; of 'idle' processes is greater than this
106 | ; number then some children will be killed.
107 | ; pm.max_spawn_rate - the maximum number of rate to spawn child
108 | ; processes at once.
109 | ; ondemand - no children are created at startup. Children will be forked when
110 | ; new requests will connect. The following parameter are used:
111 | ; pm.max_children - the maximum number of children that
112 | ; can be alive at the same time.
113 | ; pm.process_idle_timeout - The number of seconds after which
114 | ; an idle process will be killed.
115 | ; Note: This value is mandatory.
116 | pm = dynamic
117 |
118 | ; The number of child processes to be created when pm is set to 'static' and the
119 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
120 | ; This value sets the limit on the number of simultaneous requests that will be
121 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
122 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
123 | ; CGI. The below defaults are based on a server without much resources. Don't
124 | ; forget to tweak pm.* to fit your needs.
125 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
126 | ; Note: This value is mandatory.
127 | ; pm.max_children = 5
128 | pm.max_children = 33
129 |
130 | ; The number of child processes created on startup.
131 | ; Note: Used only when pm is set to 'dynamic'
132 | ; Default Value: (min_spare_servers + max_spare_servers) / 2
133 | pm.start_servers = 10
134 |
135 | ; The desired minimum number of idle server processes.
136 | ; Note: Used only when pm is set to 'dynamic'
137 | ; Note: Mandatory when pm is set to 'dynamic'
138 | ; pm.min_spare_servers = 1
139 | pm.min_spare_servers = 10
140 |
141 | ; The desired maximum number of idle server processes.
142 | ; Note: Used only when pm is set to 'dynamic'
143 | ; Note: Mandatory when pm is set to 'dynamic'
144 | ;pm.max_spare_servers = 3
145 | pm.max_spare_servers = 30
146 |
147 | ; The number of rate to spawn child processes at once.
148 | ; Note: Used only when pm is set to 'dynamic'
149 | ; Note: Mandatory when pm is set to 'dynamic'
150 | ; Default Value: 32
151 | ;pm.max_spawn_rate = 32
152 |
153 | ; The number of seconds after which an idle process will be killed.
154 | ; Note: Used only when pm is set to 'ondemand'
155 | ; Default Value: 10s
156 | ;pm.process_idle_timeout = 10s;
157 |
158 | ; The number of requests each child process should execute before respawning.
159 | ; This can be useful to work around memory leaks in 3rd party libraries. For
160 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
161 | ; Default Value: 0
162 | pm.max_requests = 500
163 |
164 | ; The URI to view the FPM status page. If this value is not set, no URI will be
165 | ; recognized as a status page. It shows the following information:
166 | ; pool - the name of the pool;
167 | ; process manager - static, dynamic or ondemand;
168 | ; start time - the date and time FPM has started;
169 | ; start since - number of seconds since FPM has started;
170 | ; accepted conn - the number of request accepted by the pool;
171 | ; listen queue - the number of request in the queue of pending
172 | ; connections (see backlog in listen(2));
173 | ; max listen queue - the maximum number of requests in the queue
174 | ; of pending connections since FPM has started;
175 | ; listen queue len - the size of the socket queue of pending connections;
176 | ; idle processes - the number of idle processes;
177 | ; active processes - the number of active processes;
178 | ; total processes - the number of idle + active processes;
179 | ; max active processes - the maximum number of active processes since FPM
180 | ; has started;
181 | ; max children reached - number of times, the process limit has been reached,
182 | ; when pm tries to start more children (works only for
183 | ; pm 'dynamic' and 'ondemand');
184 | ; Value are updated in real time.
185 | ; Example output:
186 | ; pool: www
187 | ; process manager: static
188 | ; start time: 01/Jul/2011:17:53:49 +0200
189 | ; start since: 62636
190 | ; accepted conn: 190460
191 | ; listen queue: 0
192 | ; max listen queue: 1
193 | ; listen queue len: 42
194 | ; idle processes: 4
195 | ; active processes: 11
196 | ; total processes: 15
197 | ; max active processes: 12
198 | ; max children reached: 0
199 | ;
200 | ; By default the status page output is formatted as text/plain. Passing either
201 | ; 'html', 'xml' or 'json' in the query string will return the corresponding
202 | ; output syntax. Example:
203 | ; http://www.foo.bar/status
204 | ; http://www.foo.bar/status?json
205 | ; http://www.foo.bar/status?html
206 | ; http://www.foo.bar/status?xml
207 | ;
208 | ; By default the status page only outputs short status. Passing 'full' in the
209 | ; query string will also return status for each pool process.
210 | ; Example:
211 | ; http://www.foo.bar/status?full
212 | ; http://www.foo.bar/status?json&full
213 | ; http://www.foo.bar/status?html&full
214 | ; http://www.foo.bar/status?xml&full
215 | ; The Full status returns for each process:
216 | ; pid - the PID of the process;
217 | ; state - the state of the process (Idle, Running, ...);
218 | ; start time - the date and time the process has started;
219 | ; start since - the number of seconds since the process has started;
220 | ; requests - the number of requests the process has served;
221 | ; request duration - the duration in µs of the requests;
222 | ; request method - the request method (GET, POST, ...);
223 | ; request URI - the request URI with the query string;
224 | ; content length - the content length of the request (only with POST);
225 | ; user - the user (PHP_AUTH_USER) (or '-' if not set);
226 | ; script - the main script called (or '-' if not set);
227 | ; last request cpu - the %cpu the last request consumed
228 | ; it's always 0 if the process is not in Idle state
229 | ; because CPU calculation is done when the request
230 | ; processing has terminated;
231 | ; last request memory - the max amount of memory the last request consumed
232 | ; it's always 0 if the process is not in Idle state
233 | ; because memory calculation is done when the request
234 | ; processing has terminated;
235 | ; If the process is in Idle state, then informations are related to the
236 | ; last request the process has served. Otherwise informations are related to
237 | ; the current request being served.
238 | ; Example output:
239 | ; ************************
240 | ; pid: 31330
241 | ; state: Running
242 | ; start time: 01/Jul/2011:17:53:49 +0200
243 | ; start since: 63087
244 | ; requests: 12808
245 | ; request duration: 1250261
246 | ; request method: GET
247 | ; request URI: /test_mem.php?N=10000
248 | ; content length: 0
249 | ; user: -
250 | ; script: /home/fat/web/docs/php/test_mem.php
251 | ; last request cpu: 0.00
252 | ; last request memory: 0
253 | ;
254 | ; Note: There is a real-time FPM status monitoring sample web page available
255 | ; It's available in: /usr/local/share/php/fpm/status.html
256 | ;
257 | ; Note: The value must start with a leading slash (/). The value can be
258 | ; anything, but it may not be a good idea to use the .php extension or it
259 | ; may conflict with a real PHP file.
260 | ; Default Value: not set
261 | pm.status_path = /fpm-status
262 |
263 | ; The address on which to accept FastCGI status request. This creates a new
264 | ; invisible pool that can handle requests independently. This is useful
265 | ; if the main pool is busy with long running requests because it is still possible
266 | ; to get the status before finishing the long running requests.
267 | ;
268 | ; Valid syntaxes are:
269 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
270 | ; a specific port;
271 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
272 | ; a specific port;
273 | ; 'port' - to listen on a TCP socket to all addresses
274 | ; (IPv6 and IPv4-mapped) on a specific port;
275 | ; '/path/to/unix/socket' - to listen on a unix socket.
276 | ; Default Value: value of the listen option
277 | pm.status_listen = 9001
278 |
279 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no
280 | ; URI will be recognized as a ping page. This could be used to test from outside
281 | ; that FPM is alive and responding, or to
282 | ; - create a graph of FPM availability (rrd or such);
283 | ; - remove a server from a group if it is not responding (load balancing);
284 | ; - trigger alerts for the operating team (24/7).
285 | ; Note: The value must start with a leading slash (/). The value can be
286 | ; anything, but it may not be a good idea to use the .php extension or it
287 | ; may conflict with a real PHP file.
288 | ; Default Value: not set
289 | ;ping.path = /ping
290 |
291 | ; This directive may be used to customize the response of a ping request. The
292 | ; response is formatted as text/plain with a 200 response code.
293 | ; Default Value: pong
294 | ;ping.response = pong
295 |
296 | ; The access log file
297 | ; Default: not set
298 | ;access.log = log/$pool.access.log
299 |
300 | ; The access log format.
301 | ; The following syntax is allowed
302 | ; %%: the '%' character
303 | ; %C: %CPU used by the request
304 | ; it can accept the following format:
305 | ; - %{user}C for user CPU only
306 | ; - %{system}C for system CPU only
307 | ; - %{total}C for user + system CPU (default)
308 | ; %d: time taken to serve the request
309 | ; it can accept the following format:
310 | ; - %{seconds}d (default)
311 | ; - %{milliseconds}d
312 | ; - %{milli}d
313 | ; - %{microseconds}d
314 | ; - %{micro}d
315 | ; %e: an environment variable (same as $_ENV or $_SERVER)
316 | ; it must be associated with embraces to specify the name of the env
317 | ; variable. Some examples:
318 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
319 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
320 | ; %f: script filename
321 | ; %l: content-length of the request (for POST request only)
322 | ; %m: request method
323 | ; %M: peak of memory allocated by PHP
324 | ; it can accept the following format:
325 | ; - %{bytes}M (default)
326 | ; - %{kilobytes}M
327 | ; - %{kilo}M
328 | ; - %{megabytes}M
329 | ; - %{mega}M
330 | ; %n: pool name
331 | ; %o: output header
332 | ; it must be associated with embraces to specify the name of the header:
333 | ; - %{Content-Type}o
334 | ; - %{X-Powered-By}o
335 | ; - %{Transfert-Encoding}o
336 | ; - ....
337 | ; %p: PID of the child that serviced the request
338 | ; %P: PID of the parent of the child that serviced the request
339 | ; %q: the query string
340 | ; %Q: the '?' character if query string exists
341 | ; %r: the request URI (without the query string, see %q and %Q)
342 | ; %R: remote IP address
343 | ; %s: status (response code)
344 | ; %t: server time the request was received
345 | ; it can accept a strftime(3) format:
346 | ; %d/%b/%Y:%H:%M:%S %z (default)
347 | ; The strftime(3) format must be encapsulated in a %{}t tag
348 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
349 | ; %T: time the log has been written (the request has finished)
350 | ; it can accept a strftime(3) format:
351 | ; %d/%b/%Y:%H:%M:%S %z (default)
352 | ; The strftime(3) format must be encapsulated in a %{}t tag
353 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
354 | ; %u: remote user
355 | ;
356 | ; Default: "%R - %u %t \"%m %r\" %s"
357 | ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%"
358 |
359 | ; A list of request_uri values which should be filtered from the access log.
360 | ;
361 | ; As a security precuation, this setting will be ignored if:
362 | ; - the request method is not GET or HEAD; or
363 | ; - there is a request body; or
364 | ; - there are query parameters; or
365 | ; - the response code is outwith the successful range of 200 to 299
366 | ;
367 | ; Note: The paths are matched against the output of the access.format tag "%r".
368 | ; On common configurations, this may look more like SCRIPT_NAME than the
369 | ; expected pre-rewrite URI.
370 | ;
371 | ; Default Value: not set
372 | ;access.suppress_path[] = /ping
373 | ;access.suppress_path[] = /health_check.php
374 |
375 | ; The log file for slow requests
376 | ; Default Value: not set
377 | ; Note: slowlog is mandatory if request_slowlog_timeout is set
378 | ;slowlog = log/$pool.log.slow
379 |
380 | ; The timeout for serving a single request after which a PHP backtrace will be
381 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
382 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
383 | ; Default Value: 0
384 | ;request_slowlog_timeout = 0
385 |
386 | ; Depth of slow log stack trace.
387 | ; Default Value: 20
388 | ;request_slowlog_trace_depth = 20
389 |
390 | ; The timeout for serving a single request after which the worker process will
391 | ; be killed. This option should be used when the 'max_execution_time' ini option
392 | ; does not stop script execution for some reason. A value of '0' means 'off'.
393 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
394 | ; Default Value: 0
395 | ;request_terminate_timeout = 0
396 |
397 | ; The timeout set by 'request_terminate_timeout' ini option is not engaged after
398 | ; application calls 'fastcgi_finish_request' or when application has finished and
399 | ; shutdown functions are being called (registered via register_shutdown_function).
400 | ; This option will enable timeout limit to be applied unconditionally
401 | ; even in such cases.
402 | ; Default Value: no
403 | ;request_terminate_timeout_track_finished = no
404 |
405 | ; Set open file descriptor rlimit.
406 | ; Default Value: system defined value
407 | ;rlimit_files = 1024
408 |
409 | ; Set max core size rlimit.
410 | ; Possible Values: 'unlimited' or an integer greater or equal to 0
411 | ; Default Value: system defined value
412 | ;rlimit_core = 0
413 |
414 | ; Chroot to this directory at the start. This value must be defined as an
415 | ; absolute path. When this value is not set, chroot is not used.
416 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
417 | ; of its subdirectories. If the pool prefix is not set, the global prefix
418 | ; will be used instead.
419 | ; Note: chrooting is a great security feature and should be used whenever
420 | ; possible. However, all PHP paths will be relative to the chroot
421 | ; (error_log, sessions.save_path, ...).
422 | ; Default Value: not set
423 | ;chroot =
424 |
425 | ; Chdir to this directory at the start.
426 | ; Note: relative path can be used.
427 | ; Default Value: current directory or / when chroot
428 | ;chdir = /var/www
429 |
430 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and
431 | ; stderr will be redirected to /dev/null according to FastCGI specs.
432 | ; Note: on highloaded environment, this can cause some delay in the page
433 | ; process time (several ms).
434 | ; Default Value: no
435 | ;catch_workers_output = yes
436 |
437 | ; Decorate worker output with prefix and suffix containing information about
438 | ; the child that writes to the log and if stdout or stderr is used as well as
439 | ; log level and time. This options is used only if catch_workers_output is yes.
440 | ; Settings to "no" will output data as written to the stdout or stderr.
441 | ; Default value: yes
442 | ;decorate_workers_output = no
443 |
444 | ; Clear environment in FPM workers
445 | ; Prevents arbitrary environment variables from reaching FPM worker processes
446 | ; by clearing the environment in workers before env vars specified in this
447 | ; pool configuration are added.
448 | ; Setting to "no" will make all environment variables available to PHP code
449 | ; via getenv(), $_ENV and $_SERVER.
450 | ; Default Value: yes
451 | ;clear_env = no
452 |
453 | ; Limits the extensions of the main script FPM will allow to parse. This can
454 | ; prevent configuration mistakes on the web server side. You should only limit
455 | ; FPM to .php extensions to prevent malicious users to use other extensions to
456 | ; execute php code.
457 | ; Note: set an empty value to allow all extensions.
458 | ; Default Value: .php
459 | ;security.limit_extensions = .php .php3 .php4 .php5 .php7
460 |
461 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
462 | ; the current environment.
463 | ; Default Value: clean env
464 | ;env[HOSTNAME] = $HOSTNAME
465 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin
466 | ;env[TMP] = /tmp
467 | ;env[TMPDIR] = /tmp
468 | ;env[TEMP] = /tmp
469 |
470 | ; Additional php.ini defines, specific to this pool of workers. These settings
471 | ; overwrite the values previously defined in the php.ini. The directives are the
472 | ; same as the PHP SAPI:
473 | ; php_value/php_flag - you can set classic ini defines which can
474 | ; be overwritten from PHP call 'ini_set'.
475 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by
476 | ; PHP call 'ini_set'
477 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
478 |
479 | ; Defining 'extension' will load the corresponding shared extension from
480 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
481 | ; overwrite previously defined php.ini values, but will append the new value
482 | ; instead.
483 |
484 | ; Note: path INI options can be relative and will be expanded with the prefix
485 | ; (pool, global or /usr/local)
486 |
487 | ; Default Value: nothing is defined by default except the values in php.ini and
488 | ; specified at startup with the -d argument
489 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
490 | ;php_flag[display_errors] = off
491 | ;php_admin_value[error_log] = /var/log/fpm-php.www.log
492 | ;php_admin_flag[log_errors] = on
493 | ;php_admin_value[memory_limit] = 32M
494 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/003_nginx_phpfpm/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 003_nginx:
3 | build:
4 | context: ../../
5 | dockerfile: ./runtimes/003_nginx_phpfpm/nginx/nginx.Dockerfile
6 | image: 003_nginx
7 | container_name: "003_nginx"
8 | hostname: symfony7site
9 | ports:
10 | - '80:80'
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 |
22 | 003_phpfpm:
23 | build:
24 | context: ../../
25 | dockerfile: ./runtimes/003_nginx_phpfpm/fpm/phpfpm.Dockerfile
26 | image: 003_phpfpm
27 | container_name: "003_phpfpm"
28 | ports:
29 | - "9001:9001"
30 | networks:
31 | - php-benchmarks
32 | deploy:
33 | resources:
34 | limits:
35 | cpus: '1'
36 | memory: '1gb'
37 | reservations:
38 | cpus: '1'
39 | memory: '1gb'
40 |
41 | networks:
42 | php-benchmarks:
43 | name: php-benchmarks
44 |
45 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/003_nginx_phpfpm/fpm/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 |
6 | memory_limit = 128M
7 |
8 | realpath_cache_size=4096K
9 | realpath_cache_ttl=600
10 |
11 | [opcache]
12 | opcache.enable=1
13 | opcache.jit_buffer_size=256M
14 | opcache.jit=tracing
15 | opcache.preload=/var/www/symfony/config/preload.php
16 | opcache.preload_user=www-data
17 | opcache.validate_timestamps=0
18 | opcache.memory_consumption=256
19 | opcache.max_accelerated_files=20000
20 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/003_nginx_phpfpm/fpm/phpfpm.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:8.3-fpm
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
8 |
9 | RUN chmod +x /usr/local/bin/install-php-extensions && \
10 | install-php-extensions \
11 | exif \
12 | intl \
13 | opcache \
14 | pdo_pgsql \
15 | tidy \
16 | gd \
17 | bcmath \
18 | sockets \
19 | zip && \
20 | install-php-extensions @composer;
21 |
22 | COPY "./project" "/var/www/symfony"
23 |
24 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini;
25 | COPY ./runtimes/003_nginx_phpfpm/fpm/php.ini /usr/local/etc/php/conf.d/custom-php.ini
26 | COPY ./runtimes/003_nginx_phpfpm/fpm/www.conf /usr/local/etc/php-fpm.d/www.conf
27 |
28 | WORKDIR /var/www/symfony
29 |
30 | RUN cp .env.example .env.local
31 |
32 | RUN rm -rf vendor && \
33 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
34 | composer dump-autoload --no-dev --classmap-authoritative && \
35 | composer check-platform-reqs && \
36 | php bin/console cache:clear && \
37 | php bin/console cache:warmup
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/003_nginx_phpfpm/fpm/www.conf:
--------------------------------------------------------------------------------
1 | ; Start a new pool named 'www'.
2 | ; the variable $pool can be used in any directive and will be replaced by the
3 | ; pool name ('www' here)
4 | [www]
5 |
6 | ; Per pool prefix
7 | ; It only applies on the following directives:
8 | ; - 'access.log'
9 | ; - 'slowlog'
10 | ; - 'listen' (unixsocket)
11 | ; - 'chroot'
12 | ; - 'chdir'
13 | ; - 'php_values'
14 | ; - 'php_admin_values'
15 | ; When not set, the global prefix (or NONE) applies instead.
16 | ; Note: This directive can also be relative to the global prefix.
17 | ; Default Value: none
18 | ;prefix = /path/to/pools/$pool
19 |
20 | ; Unix user/group of the child processes. This can be used only if the master
21 | ; process running user is root. It is set after the child process is created.
22 | ; The user and group can be specified either by their name or by their numeric
23 | ; IDs.
24 | ; Note: If the user is root, the executable needs to be started with
25 | ; --allow-to-run-as-root option to work.
26 | ; Default Values: The user is set to master process running user by default.
27 | ; If the group is not set, the user's group is used.
28 | user = www-data
29 | group = www-data
30 |
31 | ; The address on which to accept FastCGI requests.
32 | ; Valid syntaxes are:
33 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
34 | ; a specific port;
35 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
36 | ; a specific port;
37 | ; 'port' - to listen on a TCP socket to all addresses
38 | ; (IPv6 and IPv4-mapped) on a specific port;
39 | ; '/path/to/unix/socket' - to listen on a unix socket.
40 | ; Note: This value is mandatory.
41 | listen = 127.0.0.1:9000
42 |
43 | ; Set listen(2) backlog.
44 | ; Default Value: 511 (-1 on Linux, FreeBSD and OpenBSD)
45 | ;listen.backlog = 511
46 |
47 | ; Set permissions for unix socket, if one is used. In Linux, read/write
48 | ; permissions must be set in order to allow connections from a web server. Many
49 | ; BSD-derived systems allow connections regardless of permissions. The owner
50 | ; and group can be specified either by name or by their numeric IDs.
51 | ; Default Values: Owner is set to the master process running user. If the group
52 | ; is not set, the owner's group is used. Mode is set to 0660.
53 | ;listen.owner = www-data
54 | ;listen.group = www-data
55 | ;listen.mode = 0660
56 |
57 | ; When POSIX Access Control Lists are supported you can set them using
58 | ; these options, value is a comma separated list of user/group names.
59 | ; When set, listen.owner and listen.group are ignored
60 | ;listen.acl_users =
61 | ;listen.acl_groups =
62 |
63 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
64 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
65 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
66 | ; must be separated by a comma. If this value is left blank, connections will be
67 | ; accepted from any ip address.
68 | ; Default Value: any
69 | ;listen.allowed_clients = 127.0.0.1
70 |
71 | ; Set the associated the route table (FIB). FreeBSD only
72 | ; Default Value: -1
73 | ;listen.setfib = 1
74 |
75 | ; Specify the nice(2) priority to apply to the pool processes (only if set)
76 | ; The value can vary from -19 (highest priority) to 20 (lower priority)
77 | ; Note: - It will only work if the FPM master process is launched as root
78 | ; - The pool processes will inherit the master process priority
79 | ; unless it specified otherwise
80 | ; Default Value: no set
81 | ; process.priority = -19
82 |
83 | ; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
84 | ; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
85 | ; or group is different than the master process user. It allows to create process
86 | ; core dump and ptrace the process for the pool user.
87 | ; Default Value: no
88 | ; process.dumpable = yes
89 |
90 | ; Choose how the process manager will control the number of child processes.
91 | ; Possible Values:
92 | ; static - a fixed number (pm.max_children) of child processes;
93 | ; dynamic - the number of child processes are set dynamically based on the
94 | ; following directives. With this process management, there will be
95 | ; always at least 1 children.
96 | ; pm.max_children - the maximum number of children that can
97 | ; be alive at the same time.
98 | ; pm.start_servers - the number of children created on startup.
99 | ; pm.min_spare_servers - the minimum number of children in 'idle'
100 | ; state (waiting to process). If the number
101 | ; of 'idle' processes is less than this
102 | ; number then some children will be created.
103 | ; pm.max_spare_servers - the maximum number of children in 'idle'
104 | ; state (waiting to process). If the number
105 | ; of 'idle' processes is greater than this
106 | ; number then some children will be killed.
107 | ; pm.max_spawn_rate - the maximum number of rate to spawn child
108 | ; processes at once.
109 | ; ondemand - no children are created at startup. Children will be forked when
110 | ; new requests will connect. The following parameter are used:
111 | ; pm.max_children - the maximum number of children that
112 | ; can be alive at the same time.
113 | ; pm.process_idle_timeout - The number of seconds after which
114 | ; an idle process will be killed.
115 | ; Note: This value is mandatory.
116 | pm = dynamic
117 |
118 | ; The number of child processes to be created when pm is set to 'static' and the
119 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
120 | ; This value sets the limit on the number of simultaneous requests that will be
121 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
122 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
123 | ; CGI. The below defaults are based on a server without much resources. Don't
124 | ; forget to tweak pm.* to fit your needs.
125 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
126 | ; Note: This value is mandatory.
127 | ; pm.max_children = 5
128 | pm.max_children = 33
129 |
130 | ; The number of child processes created on startup.
131 | ; Note: Used only when pm is set to 'dynamic'
132 | ; Default Value: (min_spare_servers + max_spare_servers) / 2
133 | pm.start_servers = 10
134 |
135 | ; The desired minimum number of idle server processes.
136 | ; Note: Used only when pm is set to 'dynamic'
137 | ; Note: Mandatory when pm is set to 'dynamic'
138 | ; pm.min_spare_servers = 1
139 | pm.min_spare_servers = 10
140 |
141 | ; The desired maximum number of idle server processes.
142 | ; Note: Used only when pm is set to 'dynamic'
143 | ; Note: Mandatory when pm is set to 'dynamic'
144 | ;pm.max_spare_servers = 3
145 | pm.max_spare_servers = 30
146 |
147 | ; The number of rate to spawn child processes at once.
148 | ; Note: Used only when pm is set to 'dynamic'
149 | ; Note: Mandatory when pm is set to 'dynamic'
150 | ; Default Value: 32
151 | ;pm.max_spawn_rate = 32
152 |
153 | ; The number of seconds after which an idle process will be killed.
154 | ; Note: Used only when pm is set to 'ondemand'
155 | ; Default Value: 10s
156 | ;pm.process_idle_timeout = 10s;
157 |
158 | ; The number of requests each child process should execute before respawning.
159 | ; This can be useful to work around memory leaks in 3rd party libraries. For
160 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
161 | ; Default Value: 0
162 | pm.max_requests = 500
163 |
164 | ; The URI to view the FPM status page. If this value is not set, no URI will be
165 | ; recognized as a status page. It shows the following information:
166 | ; pool - the name of the pool;
167 | ; process manager - static, dynamic or ondemand;
168 | ; start time - the date and time FPM has started;
169 | ; start since - number of seconds since FPM has started;
170 | ; accepted conn - the number of request accepted by the pool;
171 | ; listen queue - the number of request in the queue of pending
172 | ; connections (see backlog in listen(2));
173 | ; max listen queue - the maximum number of requests in the queue
174 | ; of pending connections since FPM has started;
175 | ; listen queue len - the size of the socket queue of pending connections;
176 | ; idle processes - the number of idle processes;
177 | ; active processes - the number of active processes;
178 | ; total processes - the number of idle + active processes;
179 | ; max active processes - the maximum number of active processes since FPM
180 | ; has started;
181 | ; max children reached - number of times, the process limit has been reached,
182 | ; when pm tries to start more children (works only for
183 | ; pm 'dynamic' and 'ondemand');
184 | ; Value are updated in real time.
185 | ; Example output:
186 | ; pool: www
187 | ; process manager: static
188 | ; start time: 01/Jul/2011:17:53:49 +0200
189 | ; start since: 62636
190 | ; accepted conn: 190460
191 | ; listen queue: 0
192 | ; max listen queue: 1
193 | ; listen queue len: 42
194 | ; idle processes: 4
195 | ; active processes: 11
196 | ; total processes: 15
197 | ; max active processes: 12
198 | ; max children reached: 0
199 | ;
200 | ; By default the status page output is formatted as text/plain. Passing either
201 | ; 'html', 'xml' or 'json' in the query string will return the corresponding
202 | ; output syntax. Example:
203 | ; http://www.foo.bar/status
204 | ; http://www.foo.bar/status?json
205 | ; http://www.foo.bar/status?html
206 | ; http://www.foo.bar/status?xml
207 | ;
208 | ; By default the status page only outputs short status. Passing 'full' in the
209 | ; query string will also return status for each pool process.
210 | ; Example:
211 | ; http://www.foo.bar/status?full
212 | ; http://www.foo.bar/status?json&full
213 | ; http://www.foo.bar/status?html&full
214 | ; http://www.foo.bar/status?xml&full
215 | ; The Full status returns for each process:
216 | ; pid - the PID of the process;
217 | ; state - the state of the process (Idle, Running, ...);
218 | ; start time - the date and time the process has started;
219 | ; start since - the number of seconds since the process has started;
220 | ; requests - the number of requests the process has served;
221 | ; request duration - the duration in µs of the requests;
222 | ; request method - the request method (GET, POST, ...);
223 | ; request URI - the request URI with the query string;
224 | ; content length - the content length of the request (only with POST);
225 | ; user - the user (PHP_AUTH_USER) (or '-' if not set);
226 | ; script - the main script called (or '-' if not set);
227 | ; last request cpu - the %cpu the last request consumed
228 | ; it's always 0 if the process is not in Idle state
229 | ; because CPU calculation is done when the request
230 | ; processing has terminated;
231 | ; last request memory - the max amount of memory the last request consumed
232 | ; it's always 0 if the process is not in Idle state
233 | ; because memory calculation is done when the request
234 | ; processing has terminated;
235 | ; If the process is in Idle state, then informations are related to the
236 | ; last request the process has served. Otherwise informations are related to
237 | ; the current request being served.
238 | ; Example output:
239 | ; ************************
240 | ; pid: 31330
241 | ; state: Running
242 | ; start time: 01/Jul/2011:17:53:49 +0200
243 | ; start since: 63087
244 | ; requests: 12808
245 | ; request duration: 1250261
246 | ; request method: GET
247 | ; request URI: /test_mem.php?N=10000
248 | ; content length: 0
249 | ; user: -
250 | ; script: /home/fat/web/docs/php/test_mem.php
251 | ; last request cpu: 0.00
252 | ; last request memory: 0
253 | ;
254 | ; Note: There is a real-time FPM status monitoring sample web page available
255 | ; It's available in: /usr/local/share/php/fpm/status.html
256 | ;
257 | ; Note: The value must start with a leading slash (/). The value can be
258 | ; anything, but it may not be a good idea to use the .php extension or it
259 | ; may conflict with a real PHP file.
260 | ; Default Value: not set
261 | pm.status_path = /fpm-status
262 |
263 | ; The address on which to accept FastCGI status request. This creates a new
264 | ; invisible pool that can handle requests independently. This is useful
265 | ; if the main pool is busy with long running requests because it is still possible
266 | ; to get the status before finishing the long running requests.
267 | ;
268 | ; Valid syntaxes are:
269 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
270 | ; a specific port;
271 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
272 | ; a specific port;
273 | ; 'port' - to listen on a TCP socket to all addresses
274 | ; (IPv6 and IPv4-mapped) on a specific port;
275 | ; '/path/to/unix/socket' - to listen on a unix socket.
276 | ; Default Value: value of the listen option
277 | pm.status_listen = 9001
278 |
279 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no
280 | ; URI will be recognized as a ping page. This could be used to test from outside
281 | ; that FPM is alive and responding, or to
282 | ; - create a graph of FPM availability (rrd or such);
283 | ; - remove a server from a group if it is not responding (load balancing);
284 | ; - trigger alerts for the operating team (24/7).
285 | ; Note: The value must start with a leading slash (/). The value can be
286 | ; anything, but it may not be a good idea to use the .php extension or it
287 | ; may conflict with a real PHP file.
288 | ; Default Value: not set
289 | ;ping.path = /ping
290 |
291 | ; This directive may be used to customize the response of a ping request. The
292 | ; response is formatted as text/plain with a 200 response code.
293 | ; Default Value: pong
294 | ;ping.response = pong
295 |
296 | ; The access log file
297 | ; Default: not set
298 | ;access.log = log/$pool.access.log
299 |
300 | ; The access log format.
301 | ; The following syntax is allowed
302 | ; %%: the '%' character
303 | ; %C: %CPU used by the request
304 | ; it can accept the following format:
305 | ; - %{user}C for user CPU only
306 | ; - %{system}C for system CPU only
307 | ; - %{total}C for user + system CPU (default)
308 | ; %d: time taken to serve the request
309 | ; it can accept the following format:
310 | ; - %{seconds}d (default)
311 | ; - %{milliseconds}d
312 | ; - %{milli}d
313 | ; - %{microseconds}d
314 | ; - %{micro}d
315 | ; %e: an environment variable (same as $_ENV or $_SERVER)
316 | ; it must be associated with embraces to specify the name of the env
317 | ; variable. Some examples:
318 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
319 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
320 | ; %f: script filename
321 | ; %l: content-length of the request (for POST request only)
322 | ; %m: request method
323 | ; %M: peak of memory allocated by PHP
324 | ; it can accept the following format:
325 | ; - %{bytes}M (default)
326 | ; - %{kilobytes}M
327 | ; - %{kilo}M
328 | ; - %{megabytes}M
329 | ; - %{mega}M
330 | ; %n: pool name
331 | ; %o: output header
332 | ; it must be associated with embraces to specify the name of the header:
333 | ; - %{Content-Type}o
334 | ; - %{X-Powered-By}o
335 | ; - %{Transfert-Encoding}o
336 | ; - ....
337 | ; %p: PID of the child that serviced the request
338 | ; %P: PID of the parent of the child that serviced the request
339 | ; %q: the query string
340 | ; %Q: the '?' character if query string exists
341 | ; %r: the request URI (without the query string, see %q and %Q)
342 | ; %R: remote IP address
343 | ; %s: status (response code)
344 | ; %t: server time the request was received
345 | ; it can accept a strftime(3) format:
346 | ; %d/%b/%Y:%H:%M:%S %z (default)
347 | ; The strftime(3) format must be encapsulated in a %{}t tag
348 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
349 | ; %T: time the log has been written (the request has finished)
350 | ; it can accept a strftime(3) format:
351 | ; %d/%b/%Y:%H:%M:%S %z (default)
352 | ; The strftime(3) format must be encapsulated in a %{}t tag
353 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
354 | ; %u: remote user
355 | ;
356 | ; Default: "%R - %u %t \"%m %r\" %s"
357 | ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%"
358 |
359 | ; A list of request_uri values which should be filtered from the access log.
360 | ;
361 | ; As a security precuation, this setting will be ignored if:
362 | ; - the request method is not GET or HEAD; or
363 | ; - there is a request body; or
364 | ; - there are query parameters; or
365 | ; - the response code is outwith the successful range of 200 to 299
366 | ;
367 | ; Note: The paths are matched against the output of the access.format tag "%r".
368 | ; On common configurations, this may look more like SCRIPT_NAME than the
369 | ; expected pre-rewrite URI.
370 | ;
371 | ; Default Value: not set
372 | ;access.suppress_path[] = /ping
373 | ;access.suppress_path[] = /health_check.php
374 |
375 | ; The log file for slow requests
376 | ; Default Value: not set
377 | ; Note: slowlog is mandatory if request_slowlog_timeout is set
378 | ;slowlog = log/$pool.log.slow
379 |
380 | ; The timeout for serving a single request after which a PHP backtrace will be
381 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
382 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
383 | ; Default Value: 0
384 | ;request_slowlog_timeout = 0
385 |
386 | ; Depth of slow log stack trace.
387 | ; Default Value: 20
388 | ;request_slowlog_trace_depth = 20
389 |
390 | ; The timeout for serving a single request after which the worker process will
391 | ; be killed. This option should be used when the 'max_execution_time' ini option
392 | ; does not stop script execution for some reason. A value of '0' means 'off'.
393 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
394 | ; Default Value: 0
395 | ;request_terminate_timeout = 0
396 |
397 | ; The timeout set by 'request_terminate_timeout' ini option is not engaged after
398 | ; application calls 'fastcgi_finish_request' or when application has finished and
399 | ; shutdown functions are being called (registered via register_shutdown_function).
400 | ; This option will enable timeout limit to be applied unconditionally
401 | ; even in such cases.
402 | ; Default Value: no
403 | ;request_terminate_timeout_track_finished = no
404 |
405 | ; Set open file descriptor rlimit.
406 | ; Default Value: system defined value
407 | ;rlimit_files = 1024
408 |
409 | ; Set max core size rlimit.
410 | ; Possible Values: 'unlimited' or an integer greater or equal to 0
411 | ; Default Value: system defined value
412 | ;rlimit_core = 0
413 |
414 | ; Chroot to this directory at the start. This value must be defined as an
415 | ; absolute path. When this value is not set, chroot is not used.
416 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
417 | ; of its subdirectories. If the pool prefix is not set, the global prefix
418 | ; will be used instead.
419 | ; Note: chrooting is a great security feature and should be used whenever
420 | ; possible. However, all PHP paths will be relative to the chroot
421 | ; (error_log, sessions.save_path, ...).
422 | ; Default Value: not set
423 | ;chroot =
424 |
425 | ; Chdir to this directory at the start.
426 | ; Note: relative path can be used.
427 | ; Default Value: current directory or / when chroot
428 | ;chdir = /var/www
429 |
430 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and
431 | ; stderr will be redirected to /dev/null according to FastCGI specs.
432 | ; Note: on highloaded environment, this can cause some delay in the page
433 | ; process time (several ms).
434 | ; Default Value: no
435 | ;catch_workers_output = yes
436 |
437 | ; Decorate worker output with prefix and suffix containing information about
438 | ; the child that writes to the log and if stdout or stderr is used as well as
439 | ; log level and time. This options is used only if catch_workers_output is yes.
440 | ; Settings to "no" will output data as written to the stdout or stderr.
441 | ; Default value: yes
442 | ;decorate_workers_output = no
443 |
444 | ; Clear environment in FPM workers
445 | ; Prevents arbitrary environment variables from reaching FPM worker processes
446 | ; by clearing the environment in workers before env vars specified in this
447 | ; pool configuration are added.
448 | ; Setting to "no" will make all environment variables available to PHP code
449 | ; via getenv(), $_ENV and $_SERVER.
450 | ; Default Value: yes
451 | ;clear_env = no
452 |
453 | ; Limits the extensions of the main script FPM will allow to parse. This can
454 | ; prevent configuration mistakes on the web server side. You should only limit
455 | ; FPM to .php extensions to prevent malicious users to use other extensions to
456 | ; execute php code.
457 | ; Note: set an empty value to allow all extensions.
458 | ; Default Value: .php
459 | ;security.limit_extensions = .php .php3 .php4 .php5 .php7
460 |
461 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
462 | ; the current environment.
463 | ; Default Value: clean env
464 | ;env[HOSTNAME] = $HOSTNAME
465 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin
466 | ;env[TMP] = /tmp
467 | ;env[TMPDIR] = /tmp
468 | ;env[TEMP] = /tmp
469 |
470 | ; Additional php.ini defines, specific to this pool of workers. These settings
471 | ; overwrite the values previously defined in the php.ini. The directives are the
472 | ; same as the PHP SAPI:
473 | ; php_value/php_flag - you can set classic ini defines which can
474 | ; be overwritten from PHP call 'ini_set'.
475 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by
476 | ; PHP call 'ini_set'
477 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
478 |
479 | ; Defining 'extension' will load the corresponding shared extension from
480 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
481 | ; overwrite previously defined php.ini values, but will append the new value
482 | ; instead.
483 |
484 | ; Note: path INI options can be relative and will be expanded with the prefix
485 | ; (pool, global or /usr/local)
486 |
487 | ; Default Value: nothing is defined by default except the values in php.ini and
488 | ; specified at startup with the -d argument
489 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
490 | ;php_flag[display_errors] = off
491 | ;php_admin_value[error_log] = /var/log/fpm-php.www.log
492 | ;php_admin_flag[log_errors] = on
493 | ;php_admin_value[memory_limit] = 32M
494 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/003_nginx_phpfpm/nginx/conf.d/symfony7site.conf:
--------------------------------------------------------------------------------
1 | server {
2 | server_name symfony7site localhost;
3 | root /var/www/symfony/public;
4 |
5 | location = /fpm-status {
6 | fastcgi_pass 003_phpfpm:9000;
7 | include fastcgi_params;
8 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
9 | fastcgi_param DOCUMENT_ROOT $realpath_root;
10 | }
11 | location / {
12 | # try to serve file directly, fallback to index.php
13 | try_files $uri /index.php$is_args$args;
14 | }
15 | location ~ ^/index\.php(/|$) {
16 | # when PHP-FPM is configured to use TCP
17 | fastcgi_pass 003_phpfpm:9000;
18 | fastcgi_keep_conn on;
19 |
20 | fastcgi_split_path_info ^(.+\.php)(/.*)$;
21 | include fastcgi_params;
22 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
23 | fastcgi_param DOCUMENT_ROOT $realpath_root;
24 | internal;
25 | }
26 |
27 | # return 404 for all other php files not matching the front controller
28 | # this prevents access to other php files you don't want to be accessible.
29 | location ~ \.php$ {
30 | return 404;
31 | }
32 | #error_log /var/log/nginx/project_error.log;
33 | #access_log /var/log/nginx/project_access.log;
34 | }
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/003_nginx_phpfpm/nginx/nginx.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:1.25.3
2 | COPY ./runtimes/006_nginx_roadrunner/nginx/nginx.conf /etc/nginx/nginx.conf
3 | COPY ./runtimes/003_nginx_phpfpm/nginx/conf.d/symfony7site.conf /etc/nginx/conf.d/symfony7site.conf
4 | COPY "./project" "/var/www/symfony"
5 |
6 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/003_nginx_phpfpm/nginx/nginx.conf:
--------------------------------------------------------------------------------
1 |
2 | user nginx;
3 | worker_processes auto;
4 |
5 | error_log stderr error;
6 | pid /var/run/nginx.pid;
7 |
8 |
9 | events {
10 | worker_connections 10024;
11 | }
12 |
13 |
14 | http {
15 | include /etc/nginx/mime.types;
16 | default_type application/octet-stream;
17 |
18 | access_log off;
19 |
20 | sendfile on;
21 | #tcp_nopush on;
22 |
23 | keepalive_timeout 65;
24 |
25 | #gzip on;
26 |
27 | include /etc/nginx/conf.d/*.conf;
28 | }
29 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/004_nginx_unit/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 004_nginx_unit:
3 | build:
4 | context: ../../
5 | dockerfile: "./runtimes/004_nginx_unit/unit/unit.Dockerfile"
6 | image: 004_nginx_unit
7 | container_name: "004_nginx_unit"
8 | hostname: symfony7site
9 | ports:
10 | - '80:80'
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 | networks:
22 | php-benchmarks:
23 | name: php-benchmarks
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/004_nginx_unit/unit/config/symfony7site.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "listeners": {
3 | "*:80": {
4 | "pass": "routes"
5 | }
6 | },
7 | "routes": [
8 | {
9 | "match": {
10 | "host": "symfony7site"
11 | },
12 | "action": {
13 | "pass": "applications/symfony/index"
14 | }
15 | },
16 | {
17 | "match": {
18 | "host": "localhost"
19 | },
20 | "action": {
21 | "pass": "applications/symfony/index"
22 | }
23 | }
24 | ],
25 | "applications": {
26 | "symfony": {
27 | "type": "php",
28 | "processes": {
29 | "spare": 1,
30 | "idle_timeout": 20
31 | },
32 | "targets": {
33 | "direct": {
34 | "root": "/var/www/symfony/public/"
35 | },
36 | "index": {
37 | "root": "/var/www/symfony/public/",
38 | "script": "index.php"
39 | }
40 | },
41 | "options": {
42 | "file": "/usr/local/etc/php/php.ini",
43 | "admin": {
44 | "date.timezone": "Europe/Warsaw",
45 | "short_open_tag": "off",
46 | "expose_php": "off",
47 | "allow_url_fopen": "off",
48 | "memory_limit": "128M",
49 | "variables_order": "EGPCS",
50 | "realpath_cache_size": "4096K",
51 | "realpath_cache_ttl": "600",
52 | "opcache.enable": "1",
53 | "opcache.jit_buffer_size": "256M",
54 | "opcache.jit": "tracing",
55 | "opcache.preload": "/var/www/symfony/config/preload.php",
56 | "opcache.preload_user": "root",
57 | "opcache.validate_timestamps": "0",
58 | "opcache.memory_consumption": "256",
59 | "opcache.max_accelerated_files": "20000"
60 | }
61 | }
62 | }
63 | },
64 | "settings": {
65 | "http": {
66 | "server_version": false
67 | }
68 | }
69 | }
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/004_nginx_unit/unit/unit.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM unit:php8.3
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini;
8 | ADD ./runtimes/004_nginx_unit/unit/config /docker-entrypoint.d/config
9 |
10 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
11 |
12 | RUN chmod +x /usr/local/bin/install-php-extensions && \
13 | install-php-extensions \
14 | exif \
15 | intl \
16 | opcache \
17 | pdo_pgsql \
18 | tidy \
19 | gd \
20 | bcmath \
21 | sockets \
22 | zip && \
23 | install-php-extensions @composer;
24 |
25 | COPY "./project" "/var/www/symfony"
26 |
27 |
28 | WORKDIR /var/www/symfony
29 |
30 | RUN cp .env.example .env.local
31 |
32 | RUN rm -rf vendor && \
33 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
34 | composer dump-autoload --no-dev --classmap-authoritative && \
35 | composer check-platform-reqs && \
36 | php bin/console cache:clear && \
37 | php bin/console cache:warmup
38 |
39 | EXPOSE 80
40 | EXPOSE 9090
41 | CMD ["unitd", "--no-daemon", "--control", "*:9090"]
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/005_roadrunner/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 005_roadrunner:
3 | build:
4 | context: ../../
5 | dockerfile: "./runtimes/005_roadrunner/roadrunner/roadrunner.Dockerfile"
6 | image: "005_roadrunner"
7 | container_name: "005_roadrunner"
8 | hostname: symfony7site
9 | ports:
10 | - '80:80'
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 | networks:
22 | php-benchmarks:
23 | name: php-benchmarks
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/005_roadrunner/roadrunner/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 |
6 | memory_limit = 128M
7 |
8 | realpath_cache_size=4096K
9 | realpath_cache_ttl=600
10 |
11 | [opcache]
12 | opcache.enable=1
13 | opcache.enable_cli=1
14 | opcache.jit_buffer_size=256M
15 | opcache.jit=tracing
16 | opcache.preload_user=root
17 | opcache.preload=/var/www/symfony/config/preload.php
18 | opcache.validate_timestamps=0
19 | opcache.memory_consumption=256
20 | opcache.max_accelerated_files=20000
21 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/005_roadrunner/roadrunner/roadrunner.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ghcr.io/roadrunner-server/roadrunner:2023.3.12 AS roadrunner
2 | FROM php:8.3-cli
3 |
4 | RUN set -xe; \
5 | apt update; \
6 | apt install unzip
7 |
8 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
9 |
10 | RUN chmod +x /usr/local/bin/install-php-extensions && \
11 | install-php-extensions \
12 | exif \
13 | intl \
14 | opcache \
15 | pdo_pgsql \
16 | tidy \
17 | gd \
18 | bcmath \
19 | sockets \
20 | zip && \
21 | install-php-extensions @composer-2.6.6;
22 |
23 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
24 | COPY ./runtimes/005_roadrunner/roadrunner/php.ini /usr/local/etc/php/conf.d/custom-php.ini
25 |
26 | COPY "./project" "/var/www/symfony"
27 |
28 | WORKDIR /var/www/symfony
29 |
30 | RUN cp .env.example .env.local && \
31 | cp .rr.production.yaml .rr.yaml
32 |
33 | RUN rm -rf vendor && \
34 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
35 | composer dump-autoload --no-dev --classmap-authoritative && \
36 | composer check-platform-reqs && \
37 | php bin/console cache:clear && \
38 | php bin/console cache:warmup
39 |
40 | COPY --from=roadrunner /usr/bin/rr /usr/local/bin/rr
41 |
42 | EXPOSE 80
43 |
44 | CMD ["rr", "serve", "-c", ".rr.yaml"]
45 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/006_nginx_roadrunner/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 006_nginx:
3 | build:
4 | context: ../../
5 | dockerfile: "./runtimes/006_nginx_roadrunner/nginx/nginx.Dockerfile"
6 | image: 006_nginx
7 | container_name: "006_nginx"
8 | hostname: symfony7site
9 | ports:
10 | - '80:80'
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 |
22 | 006_roadrunner:
23 | build:
24 | context: ../../
25 | dockerfile: "./runtimes/006_nginx_roadrunner/roadrunner/roadrunner.Dockerfile"
26 | image: "006_roadrunner"
27 | container_name: "006_roadrunner"
28 | networks:
29 | - php-benchmarks
30 | deploy:
31 | resources:
32 | limits:
33 | cpus: '1'
34 | memory: '1gb'
35 | reservations:
36 | cpus: '1'
37 | memory: '1gb'
38 | networks:
39 | php-benchmarks:
40 | name: php-benchmarks
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/006_nginx_roadrunner/nginx/conf.d/symfony7site.conf:
--------------------------------------------------------------------------------
1 | server {
2 | server_name symfony7site localhost;
3 | root /var/www/symfony/public;
4 | location / {
5 | # try to serve file directly, fallback to index.php
6 | try_files $uri /index.php$is_args$args;
7 | }
8 | location ~ ^/index\.php(/|$) {
9 | # when PHP-FPM is configured to use TCP
10 | fastcgi_pass 006_roadrunner:9000;
11 | fastcgi_keep_conn on;
12 |
13 | fastcgi_split_path_info ^(.+\.php)(/.*)$;
14 | include fastcgi_params;
15 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
16 | fastcgi_param DOCUMENT_ROOT $realpath_root;
17 | internal;
18 | }
19 |
20 | # return 404 for all other php files not matching the front controller
21 | # this prevents access to other php files you don't want to be accessible.
22 | location ~ \.php$ {
23 | return 404;
24 | }
25 | #error_log /var/log/nginx/project_error.log;
26 | #access_log /var/log/nginx/project_access.log;
27 | }
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/006_nginx_roadrunner/nginx/nginx.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM nginx:1.25.3
2 | COPY ./runtimes/006_nginx_roadrunner/nginx/nginx.conf /etc/nginx/nginx.conf
3 | COPY ./runtimes/006_nginx_roadrunner/nginx/conf.d/symfony7site.conf /etc/nginx/conf.d/symfony7site.conf
4 | COPY "./project" "/var/www/symfony"
5 |
6 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/006_nginx_roadrunner/nginx/nginx.conf:
--------------------------------------------------------------------------------
1 |
2 | user nginx;
3 | worker_processes auto;
4 |
5 | error_log stderr error;
6 | pid /var/run/nginx.pid;
7 |
8 |
9 | events {
10 | worker_connections 10024;
11 | }
12 |
13 |
14 | http {
15 | include /etc/nginx/mime.types;
16 | default_type application/octet-stream;
17 |
18 | access_log off;
19 |
20 | sendfile on;
21 | #tcp_nopush on;
22 |
23 | keepalive_timeout 65;
24 |
25 | #gzip on;
26 |
27 | include /etc/nginx/conf.d/*.conf;
28 | }
29 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/006_nginx_roadrunner/roadrunner/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 |
6 | memory_limit = 128M
7 |
8 | realpath_cache_size=4096K
9 | realpath_cache_ttl=600
10 |
11 | [opcache]
12 | opcache.enable=1
13 | opcache.enable_cli=1
14 | opcache.jit_buffer_size=256M
15 | opcache.jit=tracing
16 | opcache.preload_user=root
17 | opcache.preload=/var/www/symfony/config/preload.php
18 | opcache.validate_timestamps=0
19 | opcache.memory_consumption=256
20 | opcache.max_accelerated_files=20000
21 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/006_nginx_roadrunner/roadrunner/roadrunner.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:8.3-cli
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
8 |
9 | RUN chmod +x /usr/local/bin/install-php-extensions && \
10 | install-php-extensions \
11 | exif \
12 | intl \
13 | opcache \
14 | pdo_pgsql \
15 | tidy \
16 | gd \
17 | bcmath \
18 | sockets \
19 | zip && \
20 | install-php-extensions @composer;
21 |
22 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
23 | COPY ./runtimes/006_nginx_roadrunner/roadrunner/php.ini /usr/local/etc/php/conf.d/custom-php.ini
24 |
25 | COPY "./project" "/var/www/symfony"
26 |
27 | WORKDIR /var/www/symfony
28 |
29 | RUN cp .env.example .env.local && \
30 | cp .rr.fcgi.yaml .rr.yaml
31 |
32 | RUN rm -rf vendor && \
33 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
34 | composer dump-autoload --no-dev --classmap-authoritative && \
35 | composer check-platform-reqs && \
36 | php bin/console cache:clear && \
37 | php bin/console cache:warmup
38 |
39 | COPY --from=ghcr.io/roadrunner-server/roadrunner:2023.3.8 /usr/bin/rr /usr/bin/rr
40 |
41 | EXPOSE 9000
42 |
43 | CMD ["rr", "serve"]
44 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/007_frankenphp/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 007_frankenphp:
3 | build:
4 | context: ../../
5 | dockerfile: "./runtimes/007_frankenphp/frankenphp/frankenphp.Dockerfile"
6 | image: "007_frankenphp"
7 | container_name: "007_frankenphp"
8 | hostname: symfony7site
9 | networks:
10 | - php-benchmarks
11 | ports:
12 | - '80:80'
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 | networks:
22 | php-benchmarks:
23 | name: php-benchmarks
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/007_frankenphp/frankenphp/Caddyfile:
--------------------------------------------------------------------------------
1 | {
2 | {$CADDY_GLOBAL_OPTIONS}
3 |
4 | frankenphp {
5 | #worker /path/to/your/worker.php
6 | {$FRANKENPHP_CONFIG}
7 | }
8 |
9 | # https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm
10 | order mercure after encode
11 | order vulcain after reverse_proxy
12 | order php_server before file_server
13 | order php before file_server
14 | }
15 |
16 | {$CADDY_EXTRA_CONFIG}
17 |
18 | # {$SERVER_NAME:localhost} {
19 | http://localhost http://symfony7site {
20 | log {
21 | # Redact the authorization query parameter that can be set by Mercure
22 | format filter {
23 | wrap console
24 | fields {
25 | uri query {
26 | replace authorization REDACTED
27 | }
28 | }
29 | }
30 | }
31 |
32 | root * public/
33 | #encode zstd gzip
34 |
35 | # Uncomment the following lines to enable Mercure and Vulcain modules
36 | #mercure {
37 | # # Transport to use (default to Bolt)
38 | # transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
39 | # # Publisher JWT key
40 | # publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
41 | # # Subscriber JWT key
42 | # subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
43 | # # Allow anonymous subscribers (double-check that it's what you want)
44 | # anonymous
45 | # # Enable the subscription API (double-check that it's what you want)
46 | # subscriptions
47 | # # Extra directives
48 | # {$MERCURE_EXTRA_DIRECTIVES}
49 | #}
50 | #vulcain
51 |
52 | {$CADDY_SERVER_EXTRA_DIRECTIVES}
53 |
54 | php_server
55 | }
56 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/007_frankenphp/frankenphp/conf.d/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 |
6 | memory_limit = 128M
7 |
8 | realpath_cache_size=4096K
9 | realpath_cache_ttl=600
10 |
11 |
12 | [opcache]
13 | opcache.enable=1
14 | opcache.enable_cli=1
15 | opcache.preload_user=root
16 | opcache.jit_buffer_size=256M
17 | opcache.jit=tracing
18 | opcache.preload=/app/config/preload.php
19 | opcache.validate_timestamps=0
20 | opcache.memory_consumption=256
21 | opcache.max_accelerated_files=20000
22 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/007_frankenphp/frankenphp/frankenphp.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM dunglas/frankenphp:latest-php8.3.1
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | RUN install-php-extensions \
8 | exif \
9 | intl \
10 | opcache \
11 | pdo_pgsql \
12 | tidy \
13 | gd \
14 | bcmath \
15 | sockets \
16 | zip && \
17 | install-php-extensions @composer;
18 |
19 | COPY ./runtimes/007_frankenphp/frankenphp/Caddyfile /etc/caddy/Caddyfile
20 |
21 | RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
22 | COPY ./runtimes/007_frankenphp/frankenphp/conf.d/php.ini $PHP_INI_DIR/conf.d/custom-php.ini
23 |
24 | COPY "./project" "/app"
25 |
26 | RUN cd /app && \
27 | cp .env.example .env.local && \
28 | rm -rf vendor && \
29 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
30 | composer dump-autoload --no-dev --classmap-authoritative && \
31 | composer check-platform-reqs && \
32 | php bin/console cache:clear && \
33 | php bin/console cache:warmup
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/008_frankenphp_workermode/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 008_frankenphp_workermode:
3 | build:
4 | context: ../../
5 | dockerfile: "./runtimes/008_frankenphp_workermode/frankenphp/frankenphp.Dockerfile"
6 | image: "008_frankenphp_workermode"
7 | container_name: "008_frankenphp_workermode"
8 | hostname: symfony7site
9 | networks:
10 | - php-benchmarks
11 | ports:
12 | - '80:80'
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 | networks:
22 | php-benchmarks:
23 | name: php-benchmarks
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/008_frankenphp_workermode/frankenphp/Caddyfile:
--------------------------------------------------------------------------------
1 | {
2 | {$CADDY_GLOBAL_OPTIONS}
3 |
4 | frankenphp {
5 | #worker /path/to/your/worker.php
6 | {$FRANKENPHP_CONFIG}
7 | }
8 |
9 | # https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm
10 | order mercure after encode
11 | order vulcain after reverse_proxy
12 | order php_server before file_server
13 | order php before file_server
14 | }
15 |
16 | {$CADDY_EXTRA_CONFIG}
17 |
18 | # {$SERVER_NAME:localhost} {
19 | http://localhost http://symfony7site {
20 | log {
21 | # Redact the authorization query parameter that can be set by Mercure
22 | format filter {
23 | wrap console
24 | fields {
25 | uri query {
26 | replace authorization REDACTED
27 | }
28 | }
29 | }
30 | }
31 |
32 | root * public/
33 | #encode zstd gzip
34 |
35 | # Uncomment the following lines to enable Mercure and Vulcain modules
36 | #mercure {
37 | # # Transport to use (default to Bolt)
38 | # transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
39 | # # Publisher JWT key
40 | # publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
41 | # # Subscriber JWT key
42 | # subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
43 | # # Allow anonymous subscribers (double-check that it's what you want)
44 | # anonymous
45 | # # Enable the subscription API (double-check that it's what you want)
46 | # subscriptions
47 | # # Extra directives
48 | # {$MERCURE_EXTRA_DIRECTIVES}
49 | #}
50 | #vulcain
51 |
52 | {$CADDY_SERVER_EXTRA_DIRECTIVES}
53 |
54 | php_server
55 | }
56 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/008_frankenphp_workermode/frankenphp/conf.d/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 | memory_limit = 128M
6 |
7 | realpath_cache_size=4096K
8 | realpath_cache_ttl=600
9 |
10 | [opcache]
11 | opcache.enable=1
12 | opcache.enable_cli=1
13 | opcache.preload_user=root
14 | opcache.jit_buffer_size=256M
15 | opcache.jit=tracing
16 | opcache.preload=/app/config/preload.php
17 | opcache.validate_timestamps=0
18 | opcache.memory_consumption=256
19 | opcache.max_accelerated_files=20000
20 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/008_frankenphp_workermode/frankenphp/frankenphp.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM dunglas/frankenphp:latest-php8.3.1
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | RUN install-php-extensions \
8 | exif \
9 | intl \
10 | opcache \
11 | pdo_pgsql \
12 | tidy \
13 | gd \
14 | bcmath \
15 | sockets \
16 | zip && \
17 | install-php-extensions @composer;
18 |
19 | COPY ./runtimes/008_frankenphp_workermode/frankenphp/Caddyfile /etc/caddy/Caddyfile
20 |
21 | # Issue with php.ini-production, worker can't start.
22 | #RUN cp $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini
23 | COPY ./runtimes/008_frankenphp_workermode/frankenphp/conf.d/php.ini $PHP_INI_DIR/conf.d/custom-php.ini
24 |
25 | ENV FRANKENPHP_CONFIG="worker ./public/index.php"
26 | ENV APP_RUNTIME="Runtime\\FrankenPhpSymfony\\Runtime"
27 |
28 | COPY "./project" "/app"
29 |
30 | RUN cd /app && \
31 | cp .env.example .env.local && \
32 | rm -rf vendor && \
33 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
34 | composer dump-autoload --no-dev --classmap-authoritative && \
35 | composer check-platform-reqs && \
36 | php bin/console cache:clear && \
37 | php bin/console cache:warmup
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/009_swoole/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 009_swoole:
3 | build:
4 | context: ../../
5 | dockerfile: "./runtimes/009_swoole/swoole/swoole.Dockerfile"
6 | image: "009_swoole"
7 | container_name: "009_swoole"
8 | hostname: symfony7site
9 | ports:
10 | - '80:80'
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 |
22 | networks:
23 | php-benchmarks:
24 | name: php-benchmarks
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/009_swoole/swoole/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 | memory_limit = 128M
6 |
7 | realpath_cache_size=4096K
8 | realpath_cache_ttl=600
9 |
10 | [opcache]
11 | opcache.enable=1
12 | opcache.enable_cli=1
13 | opcache.preload_user=root
14 | opcache.jit_buffer_size=256M
15 | opcache.jit=tracing
16 | opcache.preload=/var/www/symfony/config/preload.php
17 | opcache.validate_timestamps=0
18 | opcache.memory_consumption=256
19 | opcache.max_accelerated_files=20000
20 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/009_swoole/swoole/swoole.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM phpswoole/swoole:php8.3
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
8 |
9 | RUN chmod +x /usr/local/bin/install-php-extensions && \
10 | install-php-extensions \
11 | exif \
12 | intl \
13 | opcache \
14 | pdo_pgsql \
15 | tidy \
16 | gd \
17 | bcmath \
18 | sockets \
19 | zip && \
20 | install-php-extensions @composer;
21 |
22 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
23 | COPY ./runtimes/009_swoole/swoole/php.ini /usr/local/etc/php/conf.d/custom-php.ini
24 |
25 | COPY "./project" "/var/www/symfony"
26 |
27 | WORKDIR /var/www/symfony
28 |
29 | RUN cp .env.example .env.local
30 |
31 | RUN rm -rf vendor && \
32 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
33 | composer dump-autoload --no-dev --classmap-authoritative && \
34 | composer check-platform-reqs && \
35 | php bin/console cache:clear && \
36 | php bin/console cache:warmup
37 |
38 | ENV APP_RUNTIME="Runtime\\Swoole\\Runtime"
39 |
40 | EXPOSE 80
41 |
42 | CMD ["php", "./public/index.swoole.php"]
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/010_adapterman/adapterman/adapterman.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:8.3-cli
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
8 |
9 | RUN chmod +x /usr/local/bin/install-php-extensions && \
10 | install-php-extensions \
11 | exif \
12 | event \
13 | intl \
14 | opcache \
15 | pcntl \
16 | pdo_pgsql \
17 | tidy \
18 | gd \
19 | bcmath \
20 | sockets \
21 | zip && \
22 | install-php-extensions @composer;
23 |
24 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
25 |
26 |
27 | COPY "./project" "/var/www/symfony"
28 |
29 | WORKDIR /var/www/symfony
30 |
31 | RUN cp .env.example .env.local
32 | RUN rm -rf vendor && \
33 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
34 | composer dump-autoload --no-dev --classmap-authoritative && \
35 | composer check-platform-reqs && \
36 | php bin/console cache:clear && \
37 | php bin/console cache:warmup
38 |
39 | #ENV APP_RUNTIME=""
40 | COPY ./runtimes/010_adapterman/adapterman/php.ini /usr/local/etc/php/conf.d/custom-php.ini
41 |
42 | EXPOSE 80
43 |
44 | CMD ["php", "server.php", "start"]
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/010_adapterman/adapterman/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 | memory_limit = 128M
6 |
7 | realpath_cache_size=4096K
8 | realpath_cache_ttl=600
9 |
10 | [opcache]
11 | opcache.enable=1
12 | opcache.enable_cli=1
13 | opcache.preload_user=root
14 | opcache.jit_buffer_size=256M
15 | opcache.jit=tracing
16 | opcache.preload=/var/www/symfony/config/preload.php
17 | opcache.validate_timestamps=0
18 | opcache.memory_consumption=256
19 | opcache.max_accelerated_files=20000
20 |
21 | disable_functions=header,header_remove,headers_sent,http_response_code,setcookie,session_create_id,session_id,session_name,session_save_path,session_status,session_start,session_write_close,session_regenerate_id,set_time_limit
22 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/010_adapterman/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 010_adapterman:
3 | build:
4 | context: ../../
5 | dockerfile: "./runtimes/010_adapterman/adapterman/adapterman.Dockerfile"
6 | image: "010_adapterman"
7 | container_name: "010_adapterman"
8 | hostname: symfony7site
9 | ports:
10 | - '8000:80'
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 |
22 | networks:
23 | php-benchmarks:
24 | name: php-benchmarks
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/011_caddy_phpfpm/caddy/Caddyfile:
--------------------------------------------------------------------------------
1 | # {$SERVER_NAME:localhost} {
2 | http://localhost http://symfony7site {
3 | root * /var/www/symfony/public
4 | php_fastcgi 011_phpfpm:9000
5 | }
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/011_caddy_phpfpm/caddy/caddy.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM caddy:2.7.6
2 |
3 | COPY ./runtimes/011_caddy_phpfpm/caddy/Caddyfile /etc/caddy/Caddyfile
4 |
5 | COPY "./project" "/var/www/symfony"
6 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/011_caddy_phpfpm/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 003_nginx:
3 | build:
4 | context: ../../
5 | dockerfile: ./runtimes/011_caddy_phpfpm/caddy/caddy.Dockerfile
6 | image: 011_caddy
7 | container_name: "011_caddy"
8 | hostname: symfony7site
9 | ports:
10 | - '8000:80'
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 |
22 | 003_phpfpm:
23 | build:
24 | context: ../../
25 | dockerfile: ./runtimes/011_caddy_phpfpm/fpm/phpfpm.Dockerfile
26 | image: 011_phpfpm
27 | container_name: "011_phpfpm"
28 | ports:
29 | - "9000:9000"
30 | networks:
31 | - php-benchmarks
32 | deploy:
33 | resources:
34 | limits:
35 | cpus: '1'
36 | memory: '1gb'
37 | reservations:
38 | cpus: '1'
39 | memory: '1gb'
40 |
41 | networks:
42 | php-benchmarks:
43 | name: php-benchmarks
44 |
45 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/011_caddy_phpfpm/fpm/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 |
6 | memory_limit = 128M
7 |
8 | realpath_cache_size=4096K
9 | realpath_cache_ttl=600
10 |
11 | [opcache]
12 | opcache.enable=1
13 | opcache.jit_buffer_size=256M
14 | opcache.jit=tracing
15 | opcache.preload=/var/www/symfony/config/preload.php
16 | opcache.preload_user=www-data
17 | opcache.validate_timestamps=0
18 | opcache.memory_consumption=256
19 | opcache.max_accelerated_files=20000
20 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/011_caddy_phpfpm/fpm/phpfpm.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:8.3-fpm
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
8 |
9 | RUN chmod +x /usr/local/bin/install-php-extensions && \
10 | install-php-extensions \
11 | exif \
12 | intl \
13 | opcache \
14 | pdo_pgsql \
15 | tidy \
16 | gd \
17 | bcmath \
18 | sockets \
19 | zip && \
20 | install-php-extensions @composer;
21 |
22 | COPY "./project" "/var/www/symfony"
23 |
24 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini;
25 | COPY ./runtimes/003_nginx_phpfpm/fpm/php.ini /usr/local/etc/php/conf.d/custom-php.ini
26 | COPY ./runtimes/003_nginx_phpfpm/fpm/www.conf /usr/local/etc/php-fpm.d/www.conf
27 |
28 | WORKDIR /var/www/symfony
29 |
30 | RUN cp .env.example .env.local
31 | ENV COMPOSER_ALLOW_SUPERUSER=1
32 |
33 | RUN rm -rf vendor && \
34 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
35 | composer dump-autoload --no-dev --classmap-authoritative && \
36 | composer check-platform-reqs && \
37 | php bin/console cache:clear && \
38 | php bin/console cache:warmup
--------------------------------------------------------------------------------
/001_symfony7_wo_db/runtimes/011_caddy_phpfpm/fpm/www.conf:
--------------------------------------------------------------------------------
1 | ; Start a new pool named 'www'.
2 | ; the variable $pool can be used in any directive and will be replaced by the
3 | ; pool name ('www' here)
4 | [www]
5 |
6 | ; Per pool prefix
7 | ; It only applies on the following directives:
8 | ; - 'access.log'
9 | ; - 'slowlog'
10 | ; - 'listen' (unixsocket)
11 | ; - 'chroot'
12 | ; - 'chdir'
13 | ; - 'php_values'
14 | ; - 'php_admin_values'
15 | ; When not set, the global prefix (or NONE) applies instead.
16 | ; Note: This directive can also be relative to the global prefix.
17 | ; Default Value: none
18 | ;prefix = /path/to/pools/$pool
19 |
20 | ; Unix user/group of the child processes. This can be used only if the master
21 | ; process running user is root. It is set after the child process is created.
22 | ; The user and group can be specified either by their name or by their numeric
23 | ; IDs.
24 | ; Note: If the user is root, the executable needs to be started with
25 | ; --allow-to-run-as-root option to work.
26 | ; Default Values: The user is set to master process running user by default.
27 | ; If the group is not set, the user's group is used.
28 | user = www-data
29 | group = www-data
30 |
31 | ; The address on which to accept FastCGI requests.
32 | ; Valid syntaxes are:
33 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
34 | ; a specific port;
35 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
36 | ; a specific port;
37 | ; 'port' - to listen on a TCP socket to all addresses
38 | ; (IPv6 and IPv4-mapped) on a specific port;
39 | ; '/path/to/unix/socket' - to listen on a unix socket.
40 | ; Note: This value is mandatory.
41 | listen = 127.0.0.1:9000
42 |
43 | ; Set listen(2) backlog.
44 | ; Default Value: 511 (-1 on Linux, FreeBSD and OpenBSD)
45 | ;listen.backlog = 511
46 |
47 | ; Set permissions for unix socket, if one is used. In Linux, read/write
48 | ; permissions must be set in order to allow connections from a web server. Many
49 | ; BSD-derived systems allow connections regardless of permissions. The owner
50 | ; and group can be specified either by name or by their numeric IDs.
51 | ; Default Values: Owner is set to the master process running user. If the group
52 | ; is not set, the owner's group is used. Mode is set to 0660.
53 | ;listen.owner = www-data
54 | ;listen.group = www-data
55 | ;listen.mode = 0660
56 |
57 | ; When POSIX Access Control Lists are supported you can set them using
58 | ; these options, value is a comma separated list of user/group names.
59 | ; When set, listen.owner and listen.group are ignored
60 | ;listen.acl_users =
61 | ;listen.acl_groups =
62 |
63 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
64 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
65 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
66 | ; must be separated by a comma. If this value is left blank, connections will be
67 | ; accepted from any ip address.
68 | ; Default Value: any
69 | ;listen.allowed_clients = 127.0.0.1
70 |
71 | ; Set the associated the route table (FIB). FreeBSD only
72 | ; Default Value: -1
73 | ;listen.setfib = 1
74 |
75 | ; Specify the nice(2) priority to apply to the pool processes (only if set)
76 | ; The value can vary from -19 (highest priority) to 20 (lower priority)
77 | ; Note: - It will only work if the FPM master process is launched as root
78 | ; - The pool processes will inherit the master process priority
79 | ; unless it specified otherwise
80 | ; Default Value: no set
81 | ; process.priority = -19
82 |
83 | ; Set the process dumpable flag (PR_SET_DUMPABLE prctl for Linux or
84 | ; PROC_TRACE_CTL procctl for FreeBSD) even if the process user
85 | ; or group is different than the master process user. It allows to create process
86 | ; core dump and ptrace the process for the pool user.
87 | ; Default Value: no
88 | ; process.dumpable = yes
89 |
90 | ; Choose how the process manager will control the number of child processes.
91 | ; Possible Values:
92 | ; static - a fixed number (pm.max_children) of child processes;
93 | ; dynamic - the number of child processes are set dynamically based on the
94 | ; following directives. With this process management, there will be
95 | ; always at least 1 children.
96 | ; pm.max_children - the maximum number of children that can
97 | ; be alive at the same time.
98 | ; pm.start_servers - the number of children created on startup.
99 | ; pm.min_spare_servers - the minimum number of children in 'idle'
100 | ; state (waiting to process). If the number
101 | ; of 'idle' processes is less than this
102 | ; number then some children will be created.
103 | ; pm.max_spare_servers - the maximum number of children in 'idle'
104 | ; state (waiting to process). If the number
105 | ; of 'idle' processes is greater than this
106 | ; number then some children will be killed.
107 | ; pm.max_spawn_rate - the maximum number of rate to spawn child
108 | ; processes at once.
109 | ; ondemand - no children are created at startup. Children will be forked when
110 | ; new requests will connect. The following parameter are used:
111 | ; pm.max_children - the maximum number of children that
112 | ; can be alive at the same time.
113 | ; pm.process_idle_timeout - The number of seconds after which
114 | ; an idle process will be killed.
115 | ; Note: This value is mandatory.
116 | pm = dynamic
117 |
118 | ; The number of child processes to be created when pm is set to 'static' and the
119 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
120 | ; This value sets the limit on the number of simultaneous requests that will be
121 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
122 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
123 | ; CGI. The below defaults are based on a server without much resources. Don't
124 | ; forget to tweak pm.* to fit your needs.
125 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
126 | ; Note: This value is mandatory.
127 | ; pm.max_children = 5
128 | pm.max_children = 33
129 |
130 | ; The number of child processes created on startup.
131 | ; Note: Used only when pm is set to 'dynamic'
132 | ; Default Value: (min_spare_servers + max_spare_servers) / 2
133 | pm.start_servers = 10
134 |
135 | ; The desired minimum number of idle server processes.
136 | ; Note: Used only when pm is set to 'dynamic'
137 | ; Note: Mandatory when pm is set to 'dynamic'
138 | ; pm.min_spare_servers = 1
139 | pm.min_spare_servers = 10
140 |
141 | ; The desired maximum number of idle server processes.
142 | ; Note: Used only when pm is set to 'dynamic'
143 | ; Note: Mandatory when pm is set to 'dynamic'
144 | ;pm.max_spare_servers = 3
145 | pm.max_spare_servers = 30
146 |
147 | ; The number of rate to spawn child processes at once.
148 | ; Note: Used only when pm is set to 'dynamic'
149 | ; Note: Mandatory when pm is set to 'dynamic'
150 | ; Default Value: 32
151 | ;pm.max_spawn_rate = 32
152 |
153 | ; The number of seconds after which an idle process will be killed.
154 | ; Note: Used only when pm is set to 'ondemand'
155 | ; Default Value: 10s
156 | ;pm.process_idle_timeout = 10s;
157 |
158 | ; The number of requests each child process should execute before respawning.
159 | ; This can be useful to work around memory leaks in 3rd party libraries. For
160 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
161 | ; Default Value: 0
162 | pm.max_requests = 500
163 |
164 | ; The URI to view the FPM status page. If this value is not set, no URI will be
165 | ; recognized as a status page. It shows the following information:
166 | ; pool - the name of the pool;
167 | ; process manager - static, dynamic or ondemand;
168 | ; start time - the date and time FPM has started;
169 | ; start since - number of seconds since FPM has started;
170 | ; accepted conn - the number of request accepted by the pool;
171 | ; listen queue - the number of request in the queue of pending
172 | ; connections (see backlog in listen(2));
173 | ; max listen queue - the maximum number of requests in the queue
174 | ; of pending connections since FPM has started;
175 | ; listen queue len - the size of the socket queue of pending connections;
176 | ; idle processes - the number of idle processes;
177 | ; active processes - the number of active processes;
178 | ; total processes - the number of idle + active processes;
179 | ; max active processes - the maximum number of active processes since FPM
180 | ; has started;
181 | ; max children reached - number of times, the process limit has been reached,
182 | ; when pm tries to start more children (works only for
183 | ; pm 'dynamic' and 'ondemand');
184 | ; Value are updated in real time.
185 | ; Example output:
186 | ; pool: www
187 | ; process manager: static
188 | ; start time: 01/Jul/2011:17:53:49 +0200
189 | ; start since: 62636
190 | ; accepted conn: 190460
191 | ; listen queue: 0
192 | ; max listen queue: 1
193 | ; listen queue len: 42
194 | ; idle processes: 4
195 | ; active processes: 11
196 | ; total processes: 15
197 | ; max active processes: 12
198 | ; max children reached: 0
199 | ;
200 | ; By default the status page output is formatted as text/plain. Passing either
201 | ; 'html', 'xml' or 'json' in the query string will return the corresponding
202 | ; output syntax. Example:
203 | ; http://www.foo.bar/status
204 | ; http://www.foo.bar/status?json
205 | ; http://www.foo.bar/status?html
206 | ; http://www.foo.bar/status?xml
207 | ;
208 | ; By default the status page only outputs short status. Passing 'full' in the
209 | ; query string will also return status for each pool process.
210 | ; Example:
211 | ; http://www.foo.bar/status?full
212 | ; http://www.foo.bar/status?json&full
213 | ; http://www.foo.bar/status?html&full
214 | ; http://www.foo.bar/status?xml&full
215 | ; The Full status returns for each process:
216 | ; pid - the PID of the process;
217 | ; state - the state of the process (Idle, Running, ...);
218 | ; start time - the date and time the process has started;
219 | ; start since - the number of seconds since the process has started;
220 | ; requests - the number of requests the process has served;
221 | ; request duration - the duration in µs of the requests;
222 | ; request method - the request method (GET, POST, ...);
223 | ; request URI - the request URI with the query string;
224 | ; content length - the content length of the request (only with POST);
225 | ; user - the user (PHP_AUTH_USER) (or '-' if not set);
226 | ; script - the main script called (or '-' if not set);
227 | ; last request cpu - the %cpu the last request consumed
228 | ; it's always 0 if the process is not in Idle state
229 | ; because CPU calculation is done when the request
230 | ; processing has terminated;
231 | ; last request memory - the max amount of memory the last request consumed
232 | ; it's always 0 if the process is not in Idle state
233 | ; because memory calculation is done when the request
234 | ; processing has terminated;
235 | ; If the process is in Idle state, then informations are related to the
236 | ; last request the process has served. Otherwise informations are related to
237 | ; the current request being served.
238 | ; Example output:
239 | ; ************************
240 | ; pid: 31330
241 | ; state: Running
242 | ; start time: 01/Jul/2011:17:53:49 +0200
243 | ; start since: 63087
244 | ; requests: 12808
245 | ; request duration: 1250261
246 | ; request method: GET
247 | ; request URI: /test_mem.php?N=10000
248 | ; content length: 0
249 | ; user: -
250 | ; script: /home/fat/web/docs/php/test_mem.php
251 | ; last request cpu: 0.00
252 | ; last request memory: 0
253 | ;
254 | ; Note: There is a real-time FPM status monitoring sample web page available
255 | ; It's available in: /usr/local/share/php/fpm/status.html
256 | ;
257 | ; Note: The value must start with a leading slash (/). The value can be
258 | ; anything, but it may not be a good idea to use the .php extension or it
259 | ; may conflict with a real PHP file.
260 | ; Default Value: not set
261 | pm.status_path = /fpm-status
262 |
263 | ; The address on which to accept FastCGI status request. This creates a new
264 | ; invisible pool that can handle requests independently. This is useful
265 | ; if the main pool is busy with long running requests because it is still possible
266 | ; to get the status before finishing the long running requests.
267 | ;
268 | ; Valid syntaxes are:
269 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
270 | ; a specific port;
271 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
272 | ; a specific port;
273 | ; 'port' - to listen on a TCP socket to all addresses
274 | ; (IPv6 and IPv4-mapped) on a specific port;
275 | ; '/path/to/unix/socket' - to listen on a unix socket.
276 | ; Default Value: value of the listen option
277 | pm.status_listen = 9001
278 |
279 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no
280 | ; URI will be recognized as a ping page. This could be used to test from outside
281 | ; that FPM is alive and responding, or to
282 | ; - create a graph of FPM availability (rrd or such);
283 | ; - remove a server from a group if it is not responding (load balancing);
284 | ; - trigger alerts for the operating team (24/7).
285 | ; Note: The value must start with a leading slash (/). The value can be
286 | ; anything, but it may not be a good idea to use the .php extension or it
287 | ; may conflict with a real PHP file.
288 | ; Default Value: not set
289 | ;ping.path = /ping
290 |
291 | ; This directive may be used to customize the response of a ping request. The
292 | ; response is formatted as text/plain with a 200 response code.
293 | ; Default Value: pong
294 | ;ping.response = pong
295 |
296 | ; The access log file
297 | ; Default: not set
298 | ;access.log = log/$pool.access.log
299 |
300 | ; The access log format.
301 | ; The following syntax is allowed
302 | ; %%: the '%' character
303 | ; %C: %CPU used by the request
304 | ; it can accept the following format:
305 | ; - %{user}C for user CPU only
306 | ; - %{system}C for system CPU only
307 | ; - %{total}C for user + system CPU (default)
308 | ; %d: time taken to serve the request
309 | ; it can accept the following format:
310 | ; - %{seconds}d (default)
311 | ; - %{milliseconds}d
312 | ; - %{milli}d
313 | ; - %{microseconds}d
314 | ; - %{micro}d
315 | ; %e: an environment variable (same as $_ENV or $_SERVER)
316 | ; it must be associated with embraces to specify the name of the env
317 | ; variable. Some examples:
318 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
319 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
320 | ; %f: script filename
321 | ; %l: content-length of the request (for POST request only)
322 | ; %m: request method
323 | ; %M: peak of memory allocated by PHP
324 | ; it can accept the following format:
325 | ; - %{bytes}M (default)
326 | ; - %{kilobytes}M
327 | ; - %{kilo}M
328 | ; - %{megabytes}M
329 | ; - %{mega}M
330 | ; %n: pool name
331 | ; %o: output header
332 | ; it must be associated with embraces to specify the name of the header:
333 | ; - %{Content-Type}o
334 | ; - %{X-Powered-By}o
335 | ; - %{Transfert-Encoding}o
336 | ; - ....
337 | ; %p: PID of the child that serviced the request
338 | ; %P: PID of the parent of the child that serviced the request
339 | ; %q: the query string
340 | ; %Q: the '?' character if query string exists
341 | ; %r: the request URI (without the query string, see %q and %Q)
342 | ; %R: remote IP address
343 | ; %s: status (response code)
344 | ; %t: server time the request was received
345 | ; it can accept a strftime(3) format:
346 | ; %d/%b/%Y:%H:%M:%S %z (default)
347 | ; The strftime(3) format must be encapsulated in a %{}t tag
348 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
349 | ; %T: time the log has been written (the request has finished)
350 | ; it can accept a strftime(3) format:
351 | ; %d/%b/%Y:%H:%M:%S %z (default)
352 | ; The strftime(3) format must be encapsulated in a %{}t tag
353 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
354 | ; %u: remote user
355 | ;
356 | ; Default: "%R - %u %t \"%m %r\" %s"
357 | ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{milli}d %{kilo}M %C%%"
358 |
359 | ; A list of request_uri values which should be filtered from the access log.
360 | ;
361 | ; As a security precuation, this setting will be ignored if:
362 | ; - the request method is not GET or HEAD; or
363 | ; - there is a request body; or
364 | ; - there are query parameters; or
365 | ; - the response code is outwith the successful range of 200 to 299
366 | ;
367 | ; Note: The paths are matched against the output of the access.format tag "%r".
368 | ; On common configurations, this may look more like SCRIPT_NAME than the
369 | ; expected pre-rewrite URI.
370 | ;
371 | ; Default Value: not set
372 | ;access.suppress_path[] = /ping
373 | ;access.suppress_path[] = /health_check.php
374 |
375 | ; The log file for slow requests
376 | ; Default Value: not set
377 | ; Note: slowlog is mandatory if request_slowlog_timeout is set
378 | ;slowlog = log/$pool.log.slow
379 |
380 | ; The timeout for serving a single request after which a PHP backtrace will be
381 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'.
382 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
383 | ; Default Value: 0
384 | ;request_slowlog_timeout = 0
385 |
386 | ; Depth of slow log stack trace.
387 | ; Default Value: 20
388 | ;request_slowlog_trace_depth = 20
389 |
390 | ; The timeout for serving a single request after which the worker process will
391 | ; be killed. This option should be used when the 'max_execution_time' ini option
392 | ; does not stop script execution for some reason. A value of '0' means 'off'.
393 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
394 | ; Default Value: 0
395 | ;request_terminate_timeout = 0
396 |
397 | ; The timeout set by 'request_terminate_timeout' ini option is not engaged after
398 | ; application calls 'fastcgi_finish_request' or when application has finished and
399 | ; shutdown functions are being called (registered via register_shutdown_function).
400 | ; This option will enable timeout limit to be applied unconditionally
401 | ; even in such cases.
402 | ; Default Value: no
403 | ;request_terminate_timeout_track_finished = no
404 |
405 | ; Set open file descriptor rlimit.
406 | ; Default Value: system defined value
407 | ;rlimit_files = 1024
408 |
409 | ; Set max core size rlimit.
410 | ; Possible Values: 'unlimited' or an integer greater or equal to 0
411 | ; Default Value: system defined value
412 | ;rlimit_core = 0
413 |
414 | ; Chroot to this directory at the start. This value must be defined as an
415 | ; absolute path. When this value is not set, chroot is not used.
416 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
417 | ; of its subdirectories. If the pool prefix is not set, the global prefix
418 | ; will be used instead.
419 | ; Note: chrooting is a great security feature and should be used whenever
420 | ; possible. However, all PHP paths will be relative to the chroot
421 | ; (error_log, sessions.save_path, ...).
422 | ; Default Value: not set
423 | ;chroot =
424 |
425 | ; Chdir to this directory at the start.
426 | ; Note: relative path can be used.
427 | ; Default Value: current directory or / when chroot
428 | ;chdir = /var/www
429 |
430 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and
431 | ; stderr will be redirected to /dev/null according to FastCGI specs.
432 | ; Note: on highloaded environment, this can cause some delay in the page
433 | ; process time (several ms).
434 | ; Default Value: no
435 | ;catch_workers_output = yes
436 |
437 | ; Decorate worker output with prefix and suffix containing information about
438 | ; the child that writes to the log and if stdout or stderr is used as well as
439 | ; log level and time. This options is used only if catch_workers_output is yes.
440 | ; Settings to "no" will output data as written to the stdout or stderr.
441 | ; Default value: yes
442 | ;decorate_workers_output = no
443 |
444 | ; Clear environment in FPM workers
445 | ; Prevents arbitrary environment variables from reaching FPM worker processes
446 | ; by clearing the environment in workers before env vars specified in this
447 | ; pool configuration are added.
448 | ; Setting to "no" will make all environment variables available to PHP code
449 | ; via getenv(), $_ENV and $_SERVER.
450 | ; Default Value: yes
451 | ;clear_env = no
452 |
453 | ; Limits the extensions of the main script FPM will allow to parse. This can
454 | ; prevent configuration mistakes on the web server side. You should only limit
455 | ; FPM to .php extensions to prevent malicious users to use other extensions to
456 | ; execute php code.
457 | ; Note: set an empty value to allow all extensions.
458 | ; Default Value: .php
459 | ;security.limit_extensions = .php .php3 .php4 .php5 .php7
460 |
461 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
462 | ; the current environment.
463 | ; Default Value: clean env
464 | ;env[HOSTNAME] = $HOSTNAME
465 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin
466 | ;env[TMP] = /tmp
467 | ;env[TMPDIR] = /tmp
468 | ;env[TEMP] = /tmp
469 |
470 | ; Additional php.ini defines, specific to this pool of workers. These settings
471 | ; overwrite the values previously defined in the php.ini. The directives are the
472 | ; same as the PHP SAPI:
473 | ; php_value/php_flag - you can set classic ini defines which can
474 | ; be overwritten from PHP call 'ini_set'.
475 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by
476 | ; PHP call 'ini_set'
477 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
478 |
479 | ; Defining 'extension' will load the corresponding shared extension from
480 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
481 | ; overwrite previously defined php.ini values, but will append the new value
482 | ; instead.
483 |
484 | ; Note: path INI options can be relative and will be expanded with the prefix
485 | ; (pool, global or /usr/local)
486 |
487 | ; Default Value: nothing is defined by default except the values in php.ini and
488 | ; specified at startup with the -d argument
489 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
490 | ;php_flag[display_errors] = off
491 | ;php_admin_value[error_log] = /var/log/fpm-php.www.log
492 | ;php_admin_flag[log_errors] = on
493 | ;php_admin_value[memory_limit] = 32M
494 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/testing-tools/bombardier:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimDev/php-runtimes-benchmark/901796f378afbdc113a8247fba0309c29ee77441/001_symfony7_wo_db/testing-tools/bombardier
--------------------------------------------------------------------------------
/001_symfony7_wo_db/testing-tools/k6/script_vus10000_dur30s.js:
--------------------------------------------------------------------------------
1 | import http from 'k6/http';
2 | import { sleep } from 'k6';
3 |
4 | export const options = {
5 | // A number specifying the number of VUs to run concurrently.
6 | vus: 10000,
7 | // A string specifying the total duration of the test run.
8 | duration: '30s',
9 | };
10 |
11 | // The function that defines VU logic.
12 | //
13 | // See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more
14 | // about authoring k6 scripts.
15 | //
16 | export default function() {
17 | http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname');
18 | }
19 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/testing-tools/k6/script_vus1000_dur30s.js:
--------------------------------------------------------------------------------
1 | import http from 'k6/http';
2 | import { sleep } from 'k6';
3 |
4 | export const options = {
5 | // A number specifying the number of VUs to run concurrently.
6 | vus: 1000,
7 | // A string specifying the total duration of the test run.
8 | duration: '30s',
9 | };
10 |
11 | // The function that defines VU logic.
12 | //
13 | // See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more
14 | // about authoring k6 scripts.
15 | //
16 | export default function() {
17 | http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname');
18 | }
19 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/testing-tools/k6/script_vus100_dur30s.js:
--------------------------------------------------------------------------------
1 | import http from 'k6/http';
2 | import { sleep } from 'k6';
3 |
4 | export const options = {
5 | // A number specifying the number of VUs to run concurrently.
6 | vus: 100,
7 | // A string specifying the total duration of the test run.
8 | duration: '30s',
9 | };
10 |
11 | // The function that defines VU logic.
12 | //
13 | // See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more
14 | // about authoring k6 scripts.
15 | //
16 | export default function() {
17 | http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname');
18 | }
19 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/testing-tools/k6/script_vus10_dur30s.js:
--------------------------------------------------------------------------------
1 | import http from 'k6/http';
2 | import { sleep } from 'k6';
3 |
4 | export const options = {
5 | // A number specifying the number of VUs to run concurrently.
6 | vus: 10,
7 | // A string specifying the total duration of the test run.
8 | duration: '30s',
9 | };
10 |
11 | // The function that defines VU logic.
12 | //
13 | // See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more
14 | // about authoring k6 scripts.
15 | //
16 | export default function() {
17 | http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname');
18 | }
19 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/testing-tools/k6/script_vus5_dur10s.js:
--------------------------------------------------------------------------------
1 | import http from 'k6/http';
2 | import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js';
3 |
4 | export const options = {
5 | // A number specifying the number of VUs to run concurrently.
6 | vus: 5,
7 | // A string specifying the total duration of the test run.
8 | duration: '5s',
9 | };
10 |
11 | // The function that defines VU logic.
12 | //
13 | // See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more
14 | // about authoring k6 scripts.
15 | //
16 | export default function() {
17 | http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname');
18 | }
19 | export function handleSummary(data) {
20 | /*return {
21 | 'summary.json': JSON.stringify(data), //the default data object
22 | };*/
23 | const customizedData = {
24 | http_reqs: data.metrics.http_reqs.values.count,
25 |
26 | rate: data.metrics.http_reqs.values.rate,
27 | avg_response_time: data.metrics['http_req_duration{expected_response:true}'].values.avg
28 | }
29 | return {
30 | 'stdout': textSummary(data, { indent: ' ', enableColors: true }), // Show the text summary to stdout...
31 | 'summary_full.json': JSON.stringify(data), // and a JSON with all the details...
32 | 'summary_short.json': JSON.stringify(customizedData), // and a JSON with all the details...
33 | };
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/001_symfony7_wo_db/testing-tools/k6/script_vus5_dur30s.js:
--------------------------------------------------------------------------------
1 | import http from 'k6/http';
2 | import { sleep } from 'k6';
3 |
4 | export const options = {
5 | // A number specifying the number of VUs to run concurrently.
6 | vus: 5,
7 | // A string specifying the total duration of the test run.
8 | duration: '30s',
9 | };
10 |
11 | // The function that defines VU logic.
12 | //
13 | // See https://grafana.com/docs/k6/latest/examples/get-started-with-k6/ to learn more
14 | // about authoring k6 scripts.
15 | //
16 | export default function() {
17 | http.get('http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname');
18 | }
19 |
--------------------------------------------------------------------------------
/002_symfony6_wo_db/runtimes/010_reactphp/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | 009_openswoole:
3 | build:
4 | context: ../../
5 | dockerfile: "./runtimes/009_openswoole/openswoole/openswoole.Dockerfile"
6 | image: "009_openswoole"
7 | container_name: "009_openswoole"
8 | hostname: symfony7site
9 | ports:
10 | - '80:80'
11 | networks:
12 | - php-benchmarks
13 | deploy:
14 | resources:
15 | limits:
16 | cpus: '1'
17 | memory: '1gb'
18 | reservations:
19 | cpus: '1'
20 | memory: '1gb'
21 |
22 | networks:
23 | php-benchmarks:
24 | name: php-benchmarks
--------------------------------------------------------------------------------
/002_symfony6_wo_db/runtimes/010_reactphp/reactphp/php.ini:
--------------------------------------------------------------------------------
1 | date.timezone = "Europe/Warsaw"
2 | short_open_tag = Off
3 | expose_php = Off
4 | allow_url_fopen = Off
5 | memory_limit = 128M
6 |
7 | realpath_cache_size=4096K
8 | realpath_cache_ttl=600
9 |
10 | [opcache]
11 | opcache.enable=1
12 | opcache.enable_cli=1
13 | opcache.preload_user=root
14 | opcache.jit_buffer_size=256M
15 | opcache.jit=tracing
16 | opcache.preload=/var/www/symfony/config/preload.php
17 | opcache.validate_timestamps=0
18 | opcache.memory_consumption=256
19 | opcache.max_accelerated_files=20000
20 |
--------------------------------------------------------------------------------
/002_symfony6_wo_db/runtimes/010_reactphp/reactphp/reactphp.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM openswoole/swoole:php8.3
2 |
3 | RUN set -xe; \
4 | apt update; \
5 | apt install unzip
6 |
7 | ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
8 |
9 | RUN chmod +x /usr/local/bin/install-php-extensions && \
10 | install-php-extensions \
11 | exif \
12 | intl \
13 | opcache \
14 | pdo_pgsql \
15 | tidy \
16 | gd \
17 | bcmath \
18 | sockets \
19 | zip && \
20 | install-php-extensions @composer;
21 |
22 | RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
23 | COPY ./runtimes/009_openswoole/openswoole/php.ini /usr/local/etc/php/conf.d/custom-php.ini
24 |
25 | COPY "./project" "/var/www/symfony"
26 |
27 | WORKDIR /var/www/symfony
28 |
29 | RUN cp .env.example .env.local
30 |
31 | RUN rm -rf vendor && \
32 | composer install --no-dev --no-scripts --prefer-dist --no-interaction && \
33 | composer dump-autoload --no-dev --classmap-authoritative && \
34 | composer check-platform-reqs && \
35 | php bin/console cache:clear && \
36 | php bin/console cache:warmup
37 |
38 | ENV APP_RUNTIME="Runtime\\Swoole\\Runtime"
39 |
40 | EXPOSE 80
41 |
42 | CMD ["php", "./public/index.openswoole.php"]
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PHP runtimes benchmark
2 |
3 | The repo contains the Symfony 7 application skeleton to be run in different runtimes:
4 |
5 | - Apache(prefork mode) + mod_php
6 | - Apache + PHP-FPM
7 | - Nginx + PHP-FPM
8 | - Nginx Unit
9 | - Roadrunner
10 | - Nginx + Roadrunner
11 | - FrankenPHP
12 | - FrankenPHP (worker mode)
13 | - Swoole
14 |
15 | ## URLs
16 |
17 | - http://localhost/
18 | - http://localhost/?firstName=Randomlfirstname&lastName=Randomlastname
19 | - http://localhost/phpinfo
20 | - http://symfony7site/
21 | - http://symfony7site/?firstName=Randomlfirstname&lastName=Randomlastname
22 | - http://symfony7site/phpinfo
23 |
24 | ## Run load tests
25 |
26 | Load tests are run inside docker container, which is in the same network as the runtime.
27 |
28 | ### Bombardier
29 |
30 | - https://pkg.go.dev/github.com/codesenberg/bombardier
31 | - https://hub.docker.com/r/alpine/bombardier
32 |
33 | ```shell
34 | make run/loadtest/bombardier-c5-d30s # Run bombardier concurrent connections: 5, duration: 30s
35 | make run/loadtest/bombardier-c10-d30s # Run bombardier concurrent connections: 10, duration: 30s
36 | make run/loadtest/bombardier-c100-d30s # Run bombardier concurrent connections: 100, duration: 30s
37 | make run/loadtest/bombardier-c1000-d30s # Run bombardier concurrent connections: 1000, duration: 30s
38 | make run/loadtest/bombardier-c10000-d30s # Run bombardier concurrent connections: 10000, duration: 30s
39 | ```
40 |
41 | ### Apache HTTP server benchmarking tool
42 |
43 | - https://httpd.apache.org/docs/2.4/programs/ab.html
44 |
45 | ```shell
46 | make run/loadtest/ab-n100-c5
47 | make run/loadtest/ab-n1000-c100
48 | make run/loadtest/ab-n10000-c1000
49 | ```
50 |
51 | ### K6 (by Grafana Labs)
52 |
53 | - https://k6.io/docs/
54 | - https://k6.io/docs/using-k6/metrics/reference/
55 |
56 | See js scripts in 001_symfony7_wo_db/testing-tools/k6
57 |
58 | ```shell
59 | make run/loadtest/k6-vus5-dur30s
60 | make run/loadtest/k6-vus10-dur30s
61 | make run/loadtest/k6-vus100-dur30s
62 | make run/loadtest/k6-vus1000-dur30s
63 | make run/loadtest/k6-vus10000-dur30s
64 | ```
65 |
66 | ## 001: Apache(prefork mode) + mod_php
67 |
68 | - http://localhost/server-status
69 |
70 |
71 | ```shell
72 | make start/runtime/001-apache-modphp
73 | make stop/runtime/001-apache-modphp
74 | make rebuild/runtime/001-apache-modphp
75 | make down/runtime/001-apache-modphp
76 | make shell/runtime/001-apache-modphp
77 | ```
78 |
79 | ## 002: Apache + PHP-FPM
80 |
81 | - http://localhost/apache-status
82 | - http://localhost/fpm-status?html&full
83 |
84 |
85 | ```shell
86 | make start/runtime/002-apache-phpfpm
87 | make stop/runtime/002-apache-phpfpm
88 | make rebuild/runtime/002-apache-phpfpm
89 | make down/runtime/002-apache-phpfpm
90 | make shell/runtime/002-apache
91 | make shell/runtime/002-phpfpm
92 | ```
93 |
94 | ## 003: Nginx + PHP-FPM
95 |
96 | - http://localhost/fpm-status?html&full
97 |
98 | To calculate PHP-FPM pm.max_children, the following formula was used:
99 | ```
100 | pm.max_children = Memory available to container / Memory consumed by 1 process
101 | ```
102 |
103 | Memory consumed by 1 process:
104 | ```shell
105 | ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"Mb") }'
106 | ```
107 |
108 | ```shell
109 | make start/runtime/003-nginx-phpfpm
110 | make stop/runtime/003-nginx-phpfpm
111 | make rebuild/runtime/003-nginx-phpfpm
112 | make down/runtime/003-nginx-phpfpm
113 | make shell/runtime/003-nginx
114 | make shell/runtime/003-phpfpm
115 | ```
116 |
117 | ## 004: Nginx Unit + PHP Language module
118 |
119 | - https://unit.nginx.org/configuration/#php
120 |
121 | ```shell
122 | make start/runtime/004-nginx-unit
123 | make stop/runtime/004-nginx-unit
124 | make rebuild/runtime/004-nginx-unit
125 | make down/runtime/004-nginx-unit
126 | make shell/runtime/004-unit
127 | ```
128 |
129 | ## 005: Roadrunner
130 |
131 | The symfony/runtime component is used
132 |
133 | - https://roadrunner.dev/
134 | - https://github.com/baldinof/roadrunner-bundle
135 |
136 | ```shell
137 | make start/runtime/005-roadrunner
138 | make stop/runtime/005-roadrunner
139 | make rebuild/runtime/005-roadrunner
140 | make down/runtime/005-roadrunner
141 | make shell/runtime/005-roadrunner
142 | ```
143 |
144 | ## 006: Nginx + Roadrunner(fcgi mode)
145 |
146 | The symfony/runtime component is used
147 |
148 | - https://roadrunner.dev/docs/app-server-nginx-with-rr/current/en
149 | - https://github.com/baldinof/roadrunner-bundle
150 |
151 | ```shell
152 | make start/runtime/006-nginx-roadrunner
153 | make stop/runtime/006-nginx-roadrunner
154 | make rebuild/runtime/006-nginx-roadrunner
155 | make down/runtime/006-nginx-roadrunner
156 | make shell/runtime/006-nginx
157 | make shell/runtime/006-roadrunner
158 | ```
159 |
160 | ## 007: Frankenphp
161 |
162 | The symfony/runtime component is used
163 |
164 | - https://frankenphp.dev/docs/
165 |
166 | ```shell
167 | make start/runtime/007-frankenphp
168 | make stop/runtime/007-frankenphp
169 | make rebuild/runtime/007-frankenphp
170 | make down/runtime/007-frankenphp
171 | make shell/runtime/007-frankenphp
172 | ```
173 |
174 | ## 008: Frankenphp (workermode)
175 |
176 | The symfony/runtime component is used
177 |
178 | - https://frankenphp.dev/docs/worker/
179 |
180 | ```shell
181 | make start/runtime/008-frankenphp-workermode
182 | make stop/runtime/008-frankenphp-workermode
183 | make rebuild/runtime/008-frankenphp-workermode
184 | make down/runtime/008-frankenphp-workermode
185 | make shell/runtime/008-frankenphp-workermode
186 | ```
187 |
188 | ### Issues
189 | - FrankenPHP can't start with production version of php.ini, which is provided with official PHP image
190 |
191 |
192 | ## 009: Swoole
193 |
194 | The symfony/runtime component is used
195 |
196 | - https://github.com/php-runtime/swoole
197 | - https://swoole.com/docs
198 |
199 | ```shell
200 | make start/runtime/009-swoole
201 | make stop/runtime/009-swoole
202 | make rebuild/runtime/009-swoole
203 | make down/runtime/009-swoole
204 | make shell/runtime/009-swoole
205 | ```
206 |
--------------------------------------------------------------------------------