AWS Lambda and Step Functions: The Power of Serverless Computing
Tabish Manzoor
Software Engineer | Generative AI | C# | Asp.net mvc | .Net Core | Fintech | Microservices | Database Design | Docker
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.
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.
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.
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.
领英推荐
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.
Step Functions State Types
Along with execution order it provide multiple options to use in flow below are some important one.