perf: improve FrankenPHP config #694
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Expanded, the current config is similar to this:
I recently took some time to profile and optimize FrankenPHP, and that config is the slowest part in FrankenPHP (this likely affects the
php_fastcgiCaddy directive as well). All the calls totry_filesandfiledo I/O operations, which are slow.Most of these I/O operations are checks useful for traditional PHP apps where the document root contains a lot of
.phpfiles (like WordPress) but are not needed when using Symfony or Laravel.This simplified config reduces the number of I/O to the strict minimum: just 1 check to see if the requested path exists on disk, and delegates to PHP if it's not the case.
In the future, I plan to add a
frameworksubdirective tophp_serverthat automatically generates this config.cc @francislavoie, this may also be interesting for
php_fastcgi.