#Weird 500ms timings with php artisan serve

25 messages · Page 1 of 1 (latest)

remote herald
#

I'm just starting out with Laravel, going through my first tutorial, but I'm very curious about the timings that php artisan serve reports. They are either less than 1 ms, or consistently around 500ms, which is half a second.
The project itself is extremely simple, there are just a couple of routes, and the views return basically one html element. I'm running it on my own machine with Windows 10, a decently powerful CPU and an SSD. I have the project folder in Windows Defender exceptions.
The timings felt extremely bizarre, so I've decided to measure the performance in other ways. I've tried debugbar, telescope and I also wrote middleware that manually measures request timings. They all show completely normal values, there are no discrepancies between those three at all! I do know that the timings of php artisan serve are not exactly comparable to these ones, but I still expected to see a correlation, and there is none.
So what could this be? Is the timing tool itself broken somehow? I've tried doing php artisan serve in git bash and with cmd.exe as well.
Here's the example comparison of the same three requests in php artisan serve, in laravel.log and in telescope: (attached)

austere bone
#

php artisan serve uses the built in php web server which is not performant, it has its own performance overhead hence why the requests taking longer than what telescope is reporting. for the 1ms requests, those are fast because it's just file access and code execution is involved

#

whenever you switch to something like nginx or frankenphp in production(or developmwwnt env if you want) the requests will reflect close to what telescope is reporting since they are very performant

dense widget
#

Telescope-reported timings using php artisan serve are close to irrelevant as mentioned above

#

if you are worried about performance caps, i recommend setting up some kind of environment (with docker or whatever you prefer) with php-fpm and nginx and redo your tests

you can (should) also use a profiler for this purpose

remote herald
#

i know this isn't actually a big deal and it shouldn't affect things in a production-like environment. i'm just naturally curious and want to get to the bottom of things, i guess. and the reported timings being either sub 1ms or 500-515ms is very perplexing to me. there has never been a 2ms or 10ms or 400ms or 700ms timing

remote herald
#

ok this continues not making any sense, things load more or less instantly for me, while it now started showing some completely made up, multisecond values

sudden cloak
#

Have you tried this on WSL? I once experienced this issue while testing the framework on Windows, but after switching to WSL, it never happened again

remote herald
sudden cloak
#

btw, php artisan serve is single-threaded. This means it can only handle one request at a time, so any subsequent requests will be hold until the current one is completed.

remote herald
#

this is wsl and docker

sudden cloak
#

wsl2 and native docker(not using docker desktop)?

#

I see you have installed telescope, can you share a screenshot of the telescope?

remote herald
#

wsl2 yes and unfortunately i'm a little too noob to answer whether it's native docker or not

#

i do have docker desktop running

#

i must say that the app itself works super fast and these timings are the norm, they seem smaller than they were just on windows

#

right now i don't have telescope running, it's a brand new app. i finished that tutorial on windows and now started another one with wsl and docker 🙂

remote herald
sudden cloak
#

It has a while since I coding at Window, hope the above reply could solve your case

remote herald
#

yeah i have that

#

overall it seems wsl made everything way faster than just on windows

#

like i don't think i've ever seen these times on windows

#

i'll try to just consider those 500ms reported by php server as, uh, annoying visual artifacts, and try to ignore them