Performance and cost optimisation for resilient systems
Right-size auto-scaled fleets, move .NET services to Graviton, use Spot and Savings Plans safely, and put a price on idle disaster-recovery capacity with a small C# cost model so resilience spending is a decision, not a surprise.
Assumes: .NET 10 LTS · AWS CDK v2 (C#) · Terraform AWS provider 6.x · AWS CLI v2 · Region us-east-1. Verified against official sources on 2026-11-18.
Learning objectives
By the end of this lesson you can:
- Explain why resilience costs money in three ways: extra capacity, extra copies of data, and extra operations, and estimate each for the four DR strategies.
- Right-size an auto-scaled ECS or EC2 fleet using measured utilisation and tune target tracking so it neither starves nor wastes.
- Move a .NET 10 service to Graviton (Arm64) and test it before switching.
- Choose between On-Demand, Spot, Savings Plans and Reserved capacity for each tier of a resilient workload.
- Build and run a C# cost model that compares DR strategies against an impact tolerance and the cost of downtime.
Prerequisites
- Scaling .NET apps for the scaling mechanisms
- Pricing models and Free tier and billing
- The auto scaling and DR strategy lessons earlier in this module (see the module overview)
- Tools: .NET 10 SDK. The IaC is optional to deploy.
Why this matters in banking
A resilient design that nobody can afford does not get built, and one that is quietly under-provisioned fails the first time it is tested. Harbourline's board asks two questions: "What does a second Region cost us per month?" and "What does an hour of payment downtime cost us?" If engineering cannot answer both with numbers, the argument is settled by whoever shouts loudest.
The honest answer usually mixes strategies, and the savings from optimisation (Graviton, right-sizing, Savings Plans) are what pay for the extra resilience. The goal is not the cheapest system. It is the cheapest system that stays within its impact tolerance, with the idle DR capacity visible on the bill and justified by a number.
The idea in plain language
There are two dials:
- Performance efficiency: getting the work done with the right amount of compute, at the right latency. Too little capacity means slow requests and failures at peak. Too much means money wasted.
- Cost optimisation: paying the lowest price for capacity you really need, by choosing the right size, architecture and purchase model.
Resilience adds a third, awkward fact: idle capacity is the point. A warm standby that does nothing for 364 days is not waste if it saves the bank on day 365. What is waste is idle capacity nobody has tied to an RTO.
Analogy: A bank keeps spare tellers on call during the lunchtime rush (auto scaling), negotiates a fixed-rate contract for the permanent staff (Savings Plans), hires temps for overflow work that can be dropped at short notice (Spot), and pays a retainer for a second branch to be ready (DR). Each has a price and a purpose, and the retainer is justified by the cost of the branch being closed.
What problem each lever solves
| Lever | What it changes | Typical effect | Sharp edges |
|---|---|---|---|
| Right-sizing | vCPU and memory per task or instance | Cuts the waste of over-provisioning | Measure peaks and memory, not just average CPU; keep headroom for AZ loss |
| Target tracking tuning | When the fleet scales out and in | Fewer scaling oscillations, lower cost at night | A target set too high causes slow responses before scale-out completes |
| Graviton (Arm64) | CPU architecture | Often better price-performance than x86 ⚠ VERIFY current figures for your instance family | Need Arm64 container images and native dependencies |
| Fargate Spot / EC2 Spot | Interruptible capacity at a discount | Large discount for tolerant workloads ⚠ VERIFY current range | Interrupted with short notice; never for the only copy of a critical service |
| Compute Savings Plans | Commitment to an hourly spend for 1 or 3 years | Discount across EC2, Fargate and Lambda usage within the commitment ⚠ VERIFY coverage | A commitment you pay even if usage drops; start with the stable baseline |
| Reserved Instances / reserved nodes | Commitment for RDS, ElastiCache, OpenSearch and similar | Discount on databases that run all the time | Tied to engine, family and Region (flexibility varies) ⚠ VERIFY |
| Aurora Serverless v2 | Database capacity in ACUs, scaled automatically | Pay for what the database uses | Has a minimum ACU, and a very low minimum can lengthen scale-up in a spike ⚠ VERIFY |
| Caching | Fewer calls to expensive back ends | Smaller database | See the caching lesson |
| Storage lifecycle | Moving old data to cheaper classes | Lower storage cost | Retrieval cost and minimum durations |
What does DR capacity cost?
Think of each strategy as a fraction of production's monthly run cost that you pay all the time (the standing cost), plus the cost of scaling up during a real event.
| Strategy | What runs in the DR Region all the time | Illustrative standing cost as a share of production | Typical recovery time |
|---|---|---|---|
| Backup and restore | Backup copies only | A few percent (storage and transfer) | Hours |
| Pilot light | Database replica, minimal core services, images and config | Roughly 10 to 25 percent | Tens of minutes to hours |
| Warm standby | A scaled-down but running copy of everything | Roughly 30 to 60 percent | Minutes to tens of minutes |
| Multi-site active-active | Full capacity serving traffic | 100 percent or more, plus data synchronisation | Seconds to minutes |
The percentages are illustrative planning ranges, not AWS figures. Your real numbers come from your own bill and the AWS Pricing Calculator. The C# model later in this lesson lets you replace them with your own.
Hidden costs of multi-Region design: cross-Region data transfer (replication, backup copies), duplicated managed services (NAT gateways, load balancers, WAF, KMS keys), duplicated observability (logs, metrics, traces in both Regions), and the people cost of running drills. Ask for these on the estimate.
Microsoft / Azure comparison
| You know (Microsoft/Azure) | AWS equivalent | What's different |
|---|---|---|
| Azure Reservations and Savings Plans for compute | Compute Savings Plans, EC2 Instance Savings Plans, Reserved Instances | Compute Savings Plans cover Fargate and Lambda as well as EC2 |
| Azure Spot VMs | EC2 Spot, Fargate Spot | Spot interruption arrives as a two-minute notice for EC2; Fargate Spot sends SIGTERM first ⚠ VERIFY |
| Azure Advisor right-sizing | AWS Compute Optimizer, Cost Explorer rightsizing | Compute Optimizer needs opt-in and several days of metrics |
| Azure Cost Management budgets | AWS Budgets with cost allocation tags | Activate tags for cost allocation before they appear in reports |
| Ampere Arm VMs on Azure | Graviton | .NET 10 supports linux-arm64 as a first-class target |
| Azure Hybrid Benefit for SQL Server licences | License-included RDS for SQL Server, or bring your own licence in limited cases | Check licensing rules with your licensing team ⚠ VERIFY |
Architecture
Security-boundary view: cost tooling needs read access to billing data, which reveals your architecture; restrict Cost Explorer and Budgets to finance and platform roles through IAM. Cost allocation tags must never contain personal data.
Step-by-step implementation
Tag everything before you optimise anything
You cannot optimise what you cannot attribute. Use the mandatory tags (Project, Lab or Service, Environment, Owner) plus a Tier tag (critical, supporting, batch). Activate the tags for cost allocation in the Billing console. Tags appear in Cost Explorer after activation, not retroactively.
Measure utilisation over a full business cycle
Collect CPU, memory, request rate and p95/p99 latency for at least two weeks including month-end. Peaks (payroll, payday, tax deadlines) set the real ceiling.
Right-size from evidence
Run AWS Compute Optimizer or inspect CloudWatch Container Insights. Keep enough headroom that the loss of one Availability Zone (about a third of the fleet in a three-AZ design) still leaves you under 80% of capacity, because that is the failure you designed for.
Tune the scaling policy
Target tracking on average CPU at 55 to 65 percent is a sensible start for a stateless API. Set a quicker scale-out than scale-in cooldown. If the service is memory-bound or queue-driven, scale on that metric instead (requests per target, queue depth per task).
Try Graviton
Build a multi-architecture image, run the tests and a load test against an Arm64 task, compare cost and latency, then roll out gradually.
Buy commitments last
Commit only to the stable baseline after right-sizing and architecture changes; a Savings Plan sized to today's waste is a commitment to waste.
Price the DR strategy and review it
Run the cost model with your real numbers and put the output in the architecture decision record, with a yearly review date.
AWS Console instructions
- Cost Explorer: Console → Billing and Cost Management → Cost Explorer → group by Tag (
ServiceorTier) and Region to see the DR Region's standing cost. - Cost allocation tags: Billing and Cost Management → Cost allocation tags → select tags → Activate.
- Budgets: Billing and Cost Management → Budgets → Create budget → Cost budget, filter by tag, add email alerts at 80% and 100% of forecast.
- Compute Optimizer: Console → AWS Compute Optimizer → Get started (opt in) → review ECS services on Fargate, EC2 instances and Lambda functions. Recommendations appear after enough metrics have accumulated ⚠ VERIFY the required history.
- Savings Plans: Billing and Cost Management → Savings Plans → Recommendations. Do not purchase in a sandbox account.
AWS CLI
# Last month's cost grouped by the Service tag (tag must be activated for cost allocation first).
aws ce get-cost-and-usage \
--time-period Start=2026-10-01,End=2026-11-01 --granularity MONTHLY \
--metrics UnblendedCost --group-by Type=TAG,Key=Service \
--profile learn-sandbox
# The same cost split by Region shows what the DR Region costs while idle.
aws ce get-cost-and-usage \
--time-period Start=2026-10-01,End=2026-11-01 --granularity MONTHLY \
--metrics UnblendedCost --group-by Type=DIMENSION,Key=REGION \
--profile learn-sandbox
# Compute Optimizer recommendations for ECS services on Fargate (after opt-in).
aws compute-optimizer get-ecs-service-recommendations \
--query "ecsServiceRecommendations[].{Service:serviceArn,Finding:finding}" \
--region us-east-1 --profile learn-sandbox
# Average CPU and memory of an ECS service over a week (CloudWatch).
aws cloudwatch get-metric-statistics --namespace AWS/ECS --metric-name CPUUtilization \
--dimensions Name=ClusterName,Value=hl-m12-cluster Name=ServiceName,Value=hl-m12-accounts-api \
--start-time "$(date -u -d '7 days ago' +%FT%TZ)" --end-time "$(date -u +%FT%TZ)" \
--period 3600 --statistics Average Maximum --region us-east-1 --profile learn-sandbox
# Build a multi-architecture image locally and push it (needs docker buildx).
docker buildx build --platform linux/amd64,linux/arm64 \
-t 111122223333.dkr.ecr.us-east-1.amazonaws.com/hl-m12-accounts-api:1.0.0 --push .111122223333 is a placeholder account ID. The ce API has a small charge per request ⚠ VERIFY, so avoid calling it in loops.
Infrastructure as Code
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.ECS.Patterns;
using Amazon.CDK.AWS.Budgets;
using Constructs;
namespace Harbourline.Ha.Infra;
public sealed class OptimisedServiceStack : Stack
{
public OptimisedServiceStack(Construct scope, string id, IVpc vpc, IStackProps props)
: base(scope, id, props)
{
var cluster = new Cluster(this, "Cluster", new ClusterProps
{
ClusterName = "hl-m12-cluster",
Vpc = vpc,
EnableFargateCapacityProviders = true
});
var taskDef = new FargateTaskDefinition(this, "Task", new FargateTaskDefinitionProps
{
Cpu = 512,
MemoryLimitMiB = 1024,
RuntimePlatform = new RuntimePlatform
{
CpuArchitecture = CpuArchitecture.ARM64, // Graviton
OperatingSystemFamily = OperatingSystemFamily.LINUX
}
});
taskDef.AddContainer("api", new ContainerDefinitionOptions
{
Image = ContainerImage.FromRegistry("public.ecr.aws/docker/library/nginx:stable"), // placeholder
PortMappings = new[] { new PortMapping { ContainerPort = 80 } },
Logging = LogDrivers.AwsLogs(new AwsLogDriverProps { StreamPrefix = "api" })
});
var service = new ApplicationLoadBalancedFargateService(this, "Service",
new ApplicationLoadBalancedFargateServiceProps
{
Cluster = cluster,
TaskDefinition = taskDef,
DesiredCount = 3, // one per AZ at minimum
MinHealthyPercent = 100,
// Baseline on regular Fargate, burst on Spot. Never put the only copy on Spot.
CapacityProviderStrategies = new[]
{
new CapacityProviderStrategy { CapacityProvider = "FARGATE", Base = 3, Weight = 1 },
new CapacityProviderStrategy { CapacityProvider = "FARGATE_SPOT", Weight = 3 }
}
});
var scaling = service.Service.AutoScaleTaskCount(new EnableScalingProps
{
MinCapacity = 3,
MaxCapacity = 12
});
scaling.ScaleOnCpuUtilization("Cpu", new CpuUtilizationScalingProps
{
TargetUtilizationPercent = 60,
ScaleOutCooldown = Duration.Seconds(60),
ScaleInCooldown = Duration.Minutes(5)
});
// Budget with a tag filter and alerts at 80 percent actual and 100 percent forecast.
_ = new CfnBudget(this, "Budget", new CfnBudgetProps
{
Budget = new CfnBudget.BudgetDataProperty
{
BudgetName = "hl-m12-lab",
BudgetType = "COST",
TimeUnit = "MONTHLY",
BudgetLimit = new CfnBudget.SpendProperty { Amount = 20, Unit = "USD" },
CostFilters = new Dictionary<string, object> { ["TagKeyValue"] = new[] { "user:Project$cea-lab" } }
},
NotificationsWithSubscribers = new[]
{
new CfnBudget.NotificationWithSubscribersProperty
{
Notification = new CfnBudget.NotificationProperty
{
NotificationType = "ACTUAL", ComparisonOperator = "GREATER_THAN",
Threshold = 80, ThresholdType = "PERCENTAGE"
},
Subscribers = new[]
{
new CfnBudget.SubscriberProperty { SubscriptionType = "EMAIL", Address = "you@example.com" }
}
}
}
});
Amazon.CDK.Tags.Of(this).Add("Project", "cea-lab");
Amazon.CDK.Tags.Of(this).Add("Lab", "m12-cost");
Amazon.CDK.Tags.Of(this).Add("Environment", "learn");
}
}The container image is a placeholder; use your own Arm64 image. The budget filter format for tags (user:Key$Value) and the notification shape should be checked against the AWS Budgets documentation ⚠ VERIFY.
Complete code
A cost model you can run without an AWS account. It turns the DR table into numbers and compares strategies with the expected cost of downtime.
namespace Harbourline.Ha.CostModel;
public sealed record DrStrategy(
string Name,
double StandingCostShare, // share of production monthly cost paid all the time
double ExpectedRecoveryHours, // realistic recovery time in a regional event
double ExpectedDataLossMinutes);
public sealed record Scenario(
decimal ProductionMonthlyCost, // GBP
decimal DowntimeCostPerHour, // lost fees, penalties, reputation proxy
decimal DataLossCostPerMinute, // reconciliation and remediation cost per minute of lost data
double RegionalEventsPerYear); // expected frequency, for example 0.1 means once in ten years
public sealed record StrategyResult(
string Name,
decimal StandingCostPerYear,
decimal ExpectedLossPerYear,
decimal TotalPerYear,
double RecoveryHours);
public static class DrCostModel
{
public static IReadOnlyList<DrStrategy> DefaultStrategies { get; } =
[
new("Backup and restore", 0.03, 12.0, 240),
new("Pilot light", 0.15, 2.0, 5),
new("Warm standby", 0.45, 0.5, 1),
new("Multi-site active-active", 1.10, 0.05, 0.2)
];
public static IReadOnlyList<StrategyResult> Compare(Scenario s, IEnumerable<DrStrategy> strategies)
{
var results = new List<StrategyResult>();
foreach (var d in strategies)
{
var standing = s.ProductionMonthlyCost * (decimal)d.StandingCostShare * 12m;
var perEventLoss =
s.DowntimeCostPerHour * (decimal)d.ExpectedRecoveryHours +
s.DataLossCostPerMinute * (decimal)d.ExpectedDataLossMinutes;
var expectedLoss = perEventLoss * (decimal)s.RegionalEventsPerYear;
results.Add(new StrategyResult(d.Name,
Math.Round(standing, 0), Math.Round(expectedLoss, 0),
Math.Round(standing + expectedLoss, 0), d.ExpectedRecoveryHours));
}
return results;
}
/// <summary>The cheapest strategy that still meets the impact tolerance (hours). Null if none does.</summary>
public static StrategyResult? Cheapest(IEnumerable<StrategyResult> results, double toleranceHours) =>
results.Where(r => r.RecoveryHours <= toleranceHours)
.OrderBy(r => r.TotalPerYear)
.FirstOrDefault();
}using Harbourline.Ha.CostModel;
// Fictional figures for Harbourline's online banking service.
var scenario = new Scenario(
ProductionMonthlyCost: 40_000m,
DowntimeCostPerHour: 250_000m,
DataLossCostPerMinute: 2_000m,
RegionalEventsPerYear: 0.1);
var results = DrCostModel.Compare(scenario, DrCostModel.DefaultStrategies);
Console.WriteLine($"{"Strategy",-28} {"Standing/yr",12} {"Exp. loss/yr",13} {"Total/yr",10} {"RTO h",6}");
foreach (var r in results)
Console.WriteLine($"{r.Name,-28} {r.StandingCostPerYear,12:N0} {r.ExpectedLossPerYear,13:N0} {r.TotalPerYear,10:N0} {r.RecoveryHours,6:F2}");
const double impactToleranceHours = 1.0; // the board's tolerance for this service
var pick = DrCostModel.Cheapest(results, impactToleranceHours);
Console.WriteLine(pick is null
? "No strategy meets the tolerance: change the design or the tolerance."
: $"Cheapest option within {impactToleranceHours} h tolerance: {pick.Name} ({pick.TotalPerYear:N0} per year).");Sample output (the numbers are illustrative; yours will differ):
Strategy Standing/yr Exp. loss/yr Total/yr RTO h
Backup and restore 14,400 348,000 362,400 12.00
Pilot light 72,000 51,000 123,000 2.00
Warm standby 216,000 12,700 228,700 0.50
Multi-site active-active 528,000 1,290 529,290 0.05
Cheapest option within 1 h tolerance: Warm standby (228,700 per year).The pattern to notice: the cheapest in total (pilot light) does not meet the 1-hour tolerance, so the cheapest compliant choice is warm standby. Tolerance, not cost alone, selects the strategy.
Code explained line by line
DrStrategyholds three assumptions per strategy: standing cost share, recovery hours and data-loss minutes. Keeping them as data lets you replace the illustrative numbers with your own measured values from drills.Scenarioholds the business inputs: production cost, cost of an hour of downtime, cost per minute of lost data, and event frequency. These come from finance and risk, not from engineering.Comparecomputes the standing cost per year (monthly cost times share times twelve) and the expected loss per year (loss per event times events per year).- Using
decimalfor money follows the project's convention; the shares and frequencies aredoublebecause they are ratios, not money. Cheapestfilters strategies by the impact tolerance first, then orders by total cost. This reflects the regulatory logic: first meet the tolerance, then minimise cost.Program.csformats a table and prints the decision. Everything is fictional and local; it is cheap to run in a unit test.
Security considerations
⚠ Learning shortcut — not for production
The CDK and Terraform examples use a public nginx placeholder image, a placeholder email address and the sandbox's default roles. In production, use images from your private ECR with scanning on, a distribution list for budget alerts, and least-privilege roles for the cost tooling.
- Spot and security: Spot tasks still run your code with the same task role. Keep secrets out of image layers, and handle
SIGTERMto stop accepting requests and finish in-flight payments cleanly. - Graviton and supply chain: rebuild and scan the Arm64 image; native dependencies may bring different vulnerabilities. Sign the multi-architecture manifest.
- Cost data is sensitive: it reveals architecture and growth. Restrict access, and do not embed account IDs or customer names in tag values.
- Savings commitments and audit: a commitment is a financial obligation. Approvals should follow your procurement controls, not an engineer's initiative.
- Optimisation must not remove controls: never cut logging retention, encryption or the DR replica to save money without risk sign-off. Operational resilience is a regulatory expectation, and the cost model is how you justify keeping it.
Banking use case
Harbourline's online banking tier review:
| Component | Change | Result |
|---|---|---|
| Accounts API (ECS) | Right-size 1 vCPU to 0.5 vCPU after measuring 22% peak CPU; move to Arm64 | Lower per-task cost; load test shows same p99 ⚠ measure in your own environment |
| Overnight statement jobs | Fargate Spot with retry | Large discount; jobs are idempotent |
| Aurora ledger | Reserved instances for the writer and one reader; Serverless v2 for reporting replicas | Lower steady cost, flexible burst |
| DR Region | Warm standby at about 45% of production cost for the ledger and API; pilot light for reporting | Meets 30-minute RTO for payments; cost line approved by the board with the cost model attached |
| Dev and test environments | Scheduled stop outside working hours | Removes idle spend with no resilience impact |
The key discipline: the DR Region's cost appears under its own tag in Cost Explorer so it is visible, reviewed yearly, and defended with the cost model rather than quietly cut.
Common mistakes
- Right-sizing on average CPU. Averages hide the payday peak. Use peak percentiles and include memory.
- Right-sizing to 100% of the three-AZ fleet. Losing one AZ then pushes the survivors past capacity. Size for N minus one zone.
- Savings Plans bought before optimisation. You commit to today's waste.
- Putting every task on Spot. An interruption wave can remove all capacity at once. Keep a regular baseline.
- Forgetting cross-Region data transfer. Replication and copies are billed and appear as "data transfer" lines that nobody owns.
- Judging DR on standing cost alone. The cheapest option may violate the tolerance. Compare expected loss, and meet the tolerance first.
- Optimising away the drill. The cost of testing is small compared with discovering a broken failover in a real event.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Arm64 task stops with exec format error | Image built for x86 only | Build a multi-architecture image or an Arm64 image with docker buildx |
| Native library fails on Arm64 | Dependency has no linux-arm64 build | Update the package, or keep that service on x86 and document why |
| Service oscillates between 3 and 9 tasks | Scale-in cooldown too short or target too tight | Increase scale_in_cooldown, widen the target, or scale on a smoother metric |
| Latency spikes before scale-out completes | Target utilisation too high or slow startup | Lower the target to 50 to 55 percent, use warm pools or faster images, pre-scale for known peaks |
| Cost Explorer shows no tag data | Tag not activated for cost allocation | Activate the tag in the Billing console; data appears going forward |
| Spot tasks vanish and service degrades | No on-demand base | Use a base on the regular capacity provider |
| Budget alert never fires | Filter format wrong or tag not activated | Check the TagKeyValue filter syntax and tag activation ⚠ VERIFY |
| Compute Optimizer shows no recommendations | Not opted in, or too little history | Opt in and wait for metrics to accumulate |
Cost and cleanup
Cost: free. The C# cost model runs locally. The IaC is optional: an ECS Fargate service with an ALB, if deployed, costs a few cents to a few dollars per day depending on size ⚠ VERIFY with the AWS Pricing Calculator; deploy-and-destroy within the hour. Do not buy Savings Plans or reservations in a learning account: they are commitments that cannot be cancelled.
# If you deployed the CDK stack:
cdk destroy --all --profile learn-sandbox
# Or Terraform:
terraform destroy
# Delete the budget (it is free, but tidy).
aws budgets delete-budget --account-id 111122223333 --budget-name hl-m12-lab --profile learn-sandbox
# Verify nothing tagged Project=cea-lab remains.
aws resourcegroupstaggingapi get-resources --tag-filters Key=Project,Values=cea-lab \
--region us-east-1 --profile learn-sandbox --query "ResourceTagMappingList[].ResourceARN"Exercises
- 🟢 Guided: Run the cost model with the sample numbers, then change
RegionalEventsPerYearfrom 0.1 to 0.02 andDowntimeCostPerHourto 50,000. Record which strategy becomes the cheapest in total, and which still meets a one-hour tolerance. - 🟡 Challenge: Add a fifth strategy ("Pilot light with automated scale-up", standing share 0.18, recovery 1.0 hours, data loss 1 minute) and write xUnit v3 tests for
CompareandCheapest, including the case where no strategy meets the tolerance. - 🔴 Live problem: Finance asks you to cut the DR Region bill by 40 percent "because it never runs". Investigate what you would look at, which savings are safe (idle test environments, right-sizing, reserved baseline, log retention), which are not, and write the one-page reply with numbers from the model.
Assignment
Write a cost and performance review of one Harbourline service: current monthly cost by tag and Region, measured peak and p99 utilisation, three optimisation proposals with expected savings, and a DR cost table produced by the cost model with your own inputs. Put it in your portfolio repository.
Solutions
With a lower event frequency and a lower downtime cost, the expected-loss column shrinks, so the cheaper strategies (backup and restore or pilot light) become cheaper in total. But a one-hour tolerance still excludes any strategy whose recovery time exceeds one hour, so warm standby remains the cheapest compliant choice. This shows why tolerance is the filter and cost the tiebreaker: lowering the loss estimate does not change what the regulator expects you to stay within.
Add the strategy to DefaultStrategies (or pass it in a test list). Tests: Compare for one strategy with known inputs returns standing equal to monthly cost times share times 12; expected loss equals (downtime cost times hours plus data-loss cost times minutes) times frequency; Cheapest with a tolerance of 0.01 hours returns null; with a tolerance of 24 returns the lowest total. Avoid floating-point comparisons for money by asserting on decimal results that have been rounded by Compare.
Knowledge check
Answer: The failure you design for is an AZ outage. In a three-AZ fleet, losing one zone removes about a third of the capacity, so the remaining tasks must absorb the load without exceeding safe utilisation. Sizing to 100% of the full fleet would make the surviving zones overload.
Answer: After right-sizing and architecture changes, for the stable baseline of usage. Committing before optimisation locks in waste.
Answer: Interruptible, idempotent, retry-friendly work such as batch jobs and extra burst capacity. Not the only copy of a critical service; keep a regular on-demand baseline.
Answer: The strategy must first meet the impact tolerance (RTO and RPO). Among compliant strategies you pick the lowest total cost, including expected loss. Cheaper options that recover too slowly are rejected.
Answer: That the container image and all native dependencies have linux-arm64 builds, that tests and load tests pass on Arm64, and that you can roll back. Then compare price and latency with the x86 baseline.
Interview questions
- How would you reduce the cost of a resilient system without lowering resilience? Right-size from peaks with N-1 AZ headroom, move to Graviton, use Spot only for non-critical burst, commit Savings Plans on the baseline, schedule non-production off-hours, and tune log retention.
- How do you explain the cost of DR to a board? With a model: standing cost per strategy, expected loss from downtime and data loss, the impact tolerance as a constraint, and the decision record with a review date.
- What is the danger of scaling on average CPU? It lags and hides peaks, and may not reflect the real bottleneck (memory, connections, queue depth).
- How do you attribute DR cost? Cost allocation tags and a Region split in Cost Explorer, with the DR Region's line reviewed yearly.
Certification practice
A bank runs an always-on ECS Fargate API at stable utilisation and nightly idempotent batch jobs on Fargate. It wants to lower cost without adding risk to the API. Which combination is best?
A. Fargate Spot for the API and the batch jobs. B. A Compute Savings Plan sized to the API's steady baseline, and Fargate Spot for the batch jobs. C. Reserved Instances for Fargate tasks. D. Move the API to a single large EC2 instance.
Answer: B. The stable API usage suits a commitment; idempotent batch jobs tolerate interruption on Spot. A puts the API at risk of interruption. C is not how Fargate is discounted. D removes the multi-AZ resilience.
A team wants the lowest-cost DR design that still lets them restore a payments service within 30 minutes after a Region failure. Which strategy fits?
A. Backup and restore. B. Pilot light with a replicated database and automation to start the compute tier. C. Warm standby or multi-site, depending on the real test results. D. No DR; rely on Multi-AZ.
Answer: C. A 30-minute RTO usually needs the compute tier already running at reduced scale (warm standby) unless measured drills prove pilot light can meet it. A takes hours. B may be possible only if tested within 30 minutes. D does not protect against Region loss. The best answer is the cheapest strategy proven by a timed drill to meet the RTO.
An ECS service scales out and back in repeatedly every few minutes, causing latency spikes. Which change reduces the oscillation?
A. Lower the scale-out cooldown and the scale-in cooldown to 10 seconds. B. Increase the scale-in cooldown and review the target value and metric. C. Switch to a step scaling policy with no cooldown. D. Disable auto scaling and fix the task count.
Answer: B. A longer scale-in cooldown (and a sensible target) damps the oscillation. A makes it worse. C removes protection against flapping. D loses elasticity and cost savings.
Completion checklist
- I can explain the standing cost versus expected loss of each DR strategy
- I can list four levers (right-sizing, Graviton, Spot, commitments) and one danger of each
- I ran the cost model with my own numbers and chose a strategy against a tolerance
- I ran the cleanup steps and confirmed nothing is still billing
Key takeaways
- Idle DR capacity is a deliberate cost: tie it to an RTO and an impact tolerance.
- Size for N minus one Availability Zone and for peaks, not averages.
- Optimise first, commit later; keep an on-demand baseline when using Spot.
- Meet the impact tolerance first, then choose the cheapest strategy.
- Make DR cost visible with tags and Region splits so it is reviewed, not quietly cut.
Further reading
Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.
Caching for performance and protection
Use CloudFront and ElastiCache to speed up reads and shield back ends from load spikes and partial outages, implement cache-aside with HybridCache in .NET, and apply a data-classification rule for what must never be cached.
Chaos engineering with AWS Fault Injection Service
Plan and run a safe first chaos experiment: write a steady-state hypothesis, build an AWS Fault Injection Service experiment template that stops ECS tasks with a CloudWatch alarm as the stop condition, gate it with a pre-flight check in C#, and rehearse the same idea locally for free.