Framework: [5.2] Slow response times running within a php-7 Docker container

Created on 10 Feb 2016  路  9Comments  路  Source: laravel/framework

When running Laravel 5.2 within a PHP-7 docker container I'm getting response times in 300ms - 400ms. That is very slow, if I'm just echoing out phpinfo() on the same container the response time is 12ms - 50ms is anyone experiencing these slow response times?

Most helpful comment

UPDATE:

Comparing differing environments in a docker

Note: the below are without artisan optimize --force or artisan config:cache

  • HHVM 13ms - 31ms (TCP port 9000)
  • HHVM 12ms - 22ms (Unix socket)
  • PHP-7 FPM 42ms - 73ms (TCP port 9000)
  • PHP-7 FPM 38ms - 55ms (Unix socket)

HHVM with artisan optimisations + unix sockets: 8ms - 12ms
PHP-7 FPM with artisan optimisations + unix sockets: 38ms - 42ms

WOW take a look at HHVM with optimizations and sockets. THAT makes node and golang look slow...

Who needs PHP-7 for performance? not me...

All 9 comments

Okay, problem solved.

On a local development environment using Docker 1.10 with the VirtualBox driver and a volume mounted to the host system (that would be Boot2Docker VM and OSX) the performance is incredibly woeful, as described above 300ms - 600ms.

Use the same configuration without the mounted volumes 20ms - 30ms response times. My assumption is that because Laravel has intensive disk I/O due to the large amount of files it loads on each request this is impacted by how VirtualBox shares folders between the host and a VM.

Issue is not a Docker or Laravel, its a VirtualBox VM issue.

(BTW If you are not using Docker... your crazy.)

UPDATE:

Comparing differing environments in a docker

Note: the below are without artisan optimize --force or artisan config:cache

  • HHVM 13ms - 31ms (TCP port 9000)
  • HHVM 12ms - 22ms (Unix socket)
  • PHP-7 FPM 42ms - 73ms (TCP port 9000)
  • PHP-7 FPM 38ms - 55ms (Unix socket)

HHVM with artisan optimisations + unix sockets: 8ms - 12ms
PHP-7 FPM with artisan optimisations + unix sockets: 38ms - 42ms

WOW take a look at HHVM with optimizations and sockets. THAT makes node and golang look slow...

Who needs PHP-7 for performance? not me...

The following optimizations should always be used in production:

composer install -o --no-dev
php artisan optimize --force
php artisan config:cache
php artisan route:cache

Who needs PHP-7 for performance? not me...

In my benchmarks, PHP 7 out performs HHVM LTS on Laravel out of the box. The performance of individual apps could vary though. If PHP 7 is significantly slower, you've probably misconfigured something.

Yes, always running artisan optimisations as above.

I doubt there are any misconfigurations, as both HHVM (v3.11) and PHP-FPM (v7) are running from offical Docker images. If the PHP Docker repos are mis-configured there are no issues logged.

The stats are from a stock Laravel 5.2 welcome route. Isolated Docker environment on Ubuntu.

8 - 12ms is faster then most of my node or golang projects :-)

Turn opcache on for php7 with disabled file check, and compare again ;)

Yeah I will do... I'm about to revisit this

What was your conclusion @andrewmclagan?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JamborJan picture JamborJan  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments

fideloper picture fideloper  路  3Comments

Fuzzyma picture Fuzzyma  路  3Comments

PhiloNL picture PhiloNL  路  3Comments