I want to know why my AWS Elastic Beanstalk CPU and memory usage is too high, and I want to troubleshoot issues.
Short description
To gain insight into your Elastic Beanstalk CPU and memory usage and troubleshoot issues, do the following:
- Configure the environment to collect metrics on memory and CPU usage
- Analyze log files to troubleshoot memory and CPU usage issues
Resolution
Configure your environment to collect metrics
To gain insight into memory and CPU usage, do the following:
Analyze your log files to troubleshoot your memory and CPU issue
After gathering data from your metrics, do the following:
- Review the log files from the instances in your Elastic Beanstalk environment.
- Analyze key log files (such as /var/log/messages), and then search for messages about high CPU or out-of-memory (OOM) events.
- Use your log file results to figure out why the process is consuming a high amount of CPU or memory.
Note: For example, you might find a large number of requests in Apache access logs or NGINX access logs.
If the issue is ongoing, then do the following:
- Connect to your Linux instance using SSH.
- Use the Linux top or free command to view details on CPU and memory consumption.
- Configure the ATOP monitoring tool. Review CPU and memory utilization stats.
- CPU-based command: atop -C
- Memory-based command: atop -m
If you don't find any errors, then the traffic load to your environment might have increased. To handle increased traffic, try the following:
- Scale up by increasing the instance type.
- Scale out to decrease the load per instance by increasing the size of the environment's Auto Scaling group.