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.
from Recent Questions - Stack Overflow https://ift.tt/3juTotH
https://ift.tt/eA8V8J
Comments
Post a Comment