Hello, I have a Laravel 8 project which uses SQL Server as the database. The problem is on my local windows 11 machine page takes 2.5s to download and I am accessing the page via 127.0.0.1:8000 using PHP Built in dev server I thought built in dev server is the problem so I tried to use nginx but got 2.5s to get the response and less than 100ms to downlaod it. the problem is when I go to telescope it says request duration was 60ms~150ms also telescope loads very fast but my application isn't. Also I thought there is a problem with the SQL Server so I changed the Database to MySQL, but still got the same problem. Last thing I have tried is I got a flash drive with Fedora 36 on it and booted into it and pressed "Try Fedora" and then I tried to start the application with mariadb as the database (Changed it cause SQL Server need 6 GB and the whole flash drive was only 8GB) and the application is working as fast as light so I know the problem is related to the OS but is there any thing I can do to fix this problem in my Windows 11 machine? cause I cannot move to linux currently? I can't even code when the application take 2.5 sec for every request I have searched a lot about this problem but nothing helped me
@automica I tried to use Sail but it require WSL 2 and WSL 2 uses VM and when I use VM my laptop will be too slow and lagging cause I only have 8GB Of ram and CPU is i5-1035g1 which is not the best for VMs
Note: I was using WSL 2 and everything was perfect except for my laptop performance which was very fast in the VM but extremally slow in windows
Maybe due to SQL Server, because in Windows 11 with mySQL it's fast.
Edit:
Also do a query and load a page, but don't go by the results of only one query do a few more and check the times. Perhaps paginate a result and compare firstpage, page 2, page 3, Etc.
@omardev in development with mySQL on Windows 11 mine is blazing fast. Have you checked your indexes and things like that.
Meaning if you have an inefficient query it's going to be slower even on a fast machine.
How much memory do you have on your windows 11 machine, cause that makes a big difference. 16 gig on mine is fast, an older machine with 8 gig that I cannot upgrade anymore is much slower with the exact same setup.
Much of this is due to these modern programs needing more and more memory whereas a decade ago a machine with 256 MB memory would run programs very fast.
@jlrdw The problem isn't related to the Database as I tried other databases and just tried to send a api request that doesn't execute any query and still same problem also as I said telescope loads extremally fast and the application and telescope is in the same server and database
try WSL and copy your source files into the linux file system and run that way. should match your experience with Fedora.
if there's a virtual machine running behind the scenes it's often the file sharing that slows down the process. Moving from linux file system to windows on each access can show things down.
@toddroseman WSL is great and the project was working perfect there but WSL uses VM and when I use VM my laptop will be too slow and lagging cause I only have 8GB Of ram and CPU is i5-1035g1
Edit: I think installing Fedora 36 is the best solution for this problem
@cwhite Yes I have tried WSL 2 works perfect. but the problem is After WSL 2 VM's starts (Vmmem) windows gets so laggy and phpstorm take about 3-5 seconds just to show code auto completion list, But when I shutdown WSL 2 it only takes < 500ms to show code auto completion list and windows become fast.
After a lot of work and researchers
I tried to debug the whole life cycle (from boot strapping the application till the termination of the application)
and I have found that the whole problem was in the termination I have followed what is happening in the termination process and figured out the problem was in the callbacks before terminating the application
tried to change file vendor/laravel/framework/src/Illuminate/Foundation/Application.php line 1158 and added this little code
dd($this->terminatingCallbacks);
And then I saw 2 callback functions one for telescope and one for laravel profiler (jkocik/laravel-profiler) I tried to skip the laravel profiler callback and done the problem is fixed after that I removed the laravel profiler package and the changes that I made in the vendor folder.
Everything now is fine, the application is working as expected (response is returned in less than 50ms).