Monitoring and Optimization · Topic 5 of 6
Compute Performance Optimization
Right-size EC2 with Compute Optimizer, choose instance families, understand burstable credits and placement groups, and tune Lambda memory and concurrency.
- 4 min
- Match the family to the bottleneck: C for CPU, R or X for memory, I for local storage speed, P or G for GPU.
- Changing an EBS backed instance type needs a stop and start.
- T instances use CPU credits, so watch
CPUCreditBalance, and unlimited mode allows bursting at extra cost.
What it is
Performance optimization for compute means matching the size and type of the resource to the actual workload. A resource that is too small is slow, and one that is too large wastes money.
On the exam you read metrics, decide whether the bottleneck is CPU, memory, disk or network, and pick the smallest change that fixes it.
How it works
Instance families
Choose the family by the shape of the workload.
| Family | Letter examples | Best for |
|---|---|---|
| General purpose | M, T | Balanced web and application servers |
| Compute optimized | C | CPU bound work such as batch processing and encoding |
| Memory optimized | R, X | Large in memory databases and caches |
| Storage optimized | I, D | High disk throughput or very low latency local storage |
| Accelerated computing | P, G | GPU (graphics processing unit) and machine learning work |
To change the instance type of an EBS backed instance, stop it, change the type, then start it. The instance gets a new public IPv4 address unless you use an Elastic IP address.
Burstable instances
T family instances earn CPU credits while idle and spend them when busy. When credits run out, the instance is throttled to its baseline.
Watch the CPUCreditBalance metric. If it keeps hitting zero, either use a larger or different family, or turn on unlimited mode, which allows bursting beyond credits at extra charge.
AWS Compute Optimizer
Compute Optimizer analyses CloudWatch metrics and recommends better EC2 instance types, Auto Scaling group settings, EBS volumes and Lambda memory sizes. It classifies a resource as under provisioned, over provisioned or optimized.
You must opt in to the service. It only sees memory use if the CloudWatch agent publishes it, so install the agent if memory matters.
Network and placement
Enhanced networking with the Elastic Network Adapter (ENA) gives higher bandwidth and lower latency on supported instance types. Choose an instance type that is EBS optimized when storage traffic is heavy.
A placement group controls how instances are placed on hardware.
| Type | Behaviour | Use for |
|---|---|---|
| Cluster | Packs instances close together in one Availability Zone | Low latency, high throughput between nodes |
| Spread | Puts each instance on distinct hardware | Small number of critical instances |
| Partition | Groups instances on separate racks in partitions | Large distributed systems such as Hadoop or Cassandra |
Auto Scaling as optimization
Scaling out lets a fleet match demand, which is often better than one very large instance. The scaling chapter covers policies in detail.
Lambda tuning
For AWS Lambda you choose the memory size, and CPU power scales with it. More memory can shorten run time enough to lower cost, so test several values.
Cold starts happen when a new execution environment must start. Provisioned concurrency keeps environments ready to reduce that delay. Reserved concurrency sets the maximum, and also guarantees capacity for a function, which protects other functions and downstream resources.
# AWS CLI: keep 10 pre warmed environments for an alias
aws lambda put-provisioned-concurrency-config \
--function-name orders --qualifier live \
--provisioned-concurrent-executions 10
Low CPU does not always mean over provisioned. Check memory (needs the agent), network and disk too before you downsize.
What to remember for the exam
- Match the family to the bottleneck: C for CPU, R or X for memory, I for local storage speed, P or G for GPU.
- Changing an EBS backed instance type needs a stop and start.
- T instances use CPU credits, so watch
CPUCreditBalance, and unlimited mode allows bursting at extra cost. - Compute Optimizer needs opt in, and memory recommendations need the CloudWatch agent.
- Cluster placement groups give low latency inside one Availability Zone, and spread groups reduce correlated failure.
- Lambda memory setting also scales CPU, so tune memory to tune speed.
- Provisioned concurrency reduces cold starts, and reserved concurrency limits and guarantees capacity.
- Prefer scaling out with Auto Scaling over one very large instance when the workload allows.
Common mistakes
Downsizing based on CPU only. A memory bound application may show low CPU while it is struggling. Look at all resources.
Using a cluster group for resilience. Cluster groups favour speed, not fault tolerance, since the instances sit close together.
Ignoring credits on T instances. A sudden slow down after a period of busy work is often exhausted credits.
Confusing reserved and provisioned concurrency. Reserved sets capacity and a ceiling. Provisioned keeps environments warm and costs extra.
Changing the type of a running instance. It must be stopped first, which means downtime unless the workload is behind a load balancer.
Instance store data is lost when an instance is stopped, so do not stop and resize an instance that keeps important data only on instance store volumes.
Check yourself
Work through these.
A T instance is slow after a long busy period and CPUCreditBalance is zero. What are two fixes?
Move to a larger or non burstable type, or enable unlimited mode so it can burst beyond its credits.
Which placement group gives the lowest latency between nodes?
A cluster placement group, within a single Availability Zone.
How does increasing Lambda memory affect performance?
It also increases the CPU share, so CPU bound functions can finish faster.
Topic 5 of 6 in Monitoring and Optimization
Test yourself on Monitoring and Optimization
The full AWS SOA-C03 question bank has 850 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.