How do I troubleshoot memory and CPU issues in Elastic Beanstalk?
Last updated: 2019-10-15
My CPU or memory usage is too high in my AWS Elastic Beanstalk application.
Configure your environment to collect metrics
To gain insight into memory and CPU usage, try the following:
- Check the health of your Amazon Elastic Compute Cloud (Amazon EC2) instances with the Elastic Beanstalk health agent.
- Monitor your instances using Amazon CloudWatch.
- Enable enhanced health reporting and monitoring and configure advanced health rules for your Elastic Beanstalk environment (such as CPU load averages).
Analyze your log files to troubleshoot your memory and CPU issue
After gathering data from your metrics, try the following:
- Review the log files from the instances in your Elastic Beanstalk environment.
- Analyze key log files (such as /var/log/messages) and 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 could find a large number of requests in Apache access logs or NGINX access logs.
If the issue is ongoing, try the following:
- Connect to your instance using SSH.
- Use the Linux top or free command to view details on CPU and memory consumption.
If you don't find any errors, then the traffic load to your environment could 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.