- Newest
- Most votes
- Most comments
To address your high memory usage issue in AWS Elastic Beanstalk while maintaining your current instance type, you should consider the following adjustments to your Auto Scaling policy:
-
Changing the scaling metric: Yes, changing the scaling metric from TargetResponseTime to MemoryUtilization would be beneficial in your case. Since your application is experiencing high memory usage while CPU utilization remains normal, using MemoryUtilization as the scaling metric will more accurately reflect your application's resource needs.
-
Thresholds for scaling based on memory usage: For memory-based scaling, consider setting the upper threshold to around 80-85% and the lower threshold to about 60-65%. This allows for some buffer before reaching critical memory levels. For example:
- Upper Threshold: 80% (Scale up)
- Lower Threshold: 65% (Scale down)
-
Capacity Rebalancing: Enabling Capacity Rebalancing is not likely to significantly improve stability in this case, as it's primarily designed to help maintain capacity during Spot Instance interruptions. Since you're using On-Demand instances, this feature won't have a major impact on your current setup.
-
Best practices for memory-heavy workloads:
a. Implement custom CloudWatch metrics to monitor memory usage more closely. This can help you set more precise alarms and scaling triggers.
b. Consider using Step Scaling instead of Simple Scaling. Step Scaling allows for more granular control over scaling actions based on the severity of the memory utilization.
c. Reduce the scaling cooldown period. Your current 360-second cooldown might be too long for memory-intensive applications. Try reducing it to 180-240 seconds to allow for faster scaling responses.
d. Implement a custom scaling solution using AWS Lambda functions and CloudWatch alarms to handle more complex scaling scenarios that take into account multiple metrics (e.g., both memory and CPU usage).
e. Regularly review and adjust your scaling configuration to ensure it aligns with your application's evolving needs and usage patterns.
f. Monitor your application closely using additional CloudWatch metrics and set up separate alarms for memory usage. While these won't automatically trigger scaling, they can alert you to potential issues.
g. Optimize your application code to improve memory management if possible.
By implementing these changes, particularly switching to MemoryUtilization as your scaling metric and adjusting your thresholds, you should see improved performance and more efficient scaling for your memory-intensive application while continuing to use t3a.micro instances.
Sources
beanstalk scaling set on CPU, what happens when RAM get eaten up? | AWS re:Post
Elastic Beanstalk is not scaling as expected on Request Count metric | AWS re:Post
ECS Service auto scaling policy conflict the one to other policy | AWS re:Post
Relevant content
- asked 6 months ago
- asked 3 years ago
- asked 2 months ago
- AWS OFFICIALUpdated 3 months ago
Thank you for your valuable suggestions regarding the scaling policy adjustments for memory utilization. I appreciate your guidance on changing the scaling metric to MemoryUtilization and adjusting the thresholds. However, I have a key concern regarding the CloudWatch agent setup. As I am using AWS Elastic Beanstalk with auto-scaling enabled, I would like a permanent solution where I do not have to manually configure the CloudWatch agent each time the auto-scaling process spins up a new instance. Currently, I understand that CloudWatch memory metrics require the installation of the CloudWatch agent on each EC2 instance. However, manually installing and configuring the CloudWatch agent on new instances every time they are launched isn't ideal for my use case. Is there a way to automatically install and configure the CloudWatch agent on new EC2 instances that are part of my Elastic Beanstalk environment (especially for memory utilization monitoring)? I want to avoid having to manually configure this each time an instance is added or replaced. Can this be achieved using an automated setup such as User Data scripts during instance launch to install the CloudWatch agent automatically? Elastic Beanstalk configurations or environment settings that ensure CloudWatch agent installation for every new instance? create a Custom AMI that already has the CloudWatch agent installed and configured, so every new instance launched from this AMI automatically has the agent pre-installed