Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

581
Visualizações
Laravel, api call slow first time (repeated call after 5s)

I work on a Vagrant+Puppet LAMP (2x cores, 2.5GB) stack where I develop my Laravel ver.8 based API. There is a default setup, JWT middleware and almost bare minimum (also try with a bare fresh install with same behaviour). After the first call, the response time is about 6 seconds. If I call the same API endpoint, the response time is 200ms. Each further call within 3 seconds interval is quick. If I pause the calls for > 3s and then call again, the response time is again slow at about 6s.

Attempts I made to solve this:

php artisan cache:clear
composer dump-autoload -a --apcu
php artisan config:cache
php artisan session:table
php artisan migrate

.env:
APP_DEBUG=false
SESSION_DRIVER=database
SESSION_LIFETIME=120
CACHE_DRIVER=memcached
MEMCACHED_HOST=127.0.0.1
MEMCACHED_PORT=11217

BTW, the api call returns only: return response()->json(['tst']); When I output phpinfo(); from index.php, the response time is each time (pausing to) about 70ms.

Also try to debug the calls with CacheGrind via Xdebug: XDEBUG_PROFILE=1. Here are the profiling results: https://filebin.net/izs3qm0gm3gt8jq6

I just mentioned that the autoloader takes longer but could not compare the results. Is there any way to figure out the issue?

Thank you in advance.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Setup clockwork so you can analyze all the activity when you try to hit some end-point

just simply run

composer require itsgoingd/clockwork

you'll get an interface like this to check all the data

enter image description here

Another option is to use laravel telescope https://laravel.com/docs/8.x/telescope But this requires database setup and record all logs on the database, and I personally like clockwork,

but both should tell you whats wrong with your setup

over 4 years ago · Santiago Trujillo Relatório

0

The reason was the long DNS Lookup on the Vagrant box - not Laravel or any other part of it.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda