CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
  • Week 1
    • 1.The ML Lifecycle (from a Specialty Perspective)
    • 2.Data Storage for ML: S3, EFS, FSx for Lustre, and Data Formats
    • 3.Data Ingestion: Kinesis, Glue, Batch vs. Streaming
    • 4.Data Labeling: SageMaker Ground Truth, Active Learning, Label Quality
    • 5.Week 1 Comprehensive Review: ML Overview & Data Engineering 1
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
  • Week 11
    • 1.Model Monitoring: SageMaker Model Monitor and Drift Response
    • 2.MLOps: SageMaker Pipelines, Model Registry, CI/CD
    • 3.ML Security: IAM Execution Roles, VPC Isolation, KMS Encryption
    • 4.Operations & Cost: Cost Optimization, Logging/Audit, Disaster Recovery
    • 5.Week 11 Comprehensive Review: Monitoring, MLOps, Security, Operations
  • Week 12
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← MLS-C01/Week 11/Day 4

Based on the MLS-C01 exam guide·Report an error

MLS-C01· AssociateWeek 11 · Day 4~28 min read

Day 4 - Operations & Cost: Cost Optimization, Logging/Audit, Disaster Recovery

📌 Key Takeaways

  • Operations rests on three pillars: cost, audit, and resilience. An ML workflow keeps spending money on data pipelines, training GPUs, and always-on endpoints.
  • The economics of training and inference are opposites. You cut training by tolerating interruption (Spot), and you cut inference by eliminating idle cost.
  • Managed Spot Training saves up to 90%, but saving checkpoints is practically mandatory.
  • "Why did it fail / how slow is it" is CloudWatch; "who did what, and when" is CloudTrail.
  • DR plans for three assets separately: data → model → endpoint. An endpoint must be re-creatable from code (IaC) plus the Model Registry.

Cost Optimization: Training and Inference Have Different Economics

AspectTrainingInference
Nature of the jobBatch, runs once and endsAlways waiting, must be ready to receive requests
Interruption tolerancePossible (resume from a checkpoint)Hard (requests fail immediately)
Main wasteOversized instances, running hopeless attempts to the endTime switched on while nobody calls it
Typical savings toolsManaged Spot, early stopping, right-sizingServerless, Async, Batch Transform, Auto Scaling
Cost unitInstance hours × number of jobsInstance hours × 24 hours × 365 days
  • For training, the problem is the total volume; for inference, the problem is idle time. This difference separates the answer options.
  • If usage is stable over the long term, a 1-year or 3-year commitment discount such as SageMaker Savings Plans is also a candidate.

Reducing Training Cost

  • Managed Spot Training: Uses spare capacity in exchange for possible interruption. Saves up to 90%.
  • Right-sizing: Don't use a GPU if a CPU is enough, and turn on distributed training only when needed.
  • AMT early stopping: Drops hopeless trials early in hyperparameter tuning.
  • Maximum runtime limit: Cuts off an infinite loop or a diverged training run that would spin all night, using max_run.
  • Warm-start tuning: Inherits the results of a previous tuning job to reduce the number of search trials.

Managed Spot Training in Detail

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/",
)
ParameterMeaningIf you omit it
use_spot_instancesWhether to use Spot capacityYou pay the On-Demand rate as is
max_runMaximum runtime of the training itselfA runaway job keeps getting billed
max_waitTotal allowed time including the wait for Spot capacityMust be set when using Spot, and must not be smaller than max_run
checkpoint_s3_uriSave checkpoints to S3On 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.

Reducing Inference Cost: Four Deployment Options

OptionBilling methodIdle costScale to zeroSuitable traffic
Real-time EndpointInstance hours (always on)YesNot possible (default)Steady, latency-sensitive traffic
Serverless InferenceBased on invocations and execution timeNonePossibleIntermittent, unpredictable traffic where cold starts are tolerable
Asynchronous InferenceInstance hours while processingDown to 0 if there are no requestsPossibleLarge payloads, long processing, no immediate answer needed
Batch TransformOnly the job run timeNone (there is no endpoint at all)Not applicablePeriodically scoring an entire dataset in bulk
Supplementary toolWhat it doesWhen
Multi-Model Endpoint (MME)Hosts thousands of models on one endpoint, loading from S3 on requestMany models with similar structure, each invoked rarely
Auto ScalingIncreases and decreases the instance count with trafficReal-time traffic with large day/night swings
Inference RecommenderRecommends a suitable instance type and count via load testingWhen you don't know which instance to use
  • Serverless: No billing while idle, but if there are no invocations for a long time a cold start delay occurs.
  • Async: Puts requests in a queue and writes results to S3. When the queue is empty, instances can be scaled down to 0.
  • Batch Transform: No endpoint is created at all, so the always-on cost is 0. If you don't need real-time responses, it is the cheapest.
  • MME: The model is loaded into memory on the first call, so only that request is slow. It is unsuitable if you are extremely latency-sensitive.

