简体   繁体   中英

Time of response taking too long time - Laravel Api

I'm building a laravel API, and I'm testing my requests from Postman. Simple request taking a too long time to get some response(about 200~300 ms). I have the same API in Java that gives the same responses in 30 ms maximum. Anyone have any idea what be happening?

response time:

response time image

Controler:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Setor;

class SetorController extends Controller
{
    public function show(){  
        return Setor::all();
    }
}

Maybe it's because the DB query takes a lot of time. Try to change the method to simple returning value:

public function show(){  
    return 'ok';
}

Then measure request time. Did it decrease?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM