[codecasts/ambientum] Performance Improvements & Refactoring
Ambientum is an out of the box Docker solution for Laravel, Symfony and Node.js projects.
This release brings optional performance improvements and refactoring on the Nginx templates.
Extreme/Aggressive OPCache Mode.
OPCache is a PHP extension which pre-compile scripts into bytecode and cache that bytecode in-memory, meaning the application does not need to load the entire source code from disk at every request.
For production applications running on Docker, a change on the source code is also a restart on the PHP-FPM handler, since the containers get removed and new ones are started, based on the newly built images.
Since OPCache will always be restarted along PHP-FPM when the code changes, it's safe to assume OPCache does not need to check for code changes on disk, since it's a pre-built Docker image.
The Extreme OPCache Mode on Ambientum is a feature, enabled by a environment variable, which sets sensitive values for the OPCache configuration, which enables OPCache to try loading all the source code into the bytecode cache.
This means that, once the first requests arrive after a deploy, the application is completely (or close-to) accessible from memory.
This technique was tested by on a custom build, before releasing as a feature. The performance improvements will vary across applications, but evidences have shown improvements between 20% to 300% faster response times.
This feature should ONLY be enabled on production, since the extreme caching will render development changes on code only visible if the container gets restarted.
The extreme OPCache mode can be enabled by using the
OPCACHE_MODE=extreme environment variable.
Nginx Templates Refactoring.
Ambientum supports both Laravel and Symfony PHP frameworks (Lumen included).
While the PHP configuration for each framework is pretty much identical, the Nginx rules for each one are far from being the same.
FRAMEWORK environment variable can be used to enable a given Nginx template.
The currently possible values for
The common parts for those templates were extracted into partials, to make the code easier to maintain.
Also, while refactoring, a new mode was introduced, the
laravel-cache framework mode, which automatically sets Nginx cache headers on media content (images, videos, fonts) and disable access logs for such assets.
Contact on the Github repository, Discord or Commenting on the Post.
Temporary Utopian Disclaimer
Upon payout, rewards corresponding the beneficiary share will be transferred to