Lesson 2 of 6 The ML Development Lifecycle and MLOps

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.

OptionHow it worksBest for
Real-timePersistent HTTPS endpoint answering in milliseconds to seconds; you pay while it runsInteractive apps such as checkout fraud checks
ServerlessScales automatically, down to zero; pay only for the compute used to process requests; occasional cold startsIntermittent or unpredictable traffic
AsynchronousQueues requests, processes each for up to about an hour, writes results to S3; can scale to zeroLarge payloads (up to about 1 GB) or long processing
BatchProcesses a whole data set offline with no endpoint (SageMaker Batch Transform, Bedrock batch inference)Cheapest when answers are not needed immediately
Troubleshooting scenario

Fix the inference choice

Exam skills 1.1.3 · 1.3.3

Each team chose an inference option that does not suit its workload. Choose the better one.

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

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.

OptionYou manage
Managed API (Amazon Bedrock)Nothing: just call the model
SageMaker AI endpointsThe model; AWS runs instances, scaling and patching
Self-hosted on EC2, ECS or EKSThe full stack
Edge deploymentModels on devices, for poor connectivity or very low latency
Match the pairs

Who manages what?

Exam skills 1.3.3

Match each hosting option with what you are responsible for.

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

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:

ModelNeedInference option
Recommend articles as a page loadsAnswer in under 100 ms, all dayReal-time endpoint
Classify support emails for a small teamA few hundred requests a day, at random timesServerless inference (scales to zero)
Transcribe and summarise hour-long videosLarge files, minutes of processing eachAsynchronous inference
Score every subscriber's churn risk each nightMillions of rows, no rushBatch 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.

Check yourself

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.