Skip to content

Commit 711d032

Browse files
docs: performance updates (#2173)
Some updates to the performance docs. Mainly creating this PR to test the automatic translations.
1 parent 6eef0d3 commit 711d032

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

docs/performance.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ However, it is possible to substantially improve performance using an appropriat
55

66
## Number of Threads and Workers
77

8-
By default, FrankenPHP starts 2 times more threads and workers (in worker mode) than the available numbers of CPU.
8+
By default, FrankenPHP starts 2 times more threads and workers (in worker mode) than the available number of CPU cores.
99

1010
The appropriate values depend heavily on how your application is written, what it does, and your hardware.
1111
We strongly recommend changing these values. For best system stability, it is recommended to have `num_threads` x `memory_limit` < `available_memory`.
@@ -45,6 +45,8 @@ In production environments, we recommend using FrankenPHP linked against glibc,
4545

4646
This can be achieved by using the Debian Docker images, using [our maintainers .deb, .rpm, or .apk packages](https://pkgs.henderkes.com), or by [compiling FrankenPHP from sources](compile.md).
4747

48+
For leaner or more secure containers, you may want to consider [a hardened Debian image](docker.md#hardening-images) rather than Alpine.
49+
4850
## Go Runtime Configuration
4951

5052
FrankenPHP is written in Go.
@@ -87,6 +89,18 @@ php_server {
8789
```
8890

8991
This can significantly reduce the number of unnecessary file operations.
92+
A worker equivalent of the previous configuration would be:
93+
94+
```caddyfile
95+
route {
96+
php_server { # use "php" instead of "php_server" if you don't need the file server at all
97+
root /root/to/your/app
98+
worker /path/to/worker.php {
99+
match * # send all requests directly to the worker
100+
}
101+
}
102+
}
103+
```
90104

91105
An alternate approach with 0 unnecessary file system operations would be to instead use the `php` directive and split
92106
files from PHP by path. This approach works well if your entire application is served by one entry file.
@@ -164,22 +178,18 @@ limits the concurrency of requests going towards the slow endpoint, similar to a
164178
connection pool.
165179

166180
```caddyfile
167-
{
168-
frankenphp {
169-
max_threads 100 # max 100 threads shared by all workers
170-
}
171-
}
172-
173181
example.com {
174182
php_server {
175183
root /app/public # the root of your application
176184
worker index.php {
177185
match /slow-endpoint/* # all requests with path /slow-endpoint/* are handled by this thread pool
178-
num 10 # minimum 10 threads for requests matching /slow-endpoint/*
186+
num 1 # minimum 1 threads for requests matching /slow-endpoint/*
187+
max_threads 20 # allow up to 20 threads for requests matching /slow-endpoint/*, if needed
179188
}
180189
worker index.php {
181190
match * # all other requests are handled separately
182-
num 20 # minimum 20 threads for other requests, even if the slow endppoints start hanging
191+
num 1 # minimum 1 threads for other requests, even if the slow endpoints start hanging
192+
max_threads 20 # allow up to 20 threads for other requests, if needed
183193
}
184194
}
185195
}

0 commit comments

Comments
 (0)