Based on the MLS-C01 exam guideReport an error
| Aspect | Training | Inference |
|---|---|---|
| Nature of the job | Batch, runs once and ends | Always waiting, must be ready to receive requests |
| Interruption tolerance | Possible (resume from a checkpoint) | Hard (requests fail immediately) |
| Main waste | Oversized instances, running hopeless attempts to the end | Time switched on while nobody calls it |
| Typical savings tools | Managed Spot, early stopping, right-sizing | Serverless, Async, Batch Transform, Auto Scaling |
| Cost unit | Instance hours × number of jobs | Instance hours × 24 hours × 365 days |
max_run.estimator = Estimator(
...,
use_spot_instances=True,
max_run=3600, # maximum time allowed for the actual training
max_wait=7200, # total allowed time, waiting + training (must be >= max_run)
checkpoint_s3_uri="s3://ml-train-bucket/checkpoints/job-01/",
)| Parameter | Meaning | If you omit it |
|---|---|---|
use_spot_instances | Whether to use Spot capacity | You pay the On-Demand rate as is |
max_run | Maximum runtime of the training itself | A runaway job keeps getting billed |
max_wait | Total allowed time including the wait for Spot capacity | Must be set when using Spot, and must not be smaller than max_run |
checkpoint_s3_uri | Save checkpoints to S3 | On interruption, training restarts from scratch |
[Spot training timeline]
Wait for capacity ──▶ Training starts ──▶ Checkpoint saved ──▶ ✗ Interruption
│
└─▶ Capacity recovers ──▶ Resume from checkpoint ──▶ Done
◀────────────────── max_wait (wait + all of training) ──────────────────▶
◀──────── max_run (training time) ────────▶⚠️ Pitfall: The answer to "How do you cut cost with Spot without losing progress?" is always checkpoints. Network isolation, KMS, and sampling options have nothing to do with recovering from an interruption.
| Option | Billing method | Idle cost | Scale to zero | Suitable traffic |
|---|---|---|---|---|
| Real-time Endpoint | Instance hours (always on) | Yes | Not possible (default) | Steady, latency-sensitive traffic |
| Serverless Inference | Based on invocations and execution time | None | Possible | Intermittent, unpredictable traffic where cold starts are tolerable |
| Asynchronous Inference | Instance hours while processing | Down to 0 if there are no requests | Possible | Large payloads, long processing, no immediate answer needed |
| Batch Transform | Only the job run time | None (there is no endpoint at all) | Not applicable | Periodically scoring an entire dataset in bulk |
| Supplementary tool | What it does | When |
|---|---|---|
| Multi-Model Endpoint (MME) | Hosts thousands of models on one endpoint, loading from S3 on request | Many models with similar structure, each invoked rarely |
| Auto Scaling | Increases and decreases the instance count with traffic | Real-time traffic with large day/night swings |
| Inference Recommender | Recommends a suitable instance type and count via load testing | When you don't know which instance to use |
Need to reduce inference cost
├─ Is a real-time response needed?
│ ├─ No ↓
│ │ ├─ Periodically score the entire dataset → Batch Transform (always-on cost 0)
│ │ └─ Per-request but no immediate answer needed, large payload → Asynchronous Inference
│ └─ Yes ↓
├─ Is the traffic intermittent and hard to predict?
│ ├─ Yes → Serverless Inference (idle cost 0, tolerate cold starts)
│ └─ No ↓
├─ Are there very many models, each invoked rarely?
│ ├─ Yes → Multi-Model Endpoint (share one endpoint)
│ └─ No ↓
└─ Steady but with large time-of-day swings?
├─ Yes → Real-time + Auto Scaling
└─ No → Real-time (right-sizing + consider a commitment discount)| Service | What it records | Question it answers |
|---|---|---|
| CloudWatch Logs | Application and job logs, container stdout/stderr | "Why did training fail? What was the loss?" |
| CloudWatch Metrics | CPU, GPU, memory, invocation count, latency | "Was the endpoint healthy? Were there spikes?" |
| CloudTrail | Every AWS API call | "Who deleted this? When?" |
Training loss curve, container stdout → CloudWatch Logs
Endpoint latency, error rate → CloudWatch Metrics
"User alice called DeleteEndpoint at 3:14 UTC" → CloudTrail| Signal | Destination | Typical items |
|---|---|---|
| Training container stdout/stderr | CloudWatch Logs (/aws/sagemaker/TrainingJobs) | Stack traces, epoch progress |
| Training loss and accuracy | CloudWatch Metrics (extracted from logs with a regular expression) | Custom metrics such as train:loss, validation:accuracy |
| Endpoint container logs | CloudWatch Logs (/aws/sagemaker/Endpoints/...) | Inference exceptions, model loading failures |
| Endpoint invocations and latency | CloudWatch Metrics | Invocations, ModelLatency, OverheadLatency, Invocation4XXErrors |
| Instance resources | CloudWatch Metrics | CPUUtilization, MemoryUtilization, GPUUtilization |
| Management API calls | CloudTrail | CreateTrainingJob, DeleteEndpoint, UpdateEndpoint |
| Raw inference inputs and outputs | S3 (Data Capture) | Input for Model Monitor baselines and drift analysis |
"Debugging performance" = CloudWatch. "Proving compliance" = CloudTrail. CloudTrail records the who, what, when, and where of every API, and is the foundation for regulatory response.
⚠️ Pitfall: CloudTrail records management (control plane) APIs. Don't try to count high-frequency data plane calls like
InvokeEndpoint, which arrive thousands of times per second, as audit logs. Invocation volume and latency are viewed with CloudWatch metrics.
Three assets need a recovery plan.
| Asset | If lost | Recovery strategy | Key tools |
|---|---|---|---|
| Data | Retraining itself becomes impossible | S3 cross-Region replication, versioning, immutable lock | S3 CRR / Versioning / Object Lock |
| Model artifacts | Retraining takes time and cost | S3 versions + copy to another Region, track approved versions | S3 / SageMaker Model Registry |
| Endpoint | Service outage | Re-create from code, multi-AZ, redeploy to another Region or account | CloudFormation, CDK, Pipelines |
instance_count ≥ 2).| Strategy | RTO/RPO | Cost | Always-running resources |
|---|---|---|---|
| Backup & Restore | Slow (hours) | Low | None (only backups kept) |
| Pilot Light | Medium (tens of minutes) | Medium | Data replication + minimal core setup |
| Warm Standby | Fast (minutes) | High | Always running at reduced scale |
| Multi-Region Active | Immediate (seconds) | Highest | Both sides running at full scale |
| Measure | Failure it prevents | Notes |
|---|---|---|
| Endpoint Auto Scaling | Latency and errors from traffic surges | A target-tracking policy maintains invocations per instance |
Multi-AZ (instance_count ≥ 2) | Single-AZ failure | With two or more instances, they are automatically spread across AZs |
| EventBridge + Lambda | Delayed manual response after detecting a failure | Responds automatically to training job failures and endpoint state changes |
| CloudWatch alarms | Silent performance degradation | Notifies and takes automatic action when latency or error-rate thresholds are exceeded |
| Deployment guardrails (canary/linear) | Full rollout of a bad model | Automatic rollback when an alarm fires |
| S3 CRR + Model Registry | Whole-Region failure | Immediate restoration in another Region |
| Clue in the stem | Answer to pick | Reason |
|---|---|---|
| "Invoked only briefly during the day, zero traffic the rest of the time" | Serverless Inference | No idle cost, billed only on request |
| "Train on Spot without losing progress" | Set checkpoint_s3_uri | Resume from the checkpoint after an interruption |
| "Cut training cost by up to 90%" | Managed Spot Training | Best for batch jobs that can tolerate interruption |
| "Large payload and long processing time, no immediate answer needed" | Asynchronous Inference | Queue-based, scales down to 0 when idle |
| "Score the entire dataset every night" | Batch Transform | No endpoint, so always-on cost is 0 |
| "Thousands of models, each invoked rarely" | Multi-Model Endpoint | Share one endpoint to cut cost |
| "Prove who deleted the endpoint and when" | CloudTrail | Records the actor and time of every API call |
| "Want to see the stack trace of why training failed" | CloudWatch Logs | Container stdout/stderr accumulates there |
| "Monitor whether endpoint latency spikes" | CloudWatch Metrics + alarm | Based on metrics such as ModelLatency |
| "Retain audit logs for years without tampering" | CloudTrail → S3 (versioning, Object Lock) | Secures long-term retention and immutability |
| "Inference must continue even through a single-AZ failure" | instance_count ≥ 2 | Automatically spread across multiple AZs |
| "Immediately restore data and models even through a Region failure" | S3 CRR + versioning + Model Registry | Asset replication + tracking the version to restore |
| "Recovery may take several hours, minimize cost" | Backup & Restore | No always-running resources, so cheapest |
| "Fail over within seconds on a failure" | Multi-Region Active | Both sides running, highest cost |
In the next note we wrap up Week 11 by tying monitoring, operations, and governance together.
Click a choice to reveal the answer and explanation.
Question 1
An inference endpoint is invoked only intermittently during a short period of the day and receives no traffic the rest of the time. Which option is MOST appropriate for eliminating idle cost?
Question 2
To reduce cost, you want to run a GPU training job on Spot, but without losing progress if it is interrupted. What must you configure?
Question 3
In a security audit, you must prove "who deleted the production endpoint last week." Which service should you check?
Question 4
What is the simplest measure to keep a real-time inference endpoint running even if a single Availability Zone (AZ) fails?
Question 5
To prepare for a failure of an entire Region, you want to be able to immediately restore training data and model artifacts in another Region as well. Which combination is MOST appropriate?