Lesson 5 of 5 Generative AI and Machine Learning Architectures

Choosing ML Inference Options in SageMaker AI

This lesson compares SageMaker AI real-time, serverless, asynchronous and batch inference and explains how endpoints are deployed and monitored in production.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish the four SageMaker AI inference options by latency, payload, duration and idle cost.
  • Choose an inference option from a workload's traffic pattern.
  • Explain how deployment guardrails and monitoring protect production endpoints.

Inference options

Real-time endpoints

A real-time endpoint runs one or more instances behind a managed HTTPS endpoint for synchronous, low-latency requests. It scales with Application Auto Scaling (for example on invocations per instance) and suits steady traffic with millisecond latency targets. Multi-model endpoints and inference components place several models on shared instances to raise utilisation.

Serverless inference

Serverless inference provisions compute per request and scales to zero, charging only for usage. It suits intermittent or unpredictable traffic that tolerates occasional cold starts and has small payloads.

Asynchronous inference

Asynchronous inference queues requests whose payloads are up to 1 GB and whose processing takes up to an hour, writes results to S3, notifies through SNS and can scale the instance count to zero when the queue is empty.

Batch transform

Batch transform runs a model over a whole data set in S3 without a persistent endpoint, which suits periodic scoring of large data sets.

Sort into groups

Which inference option?

Exam skills 1.2.3

Choose the SageMaker AI inference option for each workload.

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

Choosing an option

The following comparison summarises how the options differ.

Real-time
LatencyMilliseconds
Payload and durationSmall, short
Idle costInstances run continuously
Choose when Steady, latency-sensitive traffic.
Serverless
LatencySeconds with cold starts
Payload and durationSmall, short
Idle costNone
Choose when Intermittent traffic with small payloads.
Asynchronous
LatencyMinutes (queued)
Payload and durationUp to 1 GB, up to 1 hour
Idle costNone when scaled to zero
Choose when Large inputs or long processing with variable demand.
Batch transform
LatencyJob duration
Payload and durationWhole data sets
Idle costNone
Choose when Offline scoring of whole data sets.

Production design

Endpoints run in private subnets with VPC interface endpoints for the SageMaker API and runtime, and applications call them with IAM, often through API Gateway for external clients. New model versions are released with deployment guardrails: blue/green updates with all-at-once, canary or linear traffic shifting, a baking period and automatic rollback on CloudWatch alarms. Endpoint metrics (invocations, model latency, errors, instance utilisation) and SageMaker Model Monitor (data and model quality drift) keep the model healthy in production. Model training and data science workflows themselves are outside the scope of the exam.

Worked example

Three models, three patterns

A bank hosts three custom models: fraud scoring for card payments, a document classifier for scanned loan files of up to 500 MB, and a monthly churn model.

Fraud scoring needs answers within 50 ms at a steady 300 requests per second, so it gets a real-time endpoint with auto scaling and canary deployments. The document classifier takes several minutes per file and receives files in bursts, so it uses asynchronous inference that scales to zero overnight.

The churn model scores every customer once a month, so a batch transform job runs over the customer table exported to S3, with no endpoint left running between runs.

Check yourself

Which SageMaker AI option suits requests with 600 MB payloads that take 20 minutes each and arrive in bursts?

Show answer

Asynchronous inference. It queues requests, accepts payloads up to 1 GB and processing up to an hour, writes results to S3 and can scale to zero instances between bursts.

Exam Tips

Remember for the exam

  • Steady, low-latency traffic: real-time endpoint with auto scaling.
  • Large payloads or long processing: asynchronous inference; intermittent small requests: serverless inference.
  • Many small, lightly used models: multi-model endpoint.
  • Safe model releases with automatic rollback: deployment guardrails with canary or linear shifting.