Cost Selection Decision Tree

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)

Logging and Audit: CloudWatch vs CloudTrail

ServiceWhat it recordsQuestion it answers
CloudWatch LogsApplication and job logs, container stdout/stderr"Why did training fail? What was the loss?"
CloudWatch MetricsCPU, GPU, memory, invocation count, latency"Was the endpoint healthy? Were there spikes?"
CloudTrailEvery 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

Where Logs and Metrics Go

SignalDestinationTypical items
Training container stdout/stderrCloudWatch Logs (/aws/sagemaker/TrainingJobs)Stack traces, epoch progress
Training loss and accuracyCloudWatch Metrics (extracted from logs with a regular expression)Custom metrics such as train:loss, validation:accuracy
Endpoint container logsCloudWatch Logs (/aws/sagemaker/Endpoints/...)Inference exceptions, model loading failures
Endpoint invocations and latencyCloudWatch MetricsInvocations, ModelLatency, OverheadLatency, Invocation4XXErrors
Instance resourcesCloudWatch MetricsCPUUtilization, MemoryUtilization, GPUUtilization
Management API callsCloudTrailCreateTrainingJob, DeleteEndpoint, UpdateEndpoint
Raw inference inputs and outputsS3 (Data Capture)Input for Model Monitor baselines and drift analysis
  • CloudTrail lets you view recent events directly in the console, but long-term retention and auditing require a Trail that exports to S3.
  • CloudTrail logs accumulated in S3 are protected from tampering by bucket policies and Object Lock, and are queried with Athena and similar tools to serve as audit evidence.
  • Old audit logs are moved to low-cost storage classes with S3 lifecycle rules to reduce retention cost.

"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.

Disaster Recovery: Data → Model → Endpoint

Three assets need a recovery plan.

AssetIf lostRecovery strategyKey tools
DataRetraining itself becomes impossibleS3 cross-Region replication, versioning, immutable lockS3 CRR / Versioning / Object Lock
Model artifactsRetraining takes time and costS3 versions + copy to another Region, track approved versionsS3 / SageMaker Model Registry
EndpointService outageRe-create from code, multi-AZ, redeploy to another Region or accountCloudFormation, CDK, Pipelines

Data

  • Replicate training data with S3 cross-Region replication (CRR). For replication, versioning must be enabled on both the source and destination buckets.
  • Versioning and Object Lock prevent accidental deletion and ransomware-style overwrites.

Model

  • Make artifacts redundant with S3 versioning plus cross-Region copy.
  • Use Model Registry to track which version must be restored (including approval status).

Endpoint

  • Re-create it as is in another Region or account with IaC (CloudFormation, SageMaker Pipelines).
  • Survive a single-AZ failure with multi-AZ (instance_count ≥ 2).
StrategyRTO/RPOCostAlways-running resources
Backup & RestoreSlow (hours)LowNone (only backups kept)
Pilot LightMedium (tens of minutes)MediumData replication + minimal core setup
Warm StandbyFast (minutes)HighAlways running at reduced scale
Multi-Region ActiveImmediate (seconds)HighestBoth sides running at full scale
  • RTO is "the time it takes to recover," and RPO is "the time range of data you can afford to lose." You must decide both first to determine the strategy.
  • Key point: An endpoint must be re-creatable from code plus the Model Registry. A hand-built endpoint is not a recovery target but a cause of the incident.

Availability and Automation

