Skip to content

Commit 53986e8

Browse files
authored
Merge pull request #326 from jchristi/httpd-max-requests-per-child
Allow configuration of Apache HTTP MaxRequestsPerChild and MaxKeepAliveRequests
2 parents bd85367 + 232539c commit 53986e8

File tree

9 files changed

+66
-27
lines changed

9 files changed

+66
-27
lines changed

7.2/README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Description
1515

1616
PHP 7.2 available as container is a base platform for
1717
building and running various PHP 7.2 applications and frameworks.
18-
PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers
19-
to write dynamically generated web pages. PHP also offers built-in database integration
20-
for several commercial and non-commercial database management systems, so writing
21-
a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding
18+
PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers
19+
to write dynamically generated web pages. PHP also offers built-in database integration
20+
for several commercial and non-commercial database management systems, so writing
21+
a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding
2222
is probably as a replacement for CGI scripts.
2323

2424
This container image includes an npm utility, so users can use it to install JavaScript
@@ -191,7 +191,7 @@ The following environment variables set their equivalent property value in the p
191191
* Default: /tmp/sessions
192192
* **SESSION_COOKIE_DOMAIN**
193193
* The domain for which the cookie is valid.
194-
* Default:
194+
* Default:
195195
* **SESSION_COOKIE_HTTPONLY**
196196
* Whether or not to add the httpOnly flag to the cookie
197197
* Default: 0
@@ -214,7 +214,7 @@ The following environment variables set their equivalent property value in the o
214214
* Default: 2
215215
* **OPCACHE_MAX_FILES**
216216
* The maximum number of keys (scripts) in the OPcache hash table. Only numbers between 200 and 1000000 are allowed.
217-
* Default: 4000
217+
* Default: 4000
218218

