'Laravel 7 - random lag (mostly ajax request - from 300ms to random 4,5s)
currently I am using laravel 7(php7.4) on my client server and i have noticed some strange behavior - very often when using ajax. Normal request is taking something between 150-300ms depending on product. But every 15-30 requests there is serious lag for 4,5 seconds. I've tested it on function add to cart and problem seems to be completely random. Here is example screenshot from chrome console:
After more tests it seems that not only ajax is causing random lags but every normal action could end up with lag. Server is a quite strong VPS: 8 vCPU Intel Xeon / 16 GB ram / 500ssd. Usually everything is running smooth but this lag from time to time is annoying my client.
There is one more thing about this problem - i am using debugbar to check app "performance" and sometimes this lag is visible in chrome console but not in debugbar:

In chrome request took 5,5s which is way to long but debugbar shows execution in 120ms as it should be.
Question is how to debug this problem and where it comes from?
Many thanks for any help!
Solution 1:[1]
Did you check the queries? the pages itself is loading fast, but you have some queries because I can see them in the laravel debug bar. Check the time of the queries.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ricdizio |

