From 8ba3934f1597a3145fc3c8b9a8cc0b2cbff4eb81 Mon Sep 17 00:00:00 2001 From: Hanno Fellmann Date: Fri, 20 Dec 2024 16:17:57 +0100 Subject: [PATCH 1/2] docs: explicitly explain how to use without worker mode --- README.md | 3 ++- docs/classic.md | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 docs/classic.md diff --git a/README.md b/README.md index bb8b18d6b..f4998eb1c 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,8 @@ frankenphp php-cli /path/to/your/script.php ## Docs -* [The worker mode](https://frankenphp.dev/docs/worker/) +* [Classic mode](https://frankenphp.dev/docs/classic/) +* [Worker mode](https://frankenphp.dev/docs/worker/) * [Early Hints support (103 HTTP status code)](https://frankenphp.dev/docs/early-hints/) * [Real-time](https://frankenphp.dev/docs/mercure/) * [Configuration](https://frankenphp.dev/docs/config/) diff --git a/docs/classic.md b/docs/classic.md new file mode 100644 index 000000000..05e9ab973 --- /dev/null +++ b/docs/classic.md @@ -0,0 +1,7 @@ +# Using Classic Mode + +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. + +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. + +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). From 6e6b49e1059acb5a364acb7b871a9fb830cbc346 Mon Sep 17 00:00:00 2001 From: Hanno Fellmann Date: Sat, 21 Dec 2024 07:51:18 +0100 Subject: [PATCH 2/2] docs: additional threads info --- docs/classic.md | 2 ++ docs/performance.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/classic.md b/docs/classic.md index 05e9ab973..5d89cfba4 100644 --- a/docs/classic.md +++ b/docs/classic.md @@ -5,3 +5,5 @@ Without any additional configuration, FrankenPHP operates in classic mode. In th 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. 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). + +Each Caddy instance will only spin up one FrankenPHP thread pool, which will be shared across all `php_server` blocks. diff --git a/docs/performance.md b/docs/performance.md index bc3daf9fb..f1da61a6f 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -8,7 +8,7 @@ However, it is possible to substantially improve performance using an appropriat By default, FrankenPHP starts 2 times more threads and workers (in worker mode) than the available numbers of CPU. The appropriate values depend heavily on how your application is written, what it does and your hardware. -We strongly recommend changing these values. +We strongly recommend changing these values. For best system stability, it is recommended to have `num_threads` x `memory_limit` < `available_memory`. To find the right values, it's best to run load tests simulating real traffic. [k6](https://k6.io) and [Gatling](https://gatling.io) are good tools for this.