5

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

enter image description here

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

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
dev
  • 735
  • 2
  • 15
  • 31
  • I recently upgraded a project from Laravel 7 to Laravel 9: the performance is horrible, the server CPU usage raised 800%, and responses are much slower. I regret doing upgrade. – Facundo Fasciolo Sep 21 '22 at 16:17

3 Answers3

1

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.

kingan
  • 98
  • 6
  • Hey, the test on the Windows machine was not in container. The docker containers I tested are on a dedicated server running Unraid (ps: not the one downvoting :) – dev Mar 12 '22 at 14:34
  • Also the distro doesn’t affect the response times, based on my tests. I haven’t used laravel after version 7 and wasn’t sure what’s happening with the performance. This is not usable for actual project like that.. – dev Mar 12 '22 at 14:37
1

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.

dev
  • 735
  • 2
  • 15
  • 31
0

You can try this, uncheck "Use the WSL 2 based engine" and check "Expose deamon on TCP://localhost:2375 without TLS. As much as I know the reason behind this is WLS 2 filesystem is slower then WLS1. This is just a quick solution.

enter image description here

  • On the other hand, this looks to be your own content :-). I'd still encourage you to delete the other answer if it's AI-based, though. Regarding this answer, though, I doubt that unselecting the WSL2 backend will *improve* performance. I understanding what you are thinking, and it's not a bad line of reasoning. However, when you aren't using WSL2, Docker doesn't switch to WSL1 as you assume -- It switches to a Hyper-V backend. As noted in the screenshot/settings, the performance on WSL2 should be *better* than on Hyper-V. – NotTheDr01ds Jul 07 '23 at 16:59