SkillSprout
Chapter 7 · Lesson 4
Intermediate
6 min read

EC2 Performance, Placement Groups and Right-Sizing

Overview

Choosing and tuning EC2 is more than picking a size. You decide where instances sit relative to each other (placement groups), which family matches the workload (compute, memory, storage, accelerated), and how networking and storage attach (ENA, EFA, EBS-optimized). Resource tags and tools such as Compute Optimizer then help you find and fix under- and over-provisioned instances.

Placement is like seating guests at a wedding. A cluster group puts the team that needs to talk constantly at one table; a spread group puts critical guests at separate tables so one spilled drink cannot ruin everyone; a partition group gives each large family (like a Hadoop rack) its own block of tables.

SOA-C03 expects you to optimise compute using performance metrics, resource tags and AWS tools, and to implement placement groups and networking features correctly.

Key Concepts

  • Cluster placement group: instances packed in one AZ for lowest latency and highest throughput (HPC, tightly coupled); risk is correlated failure.
  • Spread placement group: each instance on distinct hardware, max 7 running instances per AZ per group, for small critical sets.
  • Partition placement group: instances in logical partitions on separate racks (up to 7 per AZ); suited to HDFS, Cassandra, Kafka.
  • Enhanced networking (ENA) gives higher bandwidth and lower latency; EFA adds OS-bypass for HPC and ML; instance size sets network limits.
  • Instance families: M (general), C (compute), R/X (memory), I/D (storage), P/G (GPU), T (burstable); Graviton (g suffix) often improves price/performance.
  • Compute Optimizer analyses CloudWatch metrics (and memory if the agent is installed) and recommends right-sizing for EC2, ASG, EBS, Lambda and ECS on Fargate.
  • Tags (cost allocation, environment, owner) drive automation, cost reports and tag-based Systems Manager targets; enforce with tag policies and AWS Config.
  • Detailed monitoring gives 1-minute metrics; install the CloudWatch agent for memory, disk and swap metrics that EC2 does not publish by default.

Detailed Notes

Placement group types

TypeSpans AZsLimitUse caseTrade-off
ClusterNo (single AZ)Capacity is requested togetherHPC, low-latency node-to-nodeWhole group at risk if hardware fails; launch all at once to avoid capacity errors
SpreadYes7 running instances per AZFew critical instances that must not share hardwareSmall scale
PartitionYes7 partitions per AZLarge distributed storesYou manage partition awareness
bash
aws ec2 create-placement-group --group-name hpc-cluster --strategy cluster
aws ec2 run-instances --image-id ami-0abc --instance-type c6in.8xlarge --count 4 \
  --placement GroupName=hpc-cluster --subnet-id subnet-0abc
aws ec2 create-placement-group --group-name kafka --strategy partition --partition-count 3

Rules to remember: you cannot merge placement groups, an instance can be moved into a group only while stopped (via modify-instance-placement), and a cluster group cannot span AZs. If a launch fails with InsufficientInstanceCapacity in a cluster group, stop and start all instances or relaunch together; using a single instance type helps.

Networking performance

FeatureBenefitCheck
ENAUp to 100+ Gbps on large Nitro instancesethtool -i eth0 shows driver ena; AMI flag enaSupport
EFALow-latency inter-node for MPI/NCCLRequires supported instance, same cluster placement group
Jumbo frames (MTU 9001)Fewer packets inside a VPCNot across internet or VPN
ENA ExpressHigher single-flow bandwidthWithin same AZ
Per-flow limitA single flow is capped (about 5 Gbps outside a placement group, 10 Gbps inside a cluster group)Use multiple flows

Metrics such as NetworkPacketsIn/Out are in CloudWatch; ENA allowance-exceeded counters (bw_in_allowance_exceeded, pps_allowance_exceeded, conntrack_allowance_exceeded) appear in ethtool and the CloudWatch agent's ethtool plugin, proving the instance hit its network limits.

Storage and EBS attachment

  • Use EBS-optimized instances (default on current generation) so storage traffic does not compete with network traffic.
  • Instance-level EBS bandwidth and IOPS limits can bottleneck even a fast io2 volume; check the instance type's EBS limits.
  • Instance store volumes give very high local IOPS but are ephemeral.

Right-sizing workflow

