Skip to content
Advertisement

Laravel 6 with Nginx, php 7.4 fpm and mysql 8 on docker is slower than Laravel 4 on php 7.1

I have been working on a site built on Laravel 4.2 and on Php 7.1. Recently I have been trying to migrate the site to Laravel 6 with php 7.4 and mysql 8. I setup docker with the following settings.

Database File:

JavaScript

Nginx File:

JavaScript

Nginx conf:

JavaScript

Php-fpm

JavaScript

docker-compose

JavaScript

The migration is going smooth, but i noticed the pages load quite slowly.

The same page on my old code running on php 7.1 and Apache takes about 100 – 200ms while my new version would almost take 1 second.

I put an exit in the bootstrap/app.php and it still takes around the same time. I noticed the app_debug was on and I turned it off and that reduced the delay to around 600 – 700ms to load a ‘hello’ text on a page.

I am wondering is the Docker adding the delay or am I missing any setting on laravel 6 that could be slowing it down.

The opcache is disable on both.

I have been trying to test some time differences. I have not much knowledge of how to do it, but gave it a shot.

The index page first line
old setup – 8ms
Docker setup – 16ms

in bootstrap app.php first line
old setup – 28ms
Docker setup – 106ms

in bootstrap app.php before $app is returned
old setup – 56ms
Docker setup – 206ms

At index.php before app is executed
old setup – 68ms
Docker setup – 254ms

after complete load of app
old setup – 115ms
Docker setup – 1 second (approx)

In laravel 4, we had the $app->run() in the index.php after the $app was returned. In larave 6 we have instead of $app->run().

JavaScript

could this be loading something that could be contributing to some latency. I also tried commenting out some middleware and it was still the same.

Every request is taking a long time to load. The fonts are taking 300 ~ 400 ms to load and everyhting is about 10 times slower compared to the old code on apache on Mamp.

Advertisement

Answer

I found something that drastically improved the performance. The time stamps for the site on different pages are similar to the bare metal configuration with MAMP.

I used volume optimisation as explained here: https://engageinteractive.co.uk/blog/making-docker-faster-on-mac

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement