AWS Lambda and Step Functions: The Power of Serverless Computing

AWS Lambda and Step Functions: The Power of Serverless Computing

Lambda Functions

AWS Lambda is a computing service that allows you to run your code without the need to set up or handle servers. With AWS Lambda, your code is executed only when it's required and can scale automatically from handling a handful of requests per day to thousands of requests per second. Additionally, you're only charged for the amount of computing time that you actually use.

Lambda Triggers

There are multiple ways to invoke lambda functions, directly calling the API or by using Triggers. When setting up a trigger, there are two main models.

  • PUSH
  • PULL

The push model, is where a trigger sends an event to lambda, which then invokes your lambda function. In this model trigger can be an end user or any automated script that calls AWS lambda function.

No alt text provided for this image

The second model is the pull model. Some AWS Services being configured as triggers for lambda functions.?A common example of a trigger that follows this model is Amazon Simple Queue Service (SQS). SQS allows messages to build up in a queue, and then your code would process those messages.

In below flow we have lambda function that call AWS simple queue service (SQS) to get the data/messages, basically queue have data that comes from another AWS service or process to AWS (SQS) so it can be process later by other lambda function or process.

No alt text provided for this image

Step Functions

Step functions provide work flow automation consists of multiple lambda functions. Workflow build with step functions called as state machine that can be defined by using JSON. Basically state machine contain the execution order of AWS services like lambda functions. With the help of state machine we no longer need to make the decision inside the lambda functions.

No alt text provided for this image

Above step function flow have 2 lambda functions. First is ValidateDragon that will check the existence of new record, if incoming record is new then step function invoke AddDragon and in both cases our state machine passes the information to Amazon SNS related to occurred events (Record inserted or Already Exists)

Below is the visual flow of step functions in AWS. We will focus on implementation detail in upcoming article.

No alt text provided for this image


Step Functions State Types

Along with execution order it provide multiple options to use in flow below are some important one.

  • Make a choice between branches of execution (a Choice state) (which lambda to execute base on if else)

No alt text provided for this image

  • Begin parallel branches of execution (a Parallel state)

No alt text provided for this image

  • Provide a delay for a certain amount of time or until a specified time/date (a Wait state)

No alt text provided for this image

要查看或添加评论,请登录

Tabish Manzoor的更多文章

社区洞察

其他会员也浏览了