Choosing a Deployment and Inference Option
This lesson explains how a trained model is served to make predictions, which is called inference, and how latency, request volume, payload size and cost decide the right option.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish real-time, serverless, asynchronous and batch inference.
- Compare managed APIs, SageMaker AI endpoints, self-hosting and edge deployment.
Inference options
Inference means using a trained model to make predictions, and SageMaker AI offers four ways to run it. A real-time endpoint is always running and answers each request in milliseconds to seconds, which suits interactive applications such as checking a payment for fraud at checkout; you pay for as long as it runs. A serverless endpoint scales automatically, down to zero when idle, and you pay only for the compute used, which suits intermittent or unpredictable traffic, at the cost of occasional delays while it starts.
Asynchronous inference queues requests, processes each for up to about an hour, and writes the results to S3, which suits large inputs or long processing. Batch inference processes a whole data set offline with no endpoint, which is the cheapest choice when answers are not needed immediately, such as scoring every customer overnight. The following table summarises the options.
| Option | How it works | Best for |
|---|---|---|
| Real-time | Persistent HTTPS endpoint answering in milliseconds to seconds; you pay while it runs | Interactive apps such as checkout fraud checks |
| Serverless | Scales automatically, down to zero; pay only for the compute used to process requests; occasional cold starts | Intermittent or unpredictable traffic |
| Asynchronous | Queues requests, processes each for up to about an hour, writes results to S3; can scale to zero | Large payloads (up to about 1 GB) or long processing |
| Batch | Processes a whole data set offline with no endpoint (SageMaker Batch Transform, Bedrock batch inference) | Cheapest when answers are not needed immediately |
Fix the inference choice
Hosting options
A model can be hosted with different levels of management. With a managed API, such as Amazon Bedrock, there is nothing to run: the application simply calls the model. With SageMaker AI endpoints, you provide the model, and AWS runs the instances, scaling and patching. Self-hosting on EC2, ECS or EKS gives full control but makes you responsible for the whole stack. Edge deployment runs models on devices themselves, for places with poor connectivity or where responses must be almost instant. The following table summarises the options.
| Option | You manage |
|---|---|
| Managed API (Amazon Bedrock) | Nothing: just call the model |
| SageMaker AI endpoints | The model; AWS runs instances, scaling and patching |
| Self-hosted on EC2, ECS or EKS | The full stack |
| Edge deployment | Models on devices, for poor connectivity or very low latency |
Who manages what?
Four models, four inference options
A media company deploys four models. Each has different traffic and timing needs, so each gets a different inference option:
| Model | Need | Inference option |
|---|---|---|
| Recommend articles as a page loads | Answer in under 100 ms, all day | Real-time endpoint |
| Classify support emails for a small team | A few hundred requests a day, at random times | Serverless inference (scales to zero) |
| Transcribe and summarise hour-long videos | Large files, minutes of processing each | Asynchronous inference |
| Score every subscriber's churn risk each night | Millions of rows, no rush | Batch transform |
Choosing a real-time endpoint for the nightly churn job would work, but the company would pay for an endpoint running all day to do an hour's work. Matching the option to the traffic pattern is mostly a cost decision.
Which workloads suit a serverless inference endpoint?
Show answer
Intermittent or unpredictable traffic that can accept an occasional cold start. The endpoint scales to zero, so you pay only while requests are processed.
Exam Tips
Remember for the exam
- Interactive, low-latency predictions call for a real-time endpoint.
- Intermittent traffic, with pay-per-use pricing and scaling to zero, calls for serverless inference.
- Large payloads or long processing with queued requests call for asynchronous inference.
- The cheapest way to score a large data set offline is batch inference, such as Batch Transform.
- The least operational overhead for foundation models comes from Amazon Bedrock, a managed API.