I'm currently working on a Laravel project where we would like to optimize our repsonse times.
I created a simple inline controller and tested a few things with clockwork. We thought it was db related. We ruled that one out. However I'm mostly surprised how much time is left in the internals of Laravel. Any tricks or advice on how to minimalize those. Or is it just Laravel nature?
I also checked this with the debugbar and most time is spend in the booting part.
Route::get('db-timing', function () {
// Start timer for the first query
$startFirstQuery = microtime(true);
$firstQueryResult = DB::select('SELECT 1');
$endFirstQuery = microtime(true);
$firstQueryDuration = $endFirstQuery - $startFirstQuery;
// Start timer for the second query
$startSecondQuery = microtime(true);
$secondQueryResult = DB::select('SELECT 1');
$endSecondQuery = microtime(true);
$secondQueryDuration = $endSecondQuery - $startSecondQuery;
return response()->json([
'first_query_duration' => $firstQueryDuration,
'second_query_duration' => $secondQueryDuration,
]);
});