MeasureFailure it preventsNotes
Endpoint Auto ScalingLatency and errors from traffic surgesA target-tracking policy maintains invocations per instance
Multi-AZ (instance_count ≥ 2)Single-AZ failureWith two or more instances, they are automatically spread across AZs
EventBridge + LambdaDelayed manual response after detecting a failureResponds automatically to training job failures and endpoint state changes
CloudWatch alarmsSilent performance degradationNotifies and takes automatic action when latency or error-rate thresholds are exceeded
Deployment guardrails (canary/linear)Full rollout of a bad modelAutomatic rollback when an alarm fires
S3 CRR + Model RegistryWhole-Region failureImmediate restoration in another Region

Question Stem Clue → Answer Mapping

Clue in the stemAnswer to pickReason
"Invoked only briefly during the day, zero traffic the rest of the time"Serverless InferenceNo idle cost, billed only on request
"Train on Spot without losing progress"Set checkpoint_s3_uriResume from the checkpoint after an interruption
"Cut training cost by up to 90%"Managed Spot TrainingBest for batch jobs that can tolerate interruption
"Large payload and long processing time, no immediate answer needed"Asynchronous InferenceQueue-based, scales down to 0 when idle
"Score the entire dataset every night"Batch TransformNo endpoint, so always-on cost is 0
"Thousands of models, each invoked rarely"Multi-Model EndpointShare one endpoint to cut cost
"Prove who deleted the endpoint and when"CloudTrailRecords the actor and time of every API call
"Want to see the stack trace of why training failed"CloudWatch LogsContainer stdout/stderr accumulates there
"Monitor whether endpoint latency spikes"CloudWatch Metrics + alarmBased 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 ≥ 2Automatically spread across multiple AZs
"Immediately restore data and models even through a Region failure"S3 CRR + versioning + Model RegistryAsset replication + tracking the version to restore
"Recovery may take several hours, minimize cost"Backup & RestoreNo always-running resources, so cheapest
"Fail over within seconds on a failure"Multi-Region ActiveBoth sides running, highest cost

In the next note we wrap up Week 11 by tying monitoring, operations, and governance together.

📖 Glossary

  • Managed Spot Training: A training mode that uses spare capacity cheaply. It can be interrupted, so checkpoints are practically mandatory.
  • Checkpoint: A snapshot of the state saved to S3 during training. Even after an interruption, training continues from here.
  • max_run / max_wait: Respectively "the maximum time allowed for training" and "the total allowed time including waiting for capacity."
  • Cold start: The phenomenon where, after a long period without calls, preparation time is added when it is called again and the first response is slow.
  • Multi-Model Endpoint: A mode where one endpoint loads multiple models from S3 when needed. The more models, the greater the advantage.
  • Batch Transform: A batch inference job that scores an entire dataset at once without an endpoint.
  • CloudTrail Trail: A setting that persistently stores API call records in S3. It becomes the basis for long-term auditing.
  • RTO / RPO: The time allowed until recovery / the time range of data you can afford to lose. The two criteria for choosing a DR strategy.
  • S3 cross-Region replication (CRR): A feature that automatically replicates objects to a bucket in another Region. Both buckets require versioning.
  • Model Registry: A catalog that manages model versions and approval status. During a failure, it tells you "what to roll back."

📝 Practice Questions

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?

PreviousML Security: IAM Execution Roles, VPC Isolation, KMS EncryptionWeek 11 · Day 3Next Week 11 Comprehensive Review: Monitoring, MLOps, Security, OperationsWeek 11 · Day 5

Official references

  • MLS-C01 official exam page(opens in a new tab)
  • Amazon S3 documentation(opens in a new tab)
  • Amazon CloudWatch documentation(opens in a new tab)
  • AWS CloudTrail documentation(opens in a new tab)
  • Amazon SageMaker AI documentation(opens in a new tab)
  • Amazon EC2 Auto Scaling documentation(opens in a new tab)

On this page

  • Key Takeaways
  • Cost Optimization: Training and Inference Have Different Economics
  • Reducing Training Cost
  • Reducing Inference Cost: Four Deployment Options
  • Cost Selection Decision Tree
  • Logging and Audit: CloudWatch vs CloudTrail
  • Where Logs and Metrics Go
  • Disaster Recovery: Data → Model → Endpoint
  • Data
  • Model
  • Endpoint
  • Availability and Automation
  • Question Stem Clue → Answer Mapping
  • Glossary
  • Practice Questions