Based on the MLA-C01 exam guideReport an error
A model creates business value only once it is deployed — in a form that responds to user requests or batch-processes accumulated data. SageMaker offers four modes depending on the nature of the inference workload, and MLA-C01 keeps asking "which mode fits this scenario."
| Option | Response form | Traffic pattern | Payload/duration | When cost is incurred |
|---|---|---|---|---|
| Real-time | Synchronous, immediate (ms to seconds) | Steady and predictable | Small (<6MB), <60 seconds | The entire time the instances are running |
| Serverless | Synchronous, immediate | Intermittent and unpredictable, drops to 0 | Small (<4MB), <60 seconds | Only the time spent processing requests |
| Asynchronous | Asynchronous, queue-based | Variable, long processing allowed | Large (up to 1GB), <60 minutes | Only when there is work in the queue |
| Batch Transform | Asynchronous, per job | Periodic, bulk | Very large (the whole dataset) | Only the time the job runs |
Synchronous vs asynchronous request flow
[Sync] Client ── invoke_endpoint ──▶ Endpoint ──▶ Model
◀────── Response (ms to seconds) ──────┘
Real-time / Serverless
[Async] Client ── invoke_endpoint_async ──▶ Internal queue ──▶ Endpoint
◀── OutputLocation returned immediately │
┌────────┴────────┐
▼ ▼
S3 (store result) SNS (completion notice)
[Batch] S3 (input) ──▶ [Temporary cluster, N instances run inference in parallel] ──▶ S3 (output) ──▶ Cluster terminates
There is no endpoint at allimport boto3
runtime = boto3.client("sagemaker-runtime")
# Call a real-time endpoint: an immediate response comes back
response = runtime.invoke_endpoint(
EndpointName="my-realtime-endpoint",
ContentType="application/json",
Body='{"features": [5.1, 3.5, 1.4, 0.2]}',
)
result = response["Body"].read()Choosing an inference option is essentially a three-way trade-off among "always-on cost vs latency vs throughput." A real-time endpoint keeps instances always on, so it costs money even with no traffic, but it has the lowest latency. Serverless costs 0 when traffic is 0 but adds cold start latency. Batch is the most cost-efficient per unit of bulk processing but has no immediacy. The exam asks, through scenarios, which of these three to prioritize.
Instances that are always on behind an HTTPS endpoint receive requests and respond in milliseconds to seconds.
→ If traffic is steady and latency-sensitive, real-time is the default choice.
You don't manage instances yourself; compute is provisioned automatically only when requests arrive.
# Serverless endpoint configuration — specify only memory and concurrency
serverless_config = {
"MemorySizeInMB": 2048,
"MaxConcurrency": 10,
}The downside is the cold start. If there have been no calls for a while and then the first request arrives, there is a delay while the container is brought up. It is unsuitable if you need consistently low latency.
⚠️ Pitfall: Don't pick serverless unconditionally just because you see the keyword "reduce cost." For workloads with steadily heavy traffic, serverless can actually cost more than a real-time endpoint. The cost advantage of serverless comes when "there is a lot of idle time." Also, if there is an SLA that cannot tolerate a cold start, serverless is out. "Intermittent/unpredictable traffic + cold start tolerated" is the exact condition for serverless.
Asynchronous Inference puts requests into an internal queue and processes them in order, then stores the result in S3 and announces completion through SNS.
InputLocation)# Async call: put the input in S3, pass only its location, and receive an output location instead of an immediate response
response = runtime.invoke_endpoint_async(
EndpointName="my-async-endpoint",
InputLocation="s3://my-bucket/input/large-image.png",
)
output_location = response["OutputLocation"] # S3 path where the result will be storedAsynchronous inference fills the middle ground between real-time and batch. Like real-time, the endpoint stays alive and you call it per individual request, but a queue absorbs request bursts and allows large payloads and long processing times. "An endpoint is needed (individual calls), but the payload exceeds 6MB or processing exceeds 60 seconds so the real-time constraints can't be met" → that is the classic signal that async is the answer.
Batch Transform has no endpoint. It reads large input from S3, runs inference in bulk, writes the results to S3, and shuts down all resources when the job ends.
from sagemaker.transformer import Transformer
transformer = Transformer(
model_name="my-model",
instance_count=4, # Split the data and process in parallel
instance_type="ml.m5.xlarge",
output_path="s3://my-bucket/batch-output/",
)
transformer.transform(
data="s3://my-bucket/batch-input/",
content_type="text/csv",
split_type="Line", # Split per record
)Batch Transform splits the data across multiple instances (split_type), and each instance processes it in mini-batches (BatchStrategy, MaxPayloadInMB), scaling horizontally. When processing finishes the whole cluster disappears, so always-on cost is 0. When the keyword "bulk batch processing with no real-time requirement at all" appears, Batch Transform is almost always the cheapest correct answer.
When numbers appear in a scenario, it is faster to narrow the candidates by constraints first.
| Constraint | Real-time | Serverless | Asynchronous | Batch Transform |
|---|---|---|---|---|
| Max payload | 6MB | 4MB | 1GB | Per dataset (S3) |
| Max processing time | 60 seconds | 60 seconds | 60 minutes | Per job (long runs possible) |
| Scale to 0 | Not possible (minimum 1) | Possible | Possible | Not applicable (terminates when done) |
| GPU instances | Supported | Not supported | Supported | Supported |
| How results are received | Response body | Response body | S3 + SNS notification | S3 |
⚠️ Pitfall: Serverless inference cannot use a GPU. The choice "this is deep learning inference but traffic is intermittent, so let's cut cost with serverless" doesn't hold at all if the model needs a GPU. Note that not only payload and processing time but also hardware requirements are a disqualifying condition.
① Is an immediate (synchronous) response needed?
│
├─ No ──┬─ The whole dataset at once? ──▶ Batch Transform
│ └─ Individual requests, but large or slow? ──▶ Asynchronous inference
│
└─ Yes ─┬─ Is traffic steady? ──▶ Real-time endpoint
└─ Intermittent + cold start tolerated? ──▶ Serverless inference
② Recheck the constraints: payload > 6MB or processing > 60 seconds
→ Real-time/serverless are out → Asynchronous (1GB·60 min) or Batch Transform| Scenario keyword | Answer | Basis for the decision |
|---|---|---|
| "A 50ms verdict at the moment of purchase, steady traffic" | Real-time | Latency is the top priority |
| "Internal tool, a few calls a day, mostly idle" | Serverless | Eliminates idle cost |
| "200MB image, 5-minute processing, individual requests" | Asynchronous | Exceeds payload and time constraints |
| "Score 10 million records every night" | Batch Transform | No immediacy needed + lowest cost |
| "I want a notification when processing finishes" | Asynchronous | SNS completion notification is built in |
| "I don't want to keep an endpoint up permanently" | Batch Transform | All resources are released when the job ends |
| Symptom | Cause | Action |
|---|---|---|
| Only the first serverless request is several seconds slow | Cold start (container and model load) | Pre-warm with Provisioned Concurrency, or switch to real-time |
| Real-time endpoint cost is excessive | Instances run permanently even during idle time | Serverless or async for intermittent traffic; batch for bulk jobs |
| Calls fail with timeout or payload errors | Exceeded 60 seconds or 6MB (4MB for serverless) | Move to asynchronous inference (1GB·60 min) or Batch Transform |
| A batch job doesn't get faster even with more instances | The input is a single large file that can't be split | Shard the input into multiple files and specify split_type |
| I can't tell when I'll receive the async result | The structure doesn't return a response immediately | Subscribe to the SNS completion notification + check OutputLocation |
The next article digs deep into the most central option, the real-time endpoint, covering configuration, Auto Scaling, and instance selection.
Click a choice to reveal the answer and explanation.
Question 1
A mobile game must determine whether a purchase is fraudulent within 50 ms at the moment a user taps the item purchase button. Traffic is consistently high all day. What is the most appropriate inference option?
Question 2
An internal analytics tool occasionally invokes the model (a few times a day, at irregular times). Most of the time there are no invocations, so keeping instances running all the time is wasteful. A slight delay on the first response is acceptable. What is the appropriate option?
Question 3
A medical image analysis model receives a 200 MB high-resolution image each and takes about 5 minutes to process. Requests arrive individually and the results can be received after processing completes. What is the appropriate option?
Question 4
Every night at 12:00, you compute churn probabilities for all 10 million customers and load them into a data warehouse. Real-time results are not needed at all. How do you minimize cost?
Question 5
Which is the most appropriate key characteristic that distinguishes asynchronous inference from a real-time endpoint?