You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/performance.md
+19-9Lines changed: 19 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ However, it is possible to substantially improve performance using an appropriat
5
5
6
6
## Number of Threads and Workers
7
7
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.
9
9
10
10
The appropriate values depend heavily on how your application is written, what it does, and your hardware.
11
11
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,
45
45
46
46
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).
47
47
48
+
For leaner or more secure containers, you may want to consider [a hardened Debian image](docker.md#hardening-images) rather than Alpine.
49
+
48
50
## Go Runtime Configuration
49
51
50
52
FrankenPHP is written in Go.
@@ -87,6 +89,18 @@ php_server {
87
89
```
88
90
89
91
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
+
```
90
104
91
105
An alternate approach with 0 unnecessary file system operations would be to instead use the `php` directive and split
92
106
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
164
178
connection pool.
165
179
166
180
```caddyfile
167
-
{
168
-
frankenphp {
169
-
max_threads 100 # max 100 threads shared by all workers
170
-
}
171
-
}
172
-
173
181
example.com {
174
182
php_server {
175
183
root /app/public # the root of your application
176
184
worker index.php {
177
185
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
179
188
}
180
189
worker index.php {
181
190
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
0 commit comments