Issue
It’s a single ajax request.
As you can see, I wrote the duration
in the result, it’s the duration of all the queries executed in the api backend.
The Response length is 11 KByte
, so it’s not a response weight problem.
But as you can see the server is serving the page is 5 seconds
.
I’m using nginx, and on this server (it’s a single project dev VPS), there is NO trafic, no concurrency problems.
The backend is made in laravel 8 and it’s doing only this:
$start = microtime(true);
$data = $this->articleRepository->getProducts($request->all());
$duration = microtime(true) - $start;
return response()->json([
'status' => 'success',
'data' => $data,
'debug' => [
'duration' => $duration
]
]);
I tried to replace laravel magics with
$json = json_encode([
'status' => 'success',
'data' => $data,
'debug' => [
'duration' => $duration
]
]);
return $json;
But it’s taking same time. So I think that is a problem at server side.
By the way, please note that dev VPS is a debian 11 machine in my local network. We already verified that up/down band is well over 350Mbits/secs, symmetric, and stable.
I cannot diagnose it, I have root access to VPS, but I’ve no idea of what could causes so much slowness
Any idea?
Solution
In this very specific case, it was a question of DNS. "localhost" resolution are causing a series of problems and latencies. We moved all pointing from ‘localhost’ to 127.0.0.1 and ALL is resolved.
Note for future Googlers for Laragon and/or Xamp developers: we discovered accidentally that changing localhost to 127.0.0.1 when configuring redis in the laravel .env variabile fixes a huge amount on a windows machine when using both Laragon and Xamp
Answered By – realtebo
Answer Checked By – Marie Seifert (BugsFixing Admin)