Report this

What is the reason for this report?

My AWS CPU Utilization goig very high bcz on nginx

Posted on August 16, 2020

Dear Team I have aws with nginx server for my magento store

but last 4 dys i found some times my cpu utilization going very high more than 90% but my website visit very less

that time i check with Top commend i found too much nginx process are running

can u help me for fixing this issue ?

please check this image

http://prnt.sc/u0dfos



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @shiraski,

It looks like there are a lot of PHP-FPM processes that are causing the high CPU usage on your server.

What I could suggest is using this script here which will summarize your Nginx access logs. That way you will be able to tell if the traffic that you are getting is legitimate or not.

If the traffic is legitimate, I would recommend doing some optimization for your Magento server so that it does not need so much CPU resources. For example as a start you could do:

  • Enable caching
  • Enable flat catalogue
  • Add a CDN in front of your web server
  • Enable PHP OpCache

Let me know how it goes. Regards, Bobby

High CPU utilization with many Nginx processes despite low website traffic can indicate several potential issues, including misconfiguration, an unusually high number of requests (possibly malicious), or resource-intensive processes. Here are steps to diagnose and potentially resolve the issue:

1. Analyze Access Logs

Check the Nginx access logs to see if there’s an unusually high number of requests or any pattern of suspicious requests. This can help you determine if your server is under a DDoS attack or being scanned by bots.

sudo tail -f /var/log/nginx/access.log

2. Review Nginx Configuration

Review your Nginx configuration for any settings that might be causing high CPU usage. For instance, an excessive number of worker processes or inappropriate buffer sizes can lead to issues.

  • By default, Nginx’s worker_processes directive is set to auto, which is usually appropriate. However, you might want to explicitly set it based on your server’s CPU cores.
  • Check for unnecessarily low keepalive_timeout values or extremely high client_max_body_size.

3. Optimize Magento

Magento is a resource-intensive application. Ensure it is properly optimized:

  • Enable Magento caching.
  • Consider implementing a content delivery network (CDN) to offload static resource delivery.
  • Optimize your Magento database.
  • Use Magento’s built-in compilation feature to compile and optimize your Magento installation.

4. Implement Caching

Implement caching in Nginx. Caching can significantly reduce CPU load by serving static content without repeatedly processing the same requests.

location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 30d;
}

5. Check for Malware or Unauthorized Access

Run a malware scan and check for any signs of unauthorized access or a compromised server.

6. Monitor for Unusual Activity

Utilize monitoring tools to keep an eye on what’s happening on your server:

  • Use htop or glances for a more comprehensive view of your server’s resource usage.
  • Employ tools like fail2ban to block repetitive suspicious requests.

7. Upgrade Server Resources

If your server is consistently at high CPU usage and you have optimized as much as possible, it may be time to upgrade your server’s resources.

8. Consult AWS Support or a Magento Specialist

If you continue to experience issues, consider reaching out to AWS support for insights specific to your instance. You may also want to consult with a Magento specialist, as Magento-specific optimizations can be quite complex.

Remember, high CPU usage can sometimes be a symptom of broader performance issues or security concerns, so it’s important to approach this systematically, covering both Nginx and Magento optimizations.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.