I am using out of the box Laravel 9 / php 8.1 combo and loading initial page for 190ms sounds horrible. Last project I built used laravel7 and the response times in development including database queries – talking complex ones were less than 20ms
Currently I am trying to set it up, so the tests were simply loading the default route or just a route returning a string.
I tested several instances
- Custom docker container I’ve built (amazonlinux, php81, php81-fpm / nginx ) on an old server
- Local Windows 10 instance / php81 / artisan serve
- Pre-built container by bitnami
All of them showed responses ranging from 80ms to 2200ms
- My custom container because of the optimizations showed responses of 60ms – 80ms, but on the 3rd-4th refresh it pulled a 450-900ms response time
- On Windows 10 instance there was stable response, but horribly slow ~85-130ms
- Pre-built container was also stable on around 190ms
You can understand the horror as those are simply empty frameworks deployed.
My test case where a database from another container was pulled to select 1-100 records didn’t change the response times. Database was pulled in less than 10ms.
For comparisson, because I started reviewing php-fpm configuration (still out of the box on all test cases) I ran some benchmarks if this is the bottleneck, but it was performing flawless. Ops/sec were as described on normal php8.1 benchmarks
Strange thing I’ve noticed was within Xdebug on my custom container, there were 2300 more records below this.
2
Answers
So for now I've concluded that the main issue is mainly with Docker and the fact that laravel was sitting in an folder exposed to the machine.
The responses are delayed because the performance of those folders is literally slowed down 60 times.
After further testing this is what it all comes down to. I am upgrading the hardware from a server HDD to m.2 to ignore partially this slowdown.
My tests showed 1.83 mb/s transfer rate for the shared folder on the server compared to 110 mb/s on the dedicated server.
Did you try to change your WSL config or install other distro like ubuntu etc? I had a similar issue on windows and NTFS issue. I changed my distro to ubuntu LTS and become faster like a normal website.