Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EverdevFR's avatar

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

1 like
4 replies
Snapey's avatar

Your server is stupidly low in resources. Probably only suitable for serving static pages to a couple of users.

1 like
EverdevFR's avatar

@Snapey Thanks for your feedback. To have good response times with Laravel without it costing too much in web hosting, what resources should I use?

Because I just put the maximum I have on one of my Kubernetes nodes (2vCPU of 2Ghz and 7GB of memory) and that doesn't change...

Please or to participate in this conversation.