So I've timed my controller method in Laravel with both microtime(true)
and getrusage
, and checked the actual data responded - it processes my request in ~0.2s, so quite fast.
The actual TTFB for it to respond back to my app is a massive 12 seconds.
Given the data is obtained and returned so quickly, where could this bottleneck be?
I'm aware it's quite a vague question, but I honestly have no idea what could be doing this. Has anyone encountered similar? Included the controller method below, in case it's handy. Just using a standard Axios get()
request to run the query.
public function authenticate(Request $request){
$credentials = $request->only('email', 'password');
try {
if (! $token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
return response()->json(['error' => 'could_not_create_token'], 500);
}
$user = User::where('email',$request->email)->first();
if($request->invitationIdIfExists){
$invitation = Invitation::find($request->invitationIdIfExists);
if($invitation->recipient_email == $user->email){
$request->headers->set('Authorization', 'Bearer '.$token);
Helper::processInvitation($invitation, $user);
}
}
$user->touch();
$user->token = $token;
$user->load(['accounts', 'minTodoDays', 'minNotifications']);
$user->todo_days = $user->minTodoDays;
$user->notifications = $user->minNotifications;
unset($user->minTodoDays);
unset($user->minNotifications);
$invitationIfExists = Invitation::where('recipient_email', $user->email)->where('completed', 0)->first();
if($invitationIfExists){
$user->invitedAccount = $invitationIfExists->account;
}
return $user;
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3q4lyNw
via IFTTT
Aucun commentaire:
Enregistrer un commentaire