Skip to content

Commit c5752f9

Browse files
docs: max_wait_time (#1465)
1 parent ba36f92 commit c5752f9

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

docs/classic.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
Without any additional configuration, FrankenPHP operates in classic mode. In this mode, FrankenPHP functions like a traditional PHP server, directly serving PHP files. This makes it a seamless drop-in replacement for PHP-FPM or Apache with mod_php.
44

5-
Similar to Caddy, FrankenPHP accepts an unlimited number of connections and uses a [fixed number of threads](config.md#caddyfile-config) to serve them. The number of accepted and queued connections is limited only by the available system resources. The PHP thread pool operates with a fixed number of threads initialized at startup, comparable to the static mode of PHP-FPM.
5+
Similar to Caddy, FrankenPHP accepts an unlimited number of connections and uses a [fixed number of threads](config.md#caddyfile-config) to serve them. The number of accepted and queued connections is limited only by the available system resources.
6+
The PHP thread pool operates with a fixed number of threads initialized at startup, comparable to the static mode of PHP-FPM. It's also possible to let threads [scale automatically at runtime](performance.md#max_threads), similar to the dynamic mode of PHP-FPM.
67

7-
Queued connections will wait indefinitely until a PHP thread is available to serve them. To prevent that, set a reasonable [write timeout in Caddy](https://caddyserver.com/docs/caddyfile/options#timeouts).
8+
Queued connections will wait indefinitely until a PHP thread is available to serve them. To prevent that, you can use the `max_wait_time` [configuration](config.md#caddyfile-config) to limit how long a request may wait for a free PHP thread before being rejected.
9+
Additionally, you can set a reasonable [write timeout in Caddy](https://caddyserver.com/docs/caddyfile/options#timeouts).
810

911
Each Caddy instance will only spin up one FrankenPHP thread pool, which will be shared across all `php_server` blocks.

docs/config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Optionally, the number of threads to create and [worker scripts](worker.md) to s
5252
frankenphp {
5353
num_threads <num_threads> # Sets the number of PHP threads to start. Default: 2x the number of available CPUs.
5454
max_threads <num_threads> # Limits the number of additional PHP threads that can be started at runtime. Default: num_threads. Can be set to 'auto'.
55+
max_wait_time <duration> # Sets the maximum time a request may wait for a free PHP thread before timing out. Default: disabled.
5556
php_ini <key> <value> # Set a php.ini directive. Can be used several times to set multiple directives.
5657
worker {
5758
file <path> # Sets the path to the worker script.

docs/performance.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ To change the number of workers, use the `num` option of the `worker` section of
1919
### `max_threads`
2020

2121
While it's always better to know exactly what your traffic will look like, real-life applications tend to be more
22-
unpredictable. The `max_threads` allows FrankenPHP to automatically spawn additional threads at runtime up to the specified limit.
23-
`max_threads` can help you
24-
figure out how many threads you need to handle your traffic and can make the server more resilient to latency spikes.
22+
unpredictable. The `max_threads` [configuration](config.md#caddyfile-config) allows FrankenPHP to automatically spawn additional threads at runtime up to the specified limit.
23+
`max_threads` can help you figure out how many threads you need to handle your traffic and can make the server more resilient to latency spikes.
2524
If set to `auto`, the limit will be estimated based on the `memory_limit` in your `php.ini`. If not able to do so,
26-
`auto` will instead default to 2x `num_threads`.
27-
`max_threads is similar to PHP FPM's [pm.max_children](https://www.php.net/manual/en/install.fpm.configuration.php#pm.max-children).
25+
`auto` will instead default to 2x `num_threads`. Keep in mind that `auto` might strongly underestimate the number of threads needed.
26+
`max_threads` is similar to PHP FPM's [pm.max_children](https://www.php.net/manual/en/install.fpm.configuration.php#pm.max-children). The main difference is that FrankenPHP uses threads instead of
27+
processes and automatically delegates them across different worker scripts and 'classic mode' as needed.
2828

2929
## Worker Mode
3030

0 commit comments

Comments
 (0)