1

I have a problem: When trying to get a single user from the database using laravel controller response is just too slow. Response time is over 1000ms, see Postman screenshot below.

Below is my code:

Controller:

public function getUserData(Request $request)
{
    return User::where('id',3)->select('name')->first();
}

web.php

Route::prefix('data-controller')
->name('data.controller')
->middleware([])
->group(static function(){

    Route::get('/get-user-data', 'DataController@getUserData')->name('getUserData');
});

.env

APP_NAME=AppName
APP_ENV=production
APP_KEY=base64:MEw1jEc7qyYhz4vIgxpZIqkjkfdkjfpasdfbURtoQ67HS6KsSBajwMC0=
APP_DEBUG=false
APP_URL=127.0.0.1
LOG_CHANNEL=single

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydb
DB_USERNAME=root
DB_PASSWORD=******

#SESSION_SECURE_COOKIE=true

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=anonymous-database
SESSION_LIFETIME=120

ACCESS_ALLOW_IP=
ACCESS_ALLOW_IP_ON=false

Postman screenshot

I appreciate all of you ideas and help, I'm slowly but surely loosing my mind with this problem.

Thank you in advance! If you need any more information I'll gladly provide it in this post's edit.

  • That's weird... you can install the [Clockwork](https://github.com/itsgoingd/clockwork) dev tool to your project which will provide you with a timeline of what's taking so long. – reza khademi May 20 '21 at 10:12
  • Already did and the most time is spent in the controller, db takes less than 20ms. – Mirko Druzijanic May 20 '21 at 14:35

0 Answers0