File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed
Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -264,7 +264,10 @@ func (f *FrankenPHPModule) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
264264 if _ , ok := fileNames [w .FileName ]; ok {
265265 return fmt .Errorf (`workers in a single "php_server" block must not have duplicate filenames: %q` , w .FileName )
266266 }
267- fileNames [w .FileName ] = struct {}{}
267+
268+ if len (w .MatchPath ) == 0 {
269+ fileNames [w .FileName ] = struct {}{}
270+ }
268271 }
269272
270273 return nil
Original file line number Diff line number Diff line change @@ -155,3 +155,36 @@ In particular:
155155
156156For more details, read [ the dedicated Symfony documentation entry] ( https://symfony.com/doc/current/performance.html )
157157(most tips are useful even if you don't use Symfony).
158+
159+ ## Splitting The Thread Pool
160+
161+ It is common for applications to interact with slow external services, like an
162+ API that tends to be unreliable under high load or consistently takes 10+ seconds to respond.
163+ In such cases, it can be beneficial to split the thread pool to have dedicated "slow" pools.
164+ This prevents the slow endpoints from consuming all server resources/threads and
165+ limits the concurrency of requests going towards the slow endpoint, similar to a
166+ connection pool.
167+
168+ ``` caddyfile
169+ {
170+ frankenphp {
171+ max_threads 100 # max 100 threads shared by all workers
172+ }
173+ }
174+
175+ example.com {
176+ php_server {
177+ root /app/public # the root of your application
178+ worker index.php {
179+ match /slow-endpoint/* # all requests with path /slow-endpoint/* are handled by this thread pool
180+ num 10 # minimum 10 threads for requests matching /slow-endpoint/*
181+ }
182+ worker index.php {
183+ match * # all other requests are handled separately
184+ num 20 # minimum 20 threads for other requests, even if the slow endppoints start hanging
185+ }
186+ }
187+ }
188+ ```
189+
190+ Generally it's also advisable to handle very slow endpoints asynchronously, by using relevant mechanisms such as message queues.
You can’t perform that action at this time.
0 commit comments