SageMaker AI inference: real-time, serverless, async or batch
When to use SageMaker AI real-time, serverless, asynchronous and batch inference: a comparison table, the limits that decide it, and the scenario cues for each.
Four ways to get predictions
Amazon SageMaker AI offers four main ways to run inference on a model you've trained. They differ in how fast an answer comes back, how big a request can be, and what you pay for while nothing is happening. Most deployment questions turn on those three things.
| Option | Best for | Scaling and cost | Watch out for |
|---|---|---|---|
| Real-time inference | Interactive requests that need low latency | Instances stay running; automatic scaling adjusts how many | You pay for the instances even when traffic is low |
| Serverless Inference | Traffic with idle periods between bursts | No instances to manage; compute is assigned on demand | Cold starts; 1–6 GB of memory; no GPUs |
| Asynchronous inference | Large payloads (up to 1 GB) and long processing (up to an hour) | Requests are queued; the instance count can scale to zero | Input and output go through Amazon S3, so it isn't instant |
| Batch transform | Predictions for a whole dataset, offline | A job runs and stops; there's no persistent endpoint | Not for live requests |
Real-time inference
A real-time endpoint is a fully managed, persistent endpoint for interactive, low-latency requests, such as scoring a transaction while the customer waits. It supports automatic scaling, so the number of instances follows the traffic.
- Choose it when every request needs an answer straight away and traffic is steady enough to keep instances busy.
- It supports features that Serverless Inference doesn't, such as GPUs, VPC configuration, data capture for Model Monitor and several production variants.
- Use SageMaker AI Inference Recommender to load-test instance types and pick the one that meets your latency target at the lowest cost.
Serverless Inference
Serverless Inference runs your model without any instances to configure or manage. It suits workloads with idle periods between bursts of traffic that can tolerate cold starts, such as an internal tool used a few times an hour.
- You choose a memory size from 1 GB to 6 GB, and SageMaker AI assigns compute in proportion to it.
- Several real-time features aren't available, including GPUs, VPC configuration, network isolation, data capture, Model Monitor, multi-model endpoints and multiple production variants.
- Provisioned Concurrency keeps capacity ready for predictable bursts, which reduces cold starts.
Asynchronous inference
An asynchronous endpoint queues each request and processes it in the background. It's built for large payloads of up to 1 GB, long processing times of up to one hour, and cases where an answer within minutes is fine, such as analyzing a long document or a high-resolution image.
- You place the request payload in Amazon S3 and pass its location; the result is written back to S3.
- Amazon SNS can notify you when each result succeeds or fails.
- The endpoint can scale its instance count to zero when there's nothing to process, so you pay only while it works.
Batch transform
Batch transform runs inference over a large dataset in Amazon S3 as a job, then stops. Use it when you don't need a persistent endpoint, for example scoring every customer once a night, or preprocessing a dataset before training.
Choosing in a scenario
- Does each caller wait for the answer in an interactive flow? Real-time inference, unless traffic is sparse and cold starts are acceptable, in which case Serverless Inference.
- Does the model need a GPU, a VPC, data capture or Model Monitor? Real-time inference; Serverless Inference doesn't support them.
- Are payloads large, or does processing take minutes? Asynchronous inference, with the payload in S3.
- Is it a whole dataset with no endpoint needed? Batch transform.
- Must the cost drop to nothing when idle? Serverless Inference, or an asynchronous endpoint scaled to zero.