Invocation Patterns - Serverless Architectures with AWS Lambda

Invocation Patterns

There are two models for invoking a Lambda function:

  • Push Model – Your Lambda function is invoked every time a particular event occurs within another AWS service (for example, a new object is added to an S3 bucket).

  • Pull Model – Lambda polls a data source and invokes your function with any new records that arrive at the data source, batching new records together in a single function invocation (for example, new records in an Amazon Kinesis or Amazon DynamoDB stream).

    Also, a Lambda function can be executed synchronously or asynchronously. You choose this using the parameter InvocationType that’s provided when invoking a Lambda function. This parameter has three possible values:

  • RequestResponse – Execute synchronously.

  • Event – Execute asynchronously.

  • DryRun – Test that the invocation is permitted for the caller, but don’t execute the function.

Each event source dictates how your function can be invoked. The event source is also responsible for crafting its own event parameter, as we discussed earlier.

The following tables provide details about how some of the more popular event sources can integrate with your Lambda functions. You can find the full list of supported event sources here.