Magento – Why Magento is using high CPU in AWS

awsmagento-1.9nginxperformancephp-fpm

I'm having a problem that is occurring after the volume of concurrent users on my site has increased. I'm currently with almost 600 concurrent users and the server is using 100% CPU.

To alleviate this load, I use some caching systems:

ElasticSearch, Memcached, and varnish.

My server is running with Nginx, php-fpm56 and Magento 1.9.3.

Configs nginx (/etc/nginx/nginx.conf):

fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_read_timeout 300;

php-fpm (/etc/php-fpm.d/www.conf):

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35

My server is AWS with c3.4xlarge configuration (vCPU:16 MEM: 30GB SSD: 2 x 160GB)

Monitoring CloudWatch:

My CloudWatch

htop:

enter image description here

The theme was built by us, the entire front-end searches the ElasticSearch, the whole system is cached.
We do not use many modules, just OneStepCheckout, payment gateway, and SMTP.
I do not know what could be happening anymore because with this machine configuration it should be able to handle at least triple the users.

Anyone have any idea what might be happening?

Thanks!

Best Answer

Check your logs under system.log and exception.log if you see any error there relating to your Magento. Also do some tests to your modules using https://github.com/magento-ecg/coding-standard to see if your modules have Magento standards in the way how collections are loading, or if any infinite loop is used.