Your server is stupidly low in resources. Probably only suitable for serving static pages to a couple of users.
May 31, 2024
4
Level 1
Very slow with Hash::check() in an API
Hello all,
I am developing an API with Laravel 11 and I noticed a slowness on my development PC when I use the Hash::check() function. It's even more obvious on my production server where I multiply the time by 2.
My remote server is a Kubernetes with 0.5 vCPU and 512Mb of memory.
Here is the code executed and the results locally and on a remote server:
public function getTest2()
{
$user = User::where('usr_email', '[email protected]')->where('usr_role', 'role')->first();
if(!$user || !Hash::check('password', $user->usr_password)){return response(null, 401);}
return response()->json(new UserResource($user), 200);
}
On local PC: 432ms / 456B
On remote kubernetes server: 905ms / 619B
If I remove the Hash::check() function I go to 228ms execution time locally and 284ms on the remote server.
Is there a solution to already locally speed up execution times and also improve on the remote server side?
Best regards, Yann
Please or to participate in this conversation.