AWS Lambda Invocations
There are two types of invocation
Synchronous
With synchronous invocation, the request to execute an AWS Lambda function is sent directly to the service, the function is executed, and the response is returned within the specified timeframe.
Key points about synchronous Lambda invocation:
?? The caller sends the request to Lambda and waits for the function to complete before receiving the response.
?? The function must finish executing within the configured timeout (up to 15 minutes) for the caller to receive a response.
?? If the function exceeds the timeout, the caller receives an error response.This is useful for request-response style interactions, where the caller needs an immediate answer from the function.
?? Examples of services that can invoke Lambda functions synchronously include API Gateway, Application Load Balancer, and AWS SDKs.
Synchronous invocation provides a tightly-coupled, low-latency way to execute serverless workloads on AWS Lambda. It allows your applications to get a direct response from the function, which is important for use cases like web applications, APIs, or real-time data processing.
领英推荐
Asynchronous
With asynchronous invocation, the request to execute an AWS Lambda function is first queued, and then the function is executed on a different timeline, independent of the original request. This means that the caller does not have to wait for the function to complete before moving on to the next task.
Some key points about asynchronous Lambda invocation:
?? The request is added to an event queue, and Lambda will execute the function as soon as resources become available.
?? The caller receives a success response immediately, without waiting for the function to finish executing.
?? This is useful for event-driven architectures, batch processing, or any scenario where the caller does not need an immediate response.
?? Examples of services that can invoke Lambda functions asynchronously include S3, SNS, CloudWatch Events, and SQS.
Asynchronous invocation provides a decoupled, scalable, and fault-tolerant approach to executing serverless workloads on AWS Lambda. It allows your applications to scale efficiently and respond to events in near real-time, without being constrained by the duration of function execution.