0
0
AWScloud~5 mins

Performance efficiency pillar in AWS - Commands & Configuration

Choose your learning style9 modes available
Introduction
Performance efficiency pillar helps you build cloud systems that run fast and use resources well. It solves problems like slow apps or wasted computing power by guiding how to choose and adjust resources.
When your website slows down during busy times and you want it to stay fast.
When you want to save money by using just the right amount of cloud resources.
When you need your app to handle more users without crashing or lagging.
When you want to test different cloud setups to find the fastest one.
When you want to monitor and improve your system’s speed over time.
Commands
This command creates an alarm that watches CPU use on an EC2 server. It alerts you if CPU use stays above 70% for 10 minutes, helping you spot when the server is busy and might need more power.
Terminal
aws cloudwatch put-metric-alarm --alarm-name HighCPUUtilization --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 70 --comparison-operator GreaterThanThreshold --dimensions Name=InstanceId,Value=i-0123456789abcdef0 --evaluation-periods 2 --alarm-actions arn:aws:sns:us-east-1:123456789012:MyTopic --unit Percent
Expected OutputExpected
No output (command runs silently)
--alarm-name - Names the alarm for easy identification
--threshold - Sets the CPU usage level that triggers the alarm
--alarm-actions - Defines what happens when the alarm triggers, like sending a message
This command sets up automatic scaling for your servers. It keeps at least one server running and can add up to three when demand grows, so your app stays fast without wasting resources.
Terminal
aws autoscaling create-auto-scaling-group --auto-scaling-group-name my-asg --launch-configuration-name my-launch-config --min-size 1 --max-size 3 --desired-capacity 1 --vpc-zone-identifier subnet-12345678
Expected OutputExpected
No output (command runs silently)
--min-size - Minimum number of servers to keep running
--max-size - Maximum number of servers to add when needed
--desired-capacity - Number of servers to start with
This command links a scaling policy to your auto-scaling group. The policy tells AWS when to add more servers, for example, when CPU use is high, so your app can handle more users smoothly.
Terminal
aws autoscaling attach-scaling-policy --auto-scaling-group-name my-asg --policy-name cpu-scale-out --policy-arn arn:aws:autoscaling:us-east-1:123456789012:scalingPolicy:abcdef12-3456-7890-abcd-ef1234567890:autoScalingGroupName/my-asg:policyName/cpu-scale-out
Expected OutputExpected
No output (command runs silently)
--policy-name - Names the scaling policy
--policy-arn - Identifies the exact policy to attach
This command fetches CPU usage data for your server over one hour. It helps you see how busy your server was and decide if you need to change resources for better performance.
Terminal
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=i-0123456789abcdef0 --start-time 2024-06-01T00:00:00Z --end-time 2024-06-01T01:00:00Z --period 300 --statistics Average
Expected OutputExpected
{"Label":"CPUUtilization","Datapoints":[{"Timestamp":"2024-06-01T00:05:00Z","Average":45.0},{"Timestamp":"2024-06-01T00:10:00Z","Average":55.0}],"ResponseMetadata":{"RequestId":"abcd1234-5678-90ef-ghij-klmnopqrstuv"}}
--start-time - Sets the beginning of the time range for data
--end-time - Sets the end of the time range for data
--statistics - Chooses the type of data summary, here average CPU use
Key Concept

If you remember nothing else from this pattern, remember: monitor your system’s performance and adjust resources automatically to keep your app fast and efficient.

Common Mistakes
Setting the CPU threshold too high for alarms
You might miss early signs of overload and your app could slow down before you react.
Set a reasonable threshold like 70% so you get alerts before performance drops.
Not configuring auto-scaling limits properly
Your app might not scale up enough or could scale too much, wasting money or causing slowdowns.
Set min, max, and desired capacity based on expected traffic and budget.
Ignoring monitoring data after setup
You miss opportunities to improve performance or reduce costs by adjusting resources.
Regularly check CloudWatch metrics and adjust alarms and scaling policies as needed.
Summary
Create CloudWatch alarms to watch key performance metrics like CPU usage.
Set up auto-scaling groups to add or remove servers based on demand.
Attach scaling policies to automate resource changes when performance thresholds are met.
Use CloudWatch commands to review performance data and make informed adjustments.