Course contentsShow
← Cloud and Infrastructure
Lesson 487 of 2,9899. Serverless ComputeFree lesson

Function Invocation Types

Understanding synchronous, asynchronous, and stream-based invocation patterns and their use cases.

Function Invocation Types

You'll learn: How serverless functions can be triggered in different ways—synchronously, asynchronously, or via streams—and when to use each pattern.

Core Concept

When you invoke a serverless function, the cloud platform handles it in one of three main ways:

Synchronous invocation means the caller waits for your function to complete and receives the response immediately. It's like calling someone on the phone—you wait on the line for their answer.

Asynchronous invocation means the caller sends the request and moves on without waiting. The cloud platform queues your event and invokes your function later. It's like leaving a voicemail—you don't wait for a reply.

Stream-based invocation processes records from a data stream in batches. The function polls the stream continuously and processes chunks of records. Think of it like reading messages from a conveyor belt—you grab a batch, process them, then grab the next batch.

When to Use Each Pattern

  • Synchronous: API requests, real-time data transformations, webhooks where the caller needs an immediate response
  • Asynchronous: Background processing, sending notifications, file processing where the caller doesn't need to wait
  • Stream-based: Processing logs, analytics pipelines, change data capture from databases where you handle continuous data flows

Why This Matters

Choosing the right invocation type affects your function's reliability, retry behavior, and how errors are handled. Synchronous calls fail immediately if your function errors. Asynchronous calls retry automatically. Stream-based invocations process records in order and checkpoint progress.

Key Takeaway: Functions support three invocation types—synchronous for immediate responses, asynchronous for fire-and-forget tasks, and stream-based for continuous data processing—each optimized for different use cases and retry behaviors.