AWS
Use AWS services to build, deploy, secure, scale, and monitor production AI systems.
Training a model is only part of delivering an AI product. The model also needs dependable compute, storage, networking, security, deployment automation, and monitoring. Amazon Web Services (AWS) supplies these capabilities as cloud services, allowing teams to rent resources instead of maintaining physical infrastructure.
AWS can support the complete MLOps lifecycle: collecting and versioning data, training models, registering approved artifacts, deploying inference services, observing production behavior, and triggering controlled retraining. Service availability, quotas, and features vary by AWS Region, so confirm them before choosing an architecture.
Think in Capabilities, Not Service Names
Begin with workload requirements—latency, traffic pattern, model size, accelerator needs, compliance, team skills, and budget—then select services. The following map is a practical starting point.
| Capability | Common AWS services | Typical MLOps use |
|---|---|---|
| Object storage | Amazon S3 | Datasets, model artifacts, reports, and backups |
| Virtual machines | Amazon EC2 | Custom training or inference with full operating-system control |
| Container registry | Amazon ECR | Versioned training and serving images |
| Container execution | Amazon ECS, AWS Fargate, Amazon EKS | APIs, workers, batch jobs, and model servers |
| Managed ML | Amazon SageMaker AI | Training, pipelines, registry, endpoints, and monitoring |
| Foundation models | Amazon Bedrock | Managed access to foundation models and generative-AI capabilities |
| Serverless compute | AWS Lambda | Lightweight event processing and workflow glue |
| Orchestration and events | AWS Step Functions, Amazon EventBridge | Stateful workflows and scheduled or event-driven automation |
| Messaging | Amazon SQS, Amazon SNS | Decoupled jobs, buffering, notifications, and failure isolation |
| Observability and audit | Amazon CloudWatch, AWS CloudTrail | Metrics, logs, alarms, traces, and API activity |
| Identity and encryption | AWS IAM, AWS KMS | Least-privilege access and managed encryption keys |
| Infrastructure as code | AWS CloudFormation, AWS CDK | Repeatable, reviewed environments |
Core Infrastructure Services
Amazon S3
Amazon S3 is object storage commonly used for raw and curated datasets, features, trained model files, evaluation results, and inference outputs. Enable versioning where recovery and traceability matter, define lifecycle rules for older objects, encrypt data, and restrict bucket access. Record the exact S3 object version or immutable path used by every training run.
Amazon EC2
Amazon EC2 provides virtual machines and maximum control over the operating system, drivers, accelerators, and serving stack. It suits specialized workloads, but the team becomes responsible for patching, capacity, autoscaling, and host reliability. Use immutable machine or container images and avoid manual production configuration.
Amazon ECR, ECS, Fargate, and EKS
Amazon ECR stores container images. Amazon ECS runs containers using AWS-native orchestration, while AWS Fargate can supply serverless container capacity. Amazon EKS provides managed Kubernetes control planes and is appropriate when Kubernetes portability, custom operators, or advanced scheduling justifies its operational overhead. Scan images, pin immutable digests, run containers without root privileges, and promote the same tested image between environments.
AWS Lambda
Lambda is useful for short event-driven tasks such as validating uploads, starting pipelines, transforming metadata, or routing requests. Before using it for inference, evaluate package size, memory, execution duration, cold starts, concurrency, and accelerator requirements. Large or latency-sensitive models usually fit a managed endpoint or container service better.
Managed AI Platforms
Amazon SageMaker AI
Amazon SageMaker AI provides managed capabilities for model development, processing, training, pipelines, model registration, deployment, and monitoring. A model registry can associate model versions with metadata and approval states, giving CI/CD systems a controlled promotion point. Managed real-time endpoints are useful for online inference; asynchronous, serverless, and batch options suit other traffic patterns.
Amazon Bedrock
Amazon Bedrock offers managed access to foundation models and generative-AI features. It can reduce the infrastructure needed to build LLM applications, but it does not remove application responsibilities: evaluate model and prompt versions, protect sensitive inputs, constrain tool access, apply safety controls, monitor quality and cost, and design for quotas and provider failures.
Choose the Right Inference Pattern
| Pattern | Good fit | Design focus |
|---|---|---|
| Real-time endpoint | Interactive predictions | Tail latency, autoscaling, health checks, and safe rollout |
| Asynchronous inference | Large payloads or longer processing | Queue time, idempotency, status tracking, and deadlines |
| Batch inference | Scheduled predictions over stored data | Throughput, partitioning, retries, and reproducibility |
| Streaming inference | Continuous events | Ordering, checkpoints, backpressure, and schema evolution |
| Edge inference | Low-connectivity or device-local decisions | Model size, hardware limits, updates, and telemetry |
A Managed Real-Time MLOps Architecture
- Land versioned training data in S3 and validate its schema and quality.
- Use a SageMaker AI pipeline or an orchestrated container workflow to process data, train candidates, and evaluate them against explicit thresholds.
- Register the model artifact, container image, metrics, lineage, and approval state.
- Deploy an approved version behind a protected endpoint and introduce traffic with a canary or blue/green strategy.
- Send service and model signals to monitoring, alarm on actionable thresholds, and preserve audit events.
- Capture delayed labels and feedback, then retrain through a reviewed pipeline rather than modifying production manually.
A Containerized FastAPI Architecture
A team can package a FastAPI inference service and its dependencies as a Docker image, scan and push it to ECR, then deploy it on ECS/Fargate or EKS. An Application Load Balancer can route traffic to healthy replicas. Store large artifacts in S3, configuration in a managed parameter service, and secrets in AWS Secrets Manager. Use IAM roles for workloads instead of embedding access keys.
Data, Events, and Workflow Orchestration
Data platforms may combine AWS Glue for cataloging and ETL, Amazon Athena for queries over S3, Amazon EMR for distributed processing, Amazon Redshift for analytics, and Amazon Kinesis or Amazon MSK for streams. Database choice should follow access patterns: relational consistency may favor Amazon RDS or Aurora, while key-value workloads may favor DynamoDB.
Step Functions can coordinate multi-step jobs with explicit states, retries, and failure paths. EventBridge routes events and schedules work. SQS buffers jobs so traffic spikes do not overwhelm workers, and dead-letter queues isolate repeatedly failing messages. Make consumers idempotent because distributed delivery can produce retries or duplicates.
Security by Design
- Give people and workloads separate IAM identities with least-privilege policies; prefer temporary credentials and roles.
- Keep private workloads in appropriate VPC subnets and tightly control inbound and outbound traffic with security groups and network controls.
- Encrypt data in transit and at rest; use AWS KMS where customer-managed key control or auditability is required.
- Store credentials in Secrets Manager or an approved parameter store, rotate them, and never bake them into code or images.
- Use CloudTrail and configuration controls for auditing, and centralize security findings and logs where appropriate.
- Minimize sensitive training and inference data, define retention periods, and test authorization at every data access boundary.
Observability for AI Systems
CloudWatch can collect infrastructure and application metrics, logs, dashboards, and alarms; CloudTrail records supported AWS API activity for auditing. Correlate requests with trace or request IDs and record the deployed model, data, code, and configuration versions.
| Signal group | Examples |
|---|---|
| Service health | Request rate, error rate, p50/p95/p99 latency, saturation, queue depth |
| Model behavior | Input drift, prediction distribution, confidence, data-quality violations |
| Product outcomes | Acceptance, conversion, escalation, human correction, delayed ground-truth quality |
| Operations | Deployment status, retraining failures, rollback events, incident recovery time |
| Economics | Cost per prediction, accelerator utilization, idle capacity, token usage |
Monitoring drift alone does not prove model quality has declined. Pair statistical signals with labels, user feedback, product outcomes, and investigation playbooks. Avoid logging raw sensitive prompts or features unless there is a justified and protected need.
CI/CD and Infrastructure as Code
Define networks, roles, storage, compute, alarms, and policies using CloudFormation, AWS CDK, or another reviewed infrastructure-as-code tool. CI should test code, data contracts, model behavior, security, and container images. CD should promote an immutable approved artifact through development, staging, and production with manual approval where risk requires it.
Deploy progressively with shadow, canary, or blue/green releases. Compare both technical metrics and model outcomes, retain the previous working version, and automate rollback only when the signal is trustworthy.
Reliability, Recovery, and Cost
- Design for failure across Availability Zones where the service objective requires it; add multi-Region recovery only when its benefit exceeds its complexity and cost.
- Set recovery-time and recovery-point objectives, back up state, and test restoration and failover rather than assuming they work.
- Use timeouts, bounded retries with jitter, circuit breakers, queues, health checks, and graceful degradation.
- Tag resources, define budgets and anomaly alerts, and attribute spending to environments, teams, and workloads.
- Right-size compute, autoscale from meaningful metrics, shut down idle development resources, and use discounted or interruptible capacity only when workloads tolerate it.
- Measure unit economics such as cost per successful prediction instead of looking only at the monthly bill.
Multi-Account and Environment Strategy
Separate development, staging, and production to reduce accidental impact. Larger organizations often use multiple AWS accounts for stronger isolation, centralized identity, logging, networking, and guardrails. Promote artifacts between environments; do not rebuild a different artifact for production.
Responsible AI
Cloud deployment does not make a model responsible by default. Document intended use and limitations, assess relevant fairness and safety risks, protect privacy, provide human review for consequential decisions, and establish ownership for incidents and appeals. Re-evaluate when data, users, models, or operating conditions change.
Common Mistakes
- Selecting services before defining latency, availability, security, and cost requirements.
- Putting public endpoints or buckets in place for convenience.
- Using broad IAM permissions or long-lived access keys.
- Treating the latest model file or container tag as a reproducible release.
- Autoscaling only on CPU even when queue depth, concurrency, memory, or accelerator use is the real bottleneck.
- Monitoring endpoint uptime but not input quality, model behavior, business outcomes, or cost.
- Creating an elaborate Kubernetes platform when a managed endpoint or simpler container service meets the need.
- Leaving notebooks, instances, endpoints, volumes, and logs running without lifecycle or retention controls.
Beginner Project: Deploy a Prediction API
- Train a small model and save its evaluation report and artifact with unique versions.
- Build a FastAPI endpoint with input validation, health checks, structured logs, and automated tests.
- Package it in a non-root Docker container and push an immutable image to ECR.
- Deploy it first to a private test environment on ECS/Fargate, EC2, or SageMaker AI.
- Assign a least-privilege task or execution role, keep secrets outside the image, and encrypt stored data.
- Create dashboards and alarms for latency, errors, traffic, resource use, and one model-quality signal.
- Run load, failure, rollback, and restoration tests; document the architecture and operating runbook.
- Remove lab resources when finished to prevent unexpected charges.
Architecture Review Checklist
- Can every prediction be traced to model, code, data, and configuration versions?
- Are identities, network paths, secrets, encryption keys, and data retention deliberately controlled?
- Does the inference pattern match latency, throughput, payload, and availability requirements?
- Are retries idempotent and are poison messages isolated?
- Can the team detect model-quality regressions as well as service failures?
- Are deployment, rollback, backup, restore, and incident procedures tested?
- Is cost visible per environment and per useful unit of work?
- Could a simpler managed design meet the same requirements?