php: Performance problem on require, require_once, include php statements
Hi all, I’m experimenting bad performance and the problem seems to be when calling require, require_once, include statements.
Here’s a very simple file test.php I used to test the problem. The file simply load 3 files test1.php, test2.php and test3.php.
<?php
$start = microtime(true);
require('./test1.php');
$stop = microtime(true);
echo "require: " . ($stop - $start) . '<br>';
$start = microtime(true);
require_once('./test2.php');
$stop = microtime(true);
echo "require_once: " . ($stop - $start) . '<br>';
$start = microtime(true);
include('./test3.php');
$stop = microtime(true);
echo "include: " . ($stop - $start) . '<br>';
Files test1.php, test2.php and test3.php are as follow:
<?php
echo 1; // 2 and 3 in the corrisponding file
When I call test.php from the container (using the image php:7.0-apache), the response time is 10x worst than when I execute the same simple code directly from the host (same apache and same php7).
I’m using Debian 8 also for the Host and Docker Cloud for orchestration. Here’s the output of “docker info”: Containers: 51 Running: 16 Paused: 0 Stopped: 35 Images: 388 Server Version: 1.11.2-cs5 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 839 Dirperm1 Supported: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge null host weavemesh Kernel Version: 3.16.0-4-amd64 Operating System: Debian GNU/Linux 8 (jessie) OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 7.789 GiB Name: xxxxxxx ID: 2PC2:2IGQ:KT26:O4KM:RFID:HUWW:Y2FO:LYSK:MNZR:KXKY:OPFO:G2CX Docker Root Dir: /var/lib/docker Debug mode (client): false Debug mode (server): false Username: xxxxxxxxxx Registry: https://index.docker.io/v1/ WARNING: No memory limit support WARNING: No swap limit support WARNING: No kernel memory limit support WARNING: No oom kill disable support WARNING: No cpu cfs quota support WARNING: No cpu cfs period support
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 1
- Comments: 17 (2 by maintainers)
+1
I also found it really slow on php-fpm docker image, but if use the ubuntu image, apt install the php-fpm and nginx, everything works well… I dont know why
php7.2-fpm-alpine
pure ubuntu image and install php manully…
This is very interesting, I wrote a PHP include test tool based on your tests. I’m not entirely sure this is anything to do with the PHP image itself - I believe it’s still an issue of Docker volume mapping performance and the use of file streams.
Here is the test tool: https://github.com/kducharm/phpincludetest - it includes a flag to enable memory test in addition to just the file include tests.
I have Docker For Mac Edge (17.09.0-ce-mac34 19605), as well as VirtualBox running Ubuntu 16.04. With Docker For Mac, the volume mapped test is at least 10x slower than host, and building an image without volume mapping is roughly the same speed as the host. This doesn’t surprise me given the performance issues plaguing Docker For Mac volumes, but is pretty bad.
In Ubuntu under VirtualBox on Mac, running docker (inception…) - host/volume mapped/image all perform roughly the same as host/image on Docker For Mac. I haven’t tested Ubuntu enough to know what to expect, but it looks pretty performant.
I’ll probably share this testing tool on docker forums, and would be good to augment it with other file I/O tests. This is only a single container test, and I’ve been experiencing bad performance with DB containers on Mac and Ubuntu and need to narrow it down to file I/O or some other multip[le container/volume mapping issue.
Docker machine w/NFS runs way faster on Mac than Docker For Mac currently for me, which is not good.
@alexmatsak can you provide
docker info
too.Same problem here…
@tianon I tried with 1) a volume/bind mount and 2) with files created on the fly inside the container after I started it without a volume. I had the same differences between the host and container results in both cases. I didn’t try with a new image with these files stored inside.
I also installed a fresh new debian 8 on a PC and replicated the test on the host and in the container. Same results as on the precedent host.
By the way, if I compare performance for other kind of statements (i.e. using memory), the results are instead quite the same in the host and the container. For example:
This point has been also verified comparing results between the host and the container of this php benchmark.