StepTool
Collect memory and disk metricsCloudWatch agent (mem_used_percent, disk_used_percent)
Identify idle and over-provisionedCompute Optimizer findings: Under-provisioned, Over-provisioned, Optimized
Validate trendsCloudWatch graphs for 2+ weeks, including peaks
ChangeResize (stop/start) or change family (Graviton) via launch template and ASG instance refresh
Track costCost Explorer grouped by cost-allocation tags
bash
aws compute-optimizer get-ec2-instance-recommendations --instance-arns arn:aws:ec2:us-east-1:111122223333:instance/i-0abc \
  --query "instanceRecommendations[0].recommendationOptions[0].[instanceType,performanceRisk]"
aws ec2 create-tags --resources i-0abc --tags Key=Environment,Value=prod Key=Owner,Value=payments

Tag-driven operations

Tags let Systems Manager target by tag:Patch Group, backups select resources via tag-based AWS Backup assignments, and automation stop non-production instances at night. Activate cost allocation tags in Billing to use them in Cost Explorer, and use tag policies in Organizations to standardise keys and values.

Real World Example

Scenario – slow HPC job. A research team runs a tightly coupled simulation on 16 c6in instances spread over three AZs. Job time is long and CloudWatch shows high pps_allowance_exceeded plus inter-node latency of several hundred microseconds.

The operator recreates the fleet in a cluster placement group in a single AZ with EFA enabled and uses a single instance type launched in one request. Job time drops 40%. For their database nodes (a three-node Cassandra ring) they use a partition placement group so a rack failure affects only one partition. Compute Optimizer later flags some analysis nodes as over-provisioned, and tag-based scheduling shuts non-prod nodes down overnight.

Architecture Diagram

Placement strategies
Architecture
Region
AZ-a: Cluster group
Node 1EFA
Node 2EFA
Spread / Partition
Partition 1
Partition 2
CloudWatch + Compute Optimizer
  1. 1Classify the workload: tightly coupled, small critical set or large distributed store.
  2. 2Create the matching placement group and launch instances together.
  3. 3Enable ENA or EFA and choose an instance size whose network and EBS limits fit.
  4. 4Install the CloudWatch agent to collect memory, disk and network allowance metrics.
  5. 5Review Compute Optimizer recommendations and right-size using tags and launch templates.

Best Practices

  • ✓Use cluster groups only for latency-sensitive HPC and launch all instances at once with one instance type.
  • ✓Use spread or partition groups, ideally across AZs, for fault isolation of critical or distributed workloads.
  • ✓Install the CloudWatch agent so Compute Optimizer and alarms see memory and disk, not only CPU.
  • ✓Standardise tags with tag policies and activate cost-allocation tags.
  • ✓Evaluate Graviton families and re-size from data at least quarterly.

Common Interview Questions

Exam Tips

SOA-C03 focus

  • Lowest latency between instances -> cluster placement group; avoid correlated hardware failure -> spread (small) or partition (large).
  • Memory metrics are not native EC2 metrics; use the CloudWatch agent.
  • Right-sizing recommendations -> Compute Optimizer; cost reports by team -> cost allocation tags.
  • An existing instance can join a placement group only after being stopped.

Chapter quiz

Containers, Caching and Database Scaling · 10 questions

  1. 1.An ECS Fargate service runs in private subnets with no NAT gateway. New tasks stop with CannotPullContainerError. What is the MOST cost-effective fix?

  2. 2.A container in an ECS task must read objects from an S3 bucket. Which approach follows best practice?

  3. 3.A relational product catalog is read thousands of times a second with the same keys, and the RDS CPU is saturated. Which change reduces load with the LEAST application redesign effort for an in-memory approach that must also survive a node failure?

  4. 4.A DynamoDB application needs microsecond read latency for repeated GetItem calls without redesigning the data model. Which service is appropriate?

  5. 5.A DynamoDB table shows ThrottledRequests while ConsumedWriteCapacityUnits is only 30% of provisioned capacity. Which is the MOST likely cause?

  6. 6.Thousands of concurrent Lambda invocations cause 'too many connections' errors on an RDS PostgreSQL instance. What should the operator implement?

  7. 7.A development Aurora MySQL cluster is idle most nights and used unpredictably during the day. The team wants to minimise cost without manual resizing. Which option fits?

  8. 8.A distributed database such as Cassandra runs on EC2 across racks, and a rack failure must affect only part of the cluster. Which placement strategy fits?

  9. 9.Compute Optimizer reports an EC2 instance as over-provisioned, but it only had CPU data. What gives it a more accurate memory-based recommendation?

  10. 10.A Redis-based cache shows steadily rising Evictions and a falling hit ratio during peak hours. What is the BEST remediation?

0 of 10 answered

Finished this lesson?

0 of 46 lessons done · 0% of the course