samedi 26 mars 2016

Laravel High CPU usage - PHP-FPM

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.

  1. Laravel 4.2, sent the requests to:

    Route::get('/test', function() { echo "Test"; });

Results: about 40 seconds of CPU on 100%.

  1. Laravel 5.2(clean installation), sent the requests to the welcome page.
    Results: CPU usage on 100% for 20 seconds.

  2. Phalcon(clean installation): sent the requests to Hello world page.
    Results: CPU usage on 50% for 2 seconds.

  3. 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.

    • Same results on both environments.
    • Disabled debug mode, database connection, changed the configs and so on.
      PHP-fpm config:
      pm.max_children = 9
      pm.start_servers = 3
      pm.min_spare_servers = 2
      pm.max_spare_servers = 4

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://ift.tt/21MD3xi
http://ift.tt/22DJqZs

What am I missing here?
Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire