AWS Step Functions Use Cases

As you probably already know, Step Functions is a serverless Workflow Service provided by Amazon Web Services (AWS). There’s a lot to discuss about this service, and you’ll find plenty of vital information in our AWS Step Functions: The Ultimate Guide as well as in our series of articles that’ll dive deep into various aspects regarding this AWS service.

Moreover, if you’re eager to learn more about cloud computing, make sure to register for AWS re:Invent virtual event where you’ll hear a lot from AWS experts and cloud leaders about what’s new and what’s coming up next from AWS or feel free to browse our extensive Knowledge Base.

We’ll dive deep into Step Functions’ benefits and shortcomings in today’s article, but our primary focus goes to the best Step Functions use cases.

Quick Reminder About Step Functions

Step Functions are utilized with AWS Lambda. You’ll write little pieces of code into Lambda, and then you’ll stitch them all together with Step Functions. Moreover, Step Functions provide some advanced capabilities like multiple task execution in parallel and then wait for a specified period of time before proceeding.

They’re quite useful for orchestrating multiple small tasks that’ll help you build complex workflows. Step Functions are completely serverless, and this means that users won’t have to worry about scaling up or down the resources when the incoming requests decrease or increase because Step functions will take care of it all.

Now, let’s discuss the benefits of using Step Functions, so you’ll later better understand Step Functions use cases.

Benefits of Using Step Functions

These are some of the benefits worth mentioning since they’ll help you figure out the things that make Step Functions so much important.

Auto Scaling is Possible

Whenever you come across a drop in incoming requests or a surge, Step Functions will immediately allocate or deallocate the required resources for executing the workflows.

It Has a Modular Code

Considering that the entire business workflow is broken down into small Lambda functions, every Lambda function focuses on a small, independent piece of logic. This logic makes the code much more readable. It’s also incredibly helpful with writing separate, small, and reusable AWS Lambda functions that can easily be plugged into different Step Functions.

Importance of Maintainability & Testability

Since the logic in every Step Function’s Lambda function is small, it’s much easier to write test cases for every one of them. Moreover, it’s vital to know that all Lambda functions can be deployed independently.

It Allows Development in Various Languages

Because Step Functions communicate with independent Lambda functions, these Lambda functions can integrate into many supported programming languages like Java, NodeJS, Python, etc. Therefore, one Step Function can be made out of code written in more than a single language.

Code Reusability is Possible

Workflows usually involve conditional code execution, which means that if the reimbursement amount is lower than $10 within the reimbursement workflow, it’ll be reimbursed directly, or it’ll notify person X. Therefore, you’ll have to write a single Lambda function to get the reimbursement amount, another Lambda function that’ll inform a person, and one more to do the reimbursement. After writing these three Lambdas, you can connect them via Conditions within the Step Functions. Now, you can reuse the second Lambda function in any other Step Function to send notifications.

Step Functions are Resilient

Step Functions can manage restarts, state, and checkpoints. They also provide built-in try or catch, rollback, and retry features to help you automatically deal with exceptions or errors.

Challenges of Using Step Functions

Although we’ve seen some of the most beneficial aspects of using Step Functions, there are some other areas of concern. For example:

Self-Service User Interface Isn’t Great

While this might not be a shortcoming of Step Functions service per se, the Step Functions defining console isn’t very user-friendly since it makes it difficult to validate or edit the definitions.

Pricing Based Per Transition

AWS charges are based on the number of transitions happening during the Step Function execution. Therefore, if you have a one-step Step Function, you’ll be charged one unit. On the other hand, if you have a complex 30-step function, you’ll be charged staggering 30 units per each execution. Since users usually know the number of workflow executions, this method makes it quite challenging to make initial cost estimations. In case Step Functions charges were designed to operate per workflow-execution instead of their current charge method (per-state-transition), it might’ve been much more straightforward.

Read more about about how to cut cost on Step Functions.

Basic Condition Checks

Condition nodes within Step Functions are pretty basic. Since December 2019, they support comparing variables with constants, but you won’t be able to compare two variables since this option isn’t supported. Therefore, you won’t be able to compare the output of a Lambda function with an input variable, nor you’ll be able to compare the output of two Lambda functions. Additionally, a bit more complex logical conditions don’t work either.

Now that you’re aware of both upsides and downsides of using Step Functions, we’ll turn to actual Step Function use cases.

AWS Step Function Use Cases

AWS Step Functions are excellent for handling all sorts of workflows or processes that require coordination of multiple services to accomplish a higher-level task. This is especially true in cases where you have to control the information flow and process execution based on results and/or rules from all previous tasks.

These are some workload examples that can bring quite useful results from utilizing Step Functions:

AI and ETL Jobs

Extract, Transform, and Load (ETL) jobs have become pretty standard in numerous apps and companies. The significant rise of AI and data analytics tools made it almost inevitable to deal with vast amounts of data. It often happens that all these data points need to be manipulated in multiple steps before becoming analysis-ready.

example of ETL jobs

The same goes for Deep Learning and Machine Learning tasks. These tasks usually involve processing pipelines in which you have to follow a series of steps before reaching a classification or prediction result.

Step Functions are excellent for solving these needs since they’re connected to other services like AWS Batch or AWS Lambda, and they’ll run custom logic upon the data. Moreover, Step Functions will ultimately use DynamoDB and S3 to retrieve and store all information along with workflow processing.

Orchestrating Microservices

All applications that implement microservices architecture will significantly benefit from Step Functions. What happens is that they’ll simplify the orchestration work. Composing higher-level tasks is possible, thanks to multiple well-coordinated services in a decoupled but centralized manner.

Rules and complex logic apply to the workflow so they would account for exceptional cases. The “retry mechanism” that’s embedded into Step Functions, including integration services like AWS Lambda, makes it much easier to implement composition strategies like fault-tolerant microservices.

Parallel Processing (Fan-Out)

Step Functions can also be used for processing several tasks in parallel or even to control the fan-out process of tasks that need a breakdown. All this is required so that these tasks could be tackled in small steps.

Datapoint List Handling

Step Functions also support logic for loops. You can implement this feature when there’s a list of data points that have to be processed in a similar but independent way. Moreover, you can design the same workflow for the entire list, but note that Step Functions will process each item sequentially and separately.

Step Functions are excellent in other use case examples as well, and here are the most important ones:

Very Straightforward Integration with Manual Tasks

AWS Step Functions service is the best solution for coordinating a workflow requiring manual intervention/approval. A good example is “Employee Promotion Process.” For this process to be completed successfully, it requires the manager’s approval. That’s where Step Functions comes in. It’ll send the email via AWS SES service with a “Approve” or “Reject” link, and once it’s received, it’ll trigger another action using ECS jobs or Lambda.

Batch Job Processing

In case your workflow requires sequential processing and data coordination, sequential batch job processing is the best solution. For example, on an e-commerce website, the first job is to access and read the product data, while the next job will discover which products will soon be out of stock, and then, the third job will notify all vendors so they could expedite the upcoming supply process.

Step Functions: Example of Batch Job Processing
Step Functions: Example of Batch Job Processing

Coordinating Container Tasks in Serverless Workflow

AWS Step Functions are capable of helping you make decisions on how to process the data in the best way possible. By looking at the file size, you can either choose to utilize ECS, Lambda, or even on-premise activity so you could successfully optimize both runtime and the cost.

Real-Life Step Function Use Cases

Long Sequences: If your workflow has a long sequence of steps, it means that it’s never a good idea to place all the logic in a single codebase. Ordering workflow involves several steps when the user places his order, and the steps are as follows:

Waiting for payment to succeed —> Generating Invoice —> Sending email —> Sending SMS —> Deducting from Inventory —> Starting Shipment —> Creating Tracking Info.

Async Operations: You can also check for the completion of async operations by polling. If your logic is third-party service operation-dependent, and you don’t know how much time it requires, don’t wait for the process to complete synchronously. What you should do instead is trigger a Step Function upon calling the third-party service. The Step Function can then check the operation status at regular intervals until the successful completion of this operation. Step Function will notify the client when the process is completed successfully.

Larger companies with multiple teams that work on each step can find it more difficult. If that’s your case, you should define several Lambda functions for each step and combine them through a single Step function. Every Lambda function can easily be both developed and maintained by different teams or developers.

Wrapping Up

Our final verdict regarding Step Function actual use cases is that it can come in quite handy by successfully managing business workflows. The only thing developers have to worry about is the core logic, and Step Functions will take care of things like scaling, hosting, configurations, etc. Step Functions as a service is still growing, and it may evolve into a perfect solution for any business workflow management in the upcoming years.

Don’t forget that you can also monitor your Step Functions (both standard and express workflows) with Dashbird and start receiving Well-Architected insights on how to optimize them even better for cost efficiency and operational excellence. You can try it out for free by signing up here. 2-minute easy setup, no credit card required, no code changes and you can cancel any time. (Psst, we also have an early Black Friday deal: you can use code BLACK2020 an checkout to get your first 2 months for free)

Read our blog

Dashbird + AppSync = Monitor Your GraphQL APIs with Simplicity

Dashbird has just added support for AppSync to help you monitor all of your AppSync endpoints without needing to browse dozens of logs or stumble through traces in the X-Ray UI.

AWS AppSync as a Gateway to Your Cloud Infrastructure

This article will discuss AppSync, AWS’s managed GraphQL service. Read on if you’re building a new backend or want to see if there is a more refined solution to the gateway problem than ELB and API Gateway.

How to Monitor Your AWS RDS Instances

In this article, we’ll cover all the steps for creating proper monitoring for your RDS instances by starting with metrics and performance guidelines.
We will also compare the monitoring options offered by AWS with Dashbird’s simple but nevertheless all-encompassing approach.

Made by developers for developers

Dashbird was born out of our own need for an enhanced serverless debugging and monitoring tool, and we take pride in being developers.

What our customers say

Dashbird gives us a simple and easy to use tool to have peace of mind and know that all of our Serverless functions are running correctly. We are instantly aware now if there’s a problem. We love the fact that we have enough information in the Slack notification itself to take appropriate action immediately and know exactly where the issue occurred.

Thanks to Dashbird the time to discover the occurrence of an issue reduced from 2-4 hours to a matter of seconds or minutes. It also means that hundreds of dollars are saved every month.

Great onboarding: it takes just a couple of minutes to connect an AWS account to an organization in Dashbird. The UI is clean and gives a good overview of what is happening with the Lambdas and API Gateways in the account.

I mean, it is just extremely time-saving. It’s so efficient! I don’t think it’s an exaggeration or dramatic to say that Dashbird has been a lifesaver for us.

Dashbird provides an easier interface to monitor and debug problems with our Lambdas. Relevant logs are simple to find and view. Dashbird’s support has been good, and they take product suggestions with grace.

Great UI. Easy to navigate through CloudWatch logs. Simple setup.

Dashbird helped us refine the size of our Lambdas, resulting in significantly reduced costs. We have Dashbird alert us in seconds via email when any of our functions behaves abnormally. Their app immediately makes the cause and severity of errors obvious.