Course menuAIP-C01

Exams / AIP-C01 / Study guide / Synchronous, asynchronous and batch model invocation

Synchronous, asynchronous and batch model invocation: AIP-C01 study notes and practice questions

What to know about Synchronous, asynchronous and batch model invocation for the AIP-C01 exam, from the Implementation and Integration domain (26% of the exam guide), then 1 free question to test it. Part of the AIP-C01 study guide.

Last verified against current AWS documentation ·How we write our questions

What to know for the exam

AIP-C01 gives you a client, a volume and a time budget. Choose the invocation pattern that fits all three, and avoid answers that only work for short requests.

Synchronous calls

A Converse or InvokeModel call from Lambda behind API Gateway suits interactive requests that finish within a few seconds. The REST API integration timeout is 29 seconds by default. When a generation can run longer, do not answer by raising the Lambda timeout, since the client connection still closes at the gateway. Switch to an asynchronous pattern.

Asynchronous jobs with a queue

API Gateway accepts the request, returns 202 Accepted with a job ID, and places a message on Amazon SQS. A Lambda or container worker calls the model and writes the result to DynamoDB or S3. The client polls a status endpoint, or receives a push over an API Gateway WebSocket connection or a notification. The queue also absorbs bursts, and limiting consumer concurrency keeps calls under throughput quotas.

Orchestration

AWS Step Functions can call Bedrock directly and coordinate retrieval, generation, validation and storage, with Retry and Catch on each step. Map runs items in parallel. A task token pauses the workflow until a person approves. Standard workflows suit long runs, and Express workflows suit high-volume short runs. EventBridge Pipes can connect a queue or stream to a workflow with filtering.

Batch inference

Batch inference reads JSONL input files from S3, processes them asynchronously, and writes output to S3 at a lower price than on-demand for supported models. It fits millions of records where results can wait hours, such as overnight product descriptions. It does not fit an interactive feature.

SDK settings

Set the client read timeout above the expected generation time, rely on SDK retries with exponential backoff and jitter, and use streaming when users need to see text sooner. Use the Converse API so one request shape works across models.

How to choose

Scenario wording Choose
“Chat answers in a few seconds from a web page” Synchronous Converse behind API Gateway
“Generations take about a minute and the client times out” Asynchronous job with SQS worker and status polling
“Traffic spikes must not exceed the model quota” SQS with limited consumer concurrency
“Several model steps with retries and human approval” Step Functions workflow
“Two million records processed overnight at low cost” Batch inference job
“Browser must learn the result as soon as it is ready” WebSocket push or polling

Common traps

  • Raising the Lambda timeout to fix a REST API timeout. The gateway still closes the request at its own limit.
  • Batch inference for a chat feature, which cannot return answers interactively.
  • Fan-out of many model calls inside one synchronous request.
  • Retrying long calls without idempotency, which can duplicate side effects.
  • A queue in front of interactive chat, which makes the user wait for a message to be processed.

See also: streaming and resilient APIs.

Try the 1 practice question

Question 1

Medium · choose 2 ·Link to this question (question 1)

A tax software company's assistant answers filing questions. Users type a question in a web app, and a Lambda function calls a model on Amazon Bedrock and returns the answer through an Amazon API Gateway REST API. Long answers take 45 to 60 seconds, but the REST API integration stops waiting after 29 seconds, so those users see errors.

The company has three requirements. Users must not see timeout errors on long answers, text should appear as the model writes it, and the team does not want to change the model or the web app's short requests.

Which TWO actions meet these requirements? (Choose two.)

Choose two answers.

  1. A. Stream the answer with ConverseStream from a Lambda function with response streaming, exposed through a Lambda function URL, so text reaches the browser as it is generated.
  2. B. Raise the timeout of the Lambda function to 15 minutes and keep the REST API unchanged, so that the function has time to finish long answers before the response is returned.
  3. C. Send long questions to Amazon Bedrock batch inference, which writes the answers to Amazon S3, and have the web app email the user when the file is ready.
  4. D. Keep the REST API for short requests, such as loading a user's saved filing questions, which complete well within the 29-second integration limit.
  5. E. Purchase Provisioned Throughput for the model, so that each call returns faster and stays under the 29-second integration limit without any change to the API.
Show the answer and explanation

Answers: A, D

  • A. Right: A function URL with response streaming sends text to the browser while the model writes, and it does not pass through the REST API's 29-second integration limit. The model and its settings stay the same. Learn more: Configuring a Lambda function to stream responses (opens in a new tab)
  • B. Wrong: The Lambda timeout does not change how long the REST API waits, so users still see errors after 29 seconds. The change also does nothing to show text as it is generated.
  • C. Wrong: Batch inference is designed for large offline jobs, and the answers arrive hours later, not during the session. Email delivery also does not meet the requirement for text that appears as it is written.
  • D. Right: Short calls that finish in a second or two fit the REST API, so the web app needs no change for them. This keeps the existing integration for every request that does not generate a long answer. Learn more: Choose between REST APIs and HTTP APIs (opens in a new tab)
  • E. Wrong: Provisioned Throughput reserves capacity but does not guarantee that one long answer finishes in under 29 seconds. It also does not show text as it is written, and it adds a fixed hourly cost.

Explanation

Streaming through a Lambda function URL lets long answers reach the browser as they are generated, without passing through the REST API's integration timeout. The REST API stays in place for short requests that finish quickly. Longer timeouts, batch processing and reserved capacity each leave the 29-second limit or the streaming need unmet.

Study

Want more on Synchronous, asynchronous and batch model invocation? The 5 full-length practice sets have 5 more Synchronous, asynchronous and batch model invocation questions, 375 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets

Study Synchronous, asynchronous and batch model invocation

More Implementation and Integration topics