I'm using Laravel 4.2, when I navigate through the pages the PHP-FPM spikes to 10-20%.
I checked it on 2 environments:
A:
Nginx Balancer - 2 CPU, 2GB.
PHP-FPM server - 1 CPU, 1GB.
MySQL server - 2 CPU, 2GB.
B:
Simple VPS on linode of 1 CPU, 1GB.
*SSD on all servers.
Now, I started investigating it more deeply using JMeter:
JMeter settings:
Number of Threads(users) - 100.
Ramp-Up Period(in seconds) - 1.
Loop Count - 5.
Laravel 4.2, sent the requests to:
Route::get('/test', function() { echo "Test"; });
Results: about 40 seconds of CPU on 100%.
Laravel 5.2(clean installation), sent the requests to the welcome page.
Results: CPU usage on 100% for 20 seconds.
Phalcon(clean installation): sent the requests to Hello world page.
Results: CPU usage on 50% for 2 seconds.
Codeiginiter(rest api server, same config): sent the requests to a page that loads data from the DB(returning JSON).
Results: CPU usage on 55%-60% for 3 seconds.
I understand that Laravel should be slower but I doubt the difference should be that big? I googled for hours, I encountered a few posts that have the same issue as mine but without any solution:
http://laravel.io/forum/09-25-2014-what-steps-should-i-take-to-reduce-laravels-high-cpu-load
http://laravel.io/forum/08-12-2014-cpu-load-general-performance-question
What am I missing here?
Thanks in advance.
That might sound obvious and off topic, but make sure your PHP installation includes OPCache extension php-opcache
. That helped me a lot.
OPCache gradually increases PHP performance by storing precompiled script bytecode in shared memory, sot does not repeatedly load/parse scripts for each request.
You can get more information from PHP OPCache Documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With