Optimize ML and AI Costs and Performance
Unlock the complete study guide.
Bundled into the existing AWS Certified Machine Learning Engineer - Associate premium course — no separate purchase.
14-day money-back guarantee — no questions asked.
Included in this chapter:
- Cost levers, telemetry and billing data
- Selecting an inference instance family
- Sizing Serverless Inference: memory and feature limits
- Locating latency: model, overhead and network time
- Dashboards for performance metrics
- Alarms that notify and act
- Matching serving capacity to demand
- Billing data: Cost Explorer, tags and Budgets
- Purchasing options for ML compute
- Estimating FM inference cost from the token mix
- Batch inference for delay-tolerant prompts
- Intelligent prompt routing
- Prompt caching: when reuse pays
- Attributing FM usage to applications and callers
- RAG costs: knowledge base sync and vector storage
- Agent resource consumption with AgentCore
- Requirements, fixes and rejected alternatives
Purchasing options for ML and FM compute
| Decision factor | SageMaker AI Savings Plans | Compute Savings Plans | EC2 Instance Savings Plans | Managed Spot Training | Bedrock Provisioned Throughput |
|---|---|---|---|---|---|
| Applies to | SageMaker AI instance usage, such as notebooks, training and inference | EC2 instance usage, plus Fargate and Lambda | EC2 instance usage in one instance family and one Region | SageMaker AI training jobs run on Spot capacity | Model units for one supported Bedrock model |
| What you give up | A commitment whose terms can't change after purchase | A commitment whose terms can't change after purchase | A commitment whose terms can't change after purchase | Scheduling certainty: jobs can wait for capacity and be interrupted | Per-token billing: model units bill hourly, and a 1-month or 6-month term blocks deletion before it ends |
| Discount survives | Changes of instance family, size, Region and component | Changes of instance family, size, Region, OS and tenancy; moves to Fargate or Lambda | Changes of size, OS and tenancy inside the family | Not applicable: Spot applies per training job | Not applicable: the hourly price covers the purchased model units |
| Main cost risk | Unused commitment (low utilization) | Unused commitment (low utilization) | Unused commitment, or a migration outside the family or Region | Job stops at the maximum wait time; no on-demand fallback | Billing continues until you delete it |
| Best fit | A predictable SageMaker AI baseline | EC2-based ML workloads that may change family or Region | A stable EC2 family in one Region | Interruption-tolerant training with checkpoints | A Bedrock workload whose steady throughput need justifies reserved capacity |
Decision tree
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.
References
- https://docs.aws.amazon.com/sagemaker/latest/dg/monitoring-cloudwatch.html
- https://docs.aws.amazon.com/aws-certification/latest/machine-learning-engineer-associate-02/machine-learning-engineer-associate-02-domain4.html
- https://docs.aws.amazon.com/aws-certification/latest/machine-learning-engineer-associate-02/machine-learning-engineer-associate-02-domain3.html
- https://aws.amazon.com/ec2/instance-types/
- https://aws.amazon.com/machine-learning/inferentia/
- https://aws.amazon.com/ai/machine-learning/trainium/
- https://docs.aws.amazon.com/sagemaker/latest/dg/inference-recommender.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/serverless-endpoints.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/inference-gpu-drivers.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/async-inference-create-endpoint.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/host-vpc.html
- https://docs.aws.amazon.com/xray/latest/devguide/aws-xray.html
- https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-runtime-metrics.html
- https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/observability-telemetry.html
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/AlarmThatSendsEmail.html
- https://docs.aws.amazon.com/autoscaling/application/userguide/target-tracking-scaling-policy-overview.html
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/alarms-and-missing-data.html
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/alarm-combining.html
- https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-scheduled-scaling.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/async-inference-autoscale.html
- https://docs.aws.amazon.com/cost-management/latest/userguide/ce-what-is.html
- https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/cost-alloc-tags.html
- https://docs.aws.amazon.com/cost-management/latest/userguide/budgets-managing-costs.html
- https://docs.aws.amazon.com/savingsplans/latest/userguide/plan-types.html
- https://docs.aws.amazon.com/ec2/latest/instancetypes/instance-type-names.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/model-managed-spot-training.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/prov-throughput.html
- https://aws.amazon.com/bedrock/pricing/
- https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/batch-inference.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-routing.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html
- https://docs.aws.amazon.com/sagemaker/latest/dg/model-cards.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/model-invocation-logging.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/kb-data-source-sync-ingest.html
- https://docs.aws.amazon.com/bedrock/latest/userguide/knowledge-base-setup.html
- https://docs.aws.amazon.com/opensearch-service/latest/developerguide/serverless-vector-search.html