Search code examples
phpmacoslaraveldockerboot2docker

Slow response times: Laravel 5.2 in Docker container


When running Laravel 5.2 within a PHP-7 docker container I'm getting response times in 300ms - 400ms.

That is extremely slow although if I'm just echoing out phpinfo() on the same container the response time is 15ms - 50ms is anyone experiencing these slow response times with Laravel in a Docker container?


Solution

  • 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.

    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)

    WOW...!

    HHVM with artisan optimisations + unix sockets: 8ms - 12ms


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

    Take a look at HHVM with optimizations and unix sockets. It's very fast.