Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda