Customizing the image
BenchKit is built on the serversideup/php images, and inherits their environment variables. You can change how PHP is configured and run again without rebuilding anything, which is what makes BenchKit useful for learning rather than only for measuring.
Common settings to change
services:
benchkit:
image: serversideup/benchkit-laravel:latest
ports:
- "80:8080"
environment:
# OPcache, which BenchKit turns on by default
PHP_OPCACHE_ENABLE: "1"
PHP_OPCACHE_JIT: "tracing"
PHP_OPCACHE_MEMORY_CONSUMPTION: "256"
# PHP itself
PHP_MEMORY_LIMIT: "512M"
# The FPM pool, on the fpm-nginx and fpm-apache variations
PHP_FPM_PM_CONTROL: "dynamic"
PHP_FPM_PM_MAX_CHILDREN: "20"
Settings without an environment variable
The specification covers most of what you would reach for, but not everything in php.ini has a variable. When you need one that doesn't, add your own .ini file. You can mount it at runtime or bake it into an image.
Nothing to build. Edit the file, restart the container, run again. This is usually what you want, since a BenchKit server is temporary anyway.
; Files in conf.d load alphabetically. The zzz prefix puts this after
; the file serversideup/php writes from your environment variables,
; so anything set here wins where the two overlap.
; realpath_cache_ttl has a variable (PHP_REALPATH_CACHE_TTL).
; realpath_cache_size does not, so it belongs here.
; Both values below are raised from the PHP defaults of 4096K and 5.
realpath_cache_size = 16384K
opcache.max_wasted_percentage = 10
Use this when you want the configuration to travel with the image, or when your host builds from a Dockerfile rather than pulling one.
# The tag you build from decides the web server, exactly as it does
# when you pull the image directly.
FROM serversideup/benchkit-laravel:latest
COPY zzz-custom-php.ini /usr/local/etc/php/conf.d/
docker build -t benchkit-custom .
docker run -p 80:8080 \
-v benchkit-runs:/var/www/html/storage/app/runs \
benchkit-custom
Turning a setting into an experiment
Because these are environment variables, you can measure what any one of them is worth on your own hardware.
Run with the setting off
Start BenchKit with the setting disabled, for example PHP_OPCACHE_ENABLE=0, and run a benchmark.
Run with the setting on
Restart with the setting enabled and run the same benchmark again.
Compare the two runs
Open both runs in Compare. The environment panel shows the php.ini values that were in effect for each one, which tells you exactly which change produced the difference.
Choosing the web server
Which web server runs is decided by the image variation you pull, not by an environment variable. See Image variations.