219219
You can also override the entire directory used to load the PHP configuration by setting:
220220
* **PHPRC**
@@ -238,6 +238,17 @@ yourself:
238238
* `MaxRequestWorkers` was called `MaxClients` before version httpd 2.3.13.
239239
* Default: 256 (this is automatically tuned by setting Cgroup limits for the container using this formula:
240240
`TOTAL_MEMORY / 15MB`. The 15MB is average size of a single httpd process.
241+
* **HTTPD_MAX_REQUESTS_PER_CHILD**
242+
* The [MaxRequestsPerChild](http://httpd.apache.org/docs/current/mod/mpm_common.html#maxconnectionsperchild)
243+
directive sets the limit on the number of connections that an individual child server process will handle.
244+
After `MaxRequestsPerChild` connections, the child process will die. If `MaxRequestsPerChild` is 0, then the process will never expire.
245+
* Setting `MaxRequestsPerChild` to a non-zero value limits the amount of memory that a process can consume by (accidental) memory leakage.
246+
* `MaxRequestsPerChild` is called `MaxConnectionsPerChild` in Apache HTTP 2.3.9 and later.
247+
* Default: 4000
248+
* **HTTPD_MAX_KEEPALIVE_REQUESTS**
249+
* The [MaxKeepAliveRequests](http://httpd.apache.org/docs/current/mod/core.html#maxkeepaliverequests)
250+
directive limits the number of requests allowed per connection when `KeepAlive` is on. If it is set to 0, unlimited requests will be allowed.
251+
* Default: 100
241252

242253
You can use a custom composer repository mirror URL to download packages instead of the default 'packagist.org':
243254

7.2/root/usr/share/container-scripts/php/httpd-cnf/50-mpm-tuning.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
StartServers ${HTTPD_START_SERVERS}
44
MinSpareServers ${HTTPD_START_SERVERS}
55
MaxSpareServers ${HTTPD_MAX_SPARE_SERVERS}
6-
# The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served.
6+
# The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served.
77
# The default value, when no Cgroup limits are set is 256.
88
MaxRequestWorkers ${HTTPD_MAX_REQUEST_WORKERS}
99
ServerLimit ${HTTPD_MAX_REQUEST_WORKERS}
10-
MaxRequestsPerChild 4000
11-
MaxKeepAliveRequests 100
10+
MaxRequestsPerChild ${HTTPD_MAX_REQUESTS_PER_CHILD}
11+
MaxKeepAliveRequests ${HTTPD_MAX_KEEPALIVE_REQUESTS}
1212
</IfModule>

7.2/s2i/bin/run

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ envsubst < /opt/app-root/etc/php.d/10-opcache.ini.template > ${PHP_SYSCONF_PATH}
3636

3737
export HTTPD_START_SERVERS=${HTTPD_START_SERVERS:-8}
3838
export HTTPD_MAX_SPARE_SERVERS=$((HTTPD_START_SERVERS+10))
39+
export HTTPD_MAX_REQUESTS_PER_CHILD=${HTTPD_MAX_REQUESTS_PER_CHILD:-4000}
40+
export HTTPD_MAX_KEEPALIVE_REQUESTS=${HTTPD_MAX_KEEPALIVE_REQUESTS:-100}
3941

4042
if [ -n "${NO_MEMORY_LIMIT:-}" -o -z "${MEMORY_LIMIT_IN_BYTES:-}" ]; then
4143
#

7.3/README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Description
1515

1616
PHP 7.3 available as container is a base platform for
1717
building and running various PHP 7.3 applications and frameworks.
18-
PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers
19-
to write dynamically generated web pages. PHP also offers built-in database integration
20-
for several commercial and non-commercial database management systems, so writing
21-
a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding
18+
PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers
19+
to write dynamically generated web pages. PHP also offers built-in database integration
20+
for several commercial and non-commercial database management systems, so writing
21+
a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding
2222
is probably as a replacement for CGI scripts.
2323

2424
This container image includes an npm utility, so users can use it to install JavaScript
@@ -191,7 +191,7 @@ The following environment variables set their equivalent property value in the p
191191
* Default: /tmp/sessions
192192
* **SESSION_COOKIE_DOMAIN**
193193
* The domain for which the cookie is valid.
194-
* Default:
194+
* Default:
195195
* **SESSION_COOKIE_HTTPONLY**
196196
* Whether or not to add the httpOnly flag to the cookie
197197
* Default: 0
@@ -214,7 +214,7 @@ The following environment variables set their equivalent property value in the o
214214
* Default: 2
215215
* **OPCACHE_MAX_FILES**
216216
* The maximum number of keys (scripts) in the OPcache hash table. Only numbers between 200 and 1000000 are allowed.
217-
* Default: 4000
217+
* Default: 4000
218218

219219
You can also override the entire directory used to load the PHP configuration by setting:
220220
* **PHPRC**
@@ -238,6 +238,17 @@ yourself:
238238
* `MaxRequestWorkers` was called `MaxClients` before version httpd 2.3.13.
239239
* Default: 256 (this is automatically tuned by setting Cgroup limits for the container using this formula:
240240
`TOTAL_MEMORY / 15MB`. The 15MB is average size of a single httpd process.
241+
* **HTTPD_MAX_REQUESTS_PER_CHILD**
242+
* The [MaxRequestsPerChild](http://httpd.apache.org/docs/current/mod/mpm_common.html#maxconnectionsperchild)
243+
directive sets the limit on the number of connections that an individual child server process will handle.
244+
After `MaxRequestsPerChild` connections, the child process will die. If `MaxRequestsPerChild` is 0, then the process will never expire.
245+
* Setting `MaxRequestsPerChild` to a non-zero value limits the amount of memory that a process can consume by (accidental) memory leakage.
246+
* `MaxRequestsPerChild` is called `MaxConnectionsPerChild` in Apache HTTP 2.3.9 and later.
247+
* Default: 4000
248+
* **HTTPD_MAX_KEEPALIVE_REQUESTS**
249+
* The [MaxKeepAliveRequests](http://httpd.apache.org/docs/current/mod/core.html#maxkeepaliverequests)
250+
directive limits the number of requests allowed per connection when `KeepAlive` is on. If it is set to 0, unlimited requests will be allowed.
251+
* Default: 100
241252

242253
You can use a custom composer repository mirror URL to download packages instead of the default 'packagist.org':
243254

7.3/root/usr/share/container-scripts/php/httpd-cnf/50-mpm-tuning.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
StartServers ${HTTPD_START_SERVERS}
44
MinSpareServers ${HTTPD_START_SERVERS}
55
MaxSpareServers ${HTTPD_MAX_SPARE_SERVERS}
6-
# The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served.
6+
# The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served.
77
# The default value, when no Cgroup limits are set is 256.
88
MaxRequestWorkers ${HTTPD_MAX_REQUEST_WORKERS}
99
ServerLimit ${HTTPD_MAX_REQUEST_WORKERS}
10-
MaxRequestsPerChild 4000
11-
MaxKeepAliveRequests 100
10+
MaxRequestsPerChild ${HTTPD_MAX_REQUESTS_PER_CHILD}
11+
MaxKeepAliveRequests ${HTTPD_MAX_KEEPALIVE_REQUESTS}
1212
</IfModule>

7.3/s2i/bin/run

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ envsubst < /opt/app-root/etc/php.d/10-opcache.ini.template > ${PHP_SYSCONF_PATH}
3636

3737
export HTTPD_START_SERVERS=${HTTPD_START_SERVERS:-8}
3838
export HTTPD_MAX_SPARE_SERVERS=$((HTTPD_START_SERVERS+10))
39+
export HTTPD_MAX_REQUESTS_PER_CHILD=${HTTPD_MAX_REQUESTS_PER_CHILD:-4000}
40+
export HTTPD_MAX_KEEPALIVE_REQUESTS=${HTTPD_MAX_KEEPALIVE_REQUESTS:-100}
3941

4042
if [ -n "${NO_MEMORY_LIMIT:-}" -o -z "${MEMORY_LIMIT_IN_BYTES:-}" ]; then
4143
#

7.4/README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Description
1515

1616
PHP 7.4 available as container is a base platform for
1717
building and running various PHP 7.4 applications and frameworks.
18-
PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers
19-
to write dynamically generated web pages. PHP also offers built-in database integration
20-
for several commercial and non-commercial database management systems, so writing
21-
a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding
18+
PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers
19+
to write dynamically generated web pages. PHP also offers built-in database integration
20+
for several commercial and non-commercial database management systems, so writing
21+
a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding
2222
is probably as a replacement for CGI scripts.
2323

2424
This container image includes an npm utility, so users can use it to install JavaScript
@@ -191,7 +191,7 @@ The following environment variables set their equivalent property value in the p
191191
* Default: /tmp/sessions
192192
* **SESSION_COOKIE_DOMAIN**
193193
* The domain for which the cookie is valid.
194-
* Default:
194+
* Default:
195195
* **SESSION_COOKIE_HTTPONLY**
196196
* Whether or not to add the httpOnly flag to the cookie
197197
* Default: 0
@@ -214,7 +214,7 @@ The following environment variables set their equivalent property value in the o
214214
* Default: 2
215215
* **OPCACHE_MAX_FILES**
216216
* The maximum number of keys (scripts) in the OPcache hash table. Only numbers between 200 and 1000000 are allowed.
217-
* Default: 4000
217+
* Default: 4000
218218

219219
You can also override the entire directory used to load the PHP configuration by setting:
220220
* **PHPRC**
@@ -238,6 +238,17 @@ yourself:
238238
* `MaxRequestWorkers` was called `MaxClients` before version httpd 2.3.13.
239239
* Default: 256 (this is automatically tuned by setting Cgroup limits for the container using this formula:
240240
`TOTAL_MEMORY / 15MB`. The 15MB is average size of a single httpd process.
241+
* **HTTPD_MAX_REQUESTS_PER_CHILD**
242+
* The [MaxRequestsPerChild](http://httpd.apache.org/docs/current/mod/mpm_common.html#maxconnectionsperchild)
243+
directive sets the limit on the number of connections that an individual child server process will handle.
244+
After `MaxRequestsPerChild` connections, the child process will die. If `MaxRequestsPerChild` is 0, then the process will never expire.
245+
* Setting `MaxRequestsPerChild` to a non-zero value limits the amount of memory that a process can consume by (accidental) memory leakage.
246+
* `MaxRequestsPerChild` is called `MaxConnectionsPerChild` in Apache HTTP 2.3.9 and later.
247+
* Default: 4000
248+
* **HTTPD_MAX_KEEPALIVE_REQUESTS**
249+
* The [MaxKeepAliveRequests](http://httpd.apache.org/docs/current/mod/core.html#maxkeepaliverequests)
250+
directive limits the number of requests allowed per connection when `KeepAlive` is on. If it is set to 0, unlimited requests will be allowed.
251+
* Default: 100
241252

242253
You can use a custom composer repository mirror URL to download packages instead of the default 'packagist.org':
243254

7.4/root/usr/share/container-scripts/php/httpd-cnf/50-mpm-tuning.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
StartServers ${HTTPD_START_SERVERS}
44
MinSpareServers ${HTTPD_START_SERVERS}
55
MaxSpareServers ${HTTPD_MAX_SPARE_SERVERS}
6-
# The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served.
6+
# The MaxRequestWorkers directive sets the limit on the number of simultaneous requests that will be served.
77
# The default value, when no Cgroup limits are set is 256.
88
MaxRequestWorkers ${HTTPD_MAX_REQUEST_WORKERS}
99
ServerLimit ${HTTPD_MAX_REQUEST_WORKERS}
10-
MaxRequestsPerChild 4000
11-
MaxKeepAliveRequests 100
10+
MaxRequestsPerChild ${HTTPD_MAX_REQUESTS_PER_CHILD}
11+
MaxKeepAliveRequests ${HTTPD_MAX_KEEPALIVE_REQUESTS}
1212
</IfModule>

7.4/s2i/bin/run

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ envsubst < /opt/app-root/etc/php.d/10-opcache.ini.template > ${PHP_SYSCONF_PATH}
3636

3737
export HTTPD_START_SERVERS=${HTTPD_START_SERVERS:-8}
3838
export HTTPD_MAX_SPARE_SERVERS=$((HTTPD_START_SERVERS+10))
39+
export HTTPD_MAX_REQUESTS_PER_CHILD=${HTTPD_MAX_REQUESTS_PER_CHILD:-4000}
40+
export HTTPD_MAX_KEEPALIVE_REQUESTS=${HTTPD_MAX_KEEPALIVE_REQUESTS:-100}
3941

4042
if [ -n "${NO_MEMORY_LIMIT:-}" -o -z "${MEMORY_LIMIT_IN_BYTES:-}" ]; then
4143
#

0 commit comments

Comments
 (0)