Lesson 2 of 4 Model Deployment and Inference

Choosing Compute Environments for Model Hosting

This lesson explains when scenarios favour containers, functions or instances that the team controls instead of SageMaker AI endpoints, the managed default for hosting models.

Learning outcomes

After completing this lesson, you will be able to:

  • Compare SageMaker AI endpoints, EKS, ECS, Lambda and EC2.
  • Choose inference hardware such as CPU, GPU or Inferentia.
  • Weigh control against operational effort.

The options

SageMaker AI endpoints provide managed hosting with auto scaling, deployment guardrails, Model Monitor and multi-model options. Amazon EKS suits organisations that run everything on Kubernetes and want custom serving stacks such as KServe or Ray Serve, with GPU node groups and Karpenter for scaling. Amazon ECS, on EC2 or AWS Fargate, runs serving containers with simpler orchestration (Fargate has no GPUs). AWS Lambda suits small models and sporadic traffic, with up to 10 GB memory, a 15-minute limit, container images up to 10 GB and no GPUs. Amazon EC2 gives complete control. AWS Batch runs containerised batch scoring jobs at scale.

Match the pairs

Deployment targets

Exam skills 3.1.1

Match each requirement with the deployment target that fits it.

Log in to try this activity Interactive activities are free with an account.

Choosing hardware

The hardware for inference follows the model. CPU instances, such as the ml.c and ml.m families, suit tree-based models and small neural networks, and Graviton-based instances lower the cost of CPU inference further. GPU instances, such as ml.g5, ml.g6, ml.p4d and ml.p5, suit deep learning models and large language models.

AWS Inferentia2 instances (ml.inf2) lower the cost per inference for supported models compiled with the AWS Neuron SDK. Because the best choice depends on the specific model and traffic, SageMaker Inference Recommender benchmarks a model on several instance types and reports latency, throughput and cost for each.

The following table summarises the deployment targets.

TargetChoose whenLimits
SageMaker AI endpointManaged ML hosting with least operationsSageMaker-specific
Amazon EKSKubernetes standard, custom serving stackCluster operations
Amazon ECS / FargateContainers without KubernetesFargate: no GPU
AWS LambdaSmall model, sporadic trafficNo GPU, 15 min, 10 GB memory
Amazon EC2Full controlEverything is yours to manage
AWS BatchContainerized batch scoringNot for online inference
Sort into groups

Choose the hardware

Exam skills 3.1.1 · 4.2.1

Choose the hardware type for each model.

Log in to try this activity Interactive activities are free with an account.

Weighing control against operations

The targets form a spectrum from most managed to most controlled. A SageMaker AI endpoint handles instance provisioning, health checks, scaling, model loading and safe deployment, and integrates with data capture and Model Monitor, so the team manages only the model and its configuration. EKS and ECS give the team control over the serving stack and the deployment process, but the team must build or operate scaling, monitoring and rollout itself. EC2 gives complete control and complete responsibility.

Existing platforms often decide the question. When an organisation already runs every service on Kubernetes, with a platform team, observability and a GitOps process, deploying models on EKS reuses all of that, and a separate SageMaker AI process would be the inconsistent choice. When no such platform exists, building one for a few models costs far more than using SageMaker AI endpoints.

Workload shape matters as well. Lambda fits small CPU models with sporadic traffic and integrates naturally with other serverless services, but its 15-minute limit, 10 GB memory and lack of GPUs rule it out for large or long-running inference. AWS Batch fits containerised scoring jobs that run for hours on many instances, especially when a team already uses Batch queues with Spot capacity, but it serves no online requests. Matching the target to the traffic pattern, latency requirement and hardware need is as important as matching it to the team's skills.

Worked example

A platform team's decision

A company runs all microservices on EKS with a mature GitOps process and a platform team. It wants to serve a PyTorch model with GPU support and the same deployment process as other services.

Deploying on EKS with a GPU node group and a standard serving framework fits the existing platform and process. For a team without Kubernetes expertise, a SageMaker AI real-time endpoint would be the least-effort answer; the existing platform and requirement for one process change the answer here.

Check yourself

Which compute targets have no GPUs?

Show answer

AWS Lambda and AWS Fargate.

Exam Tips

Remember for the exam

  • Managed ML hosting with least operations: SageMaker AI endpoints.
  • Existing Kubernetes platform and process: EKS.
  • Lambda and Fargate have no GPUs.
  • Lower-cost deep learning inference: Inferentia2 with the Neuron SDK.
  • Benchmark instance types: SageMaker Inference Recommender.