Nowadays serverless computing is gaining a lot of popularity, due to its rapid growth. You might have already heard about AWS Lambda, the serverless compute service. Similarly, AWS has one more such service known as AWS Step Functions which is based on the concept of state machines and tasks.
In this blog, we will discuss AWS Step Functions so that we get more familiar with it. We will cover the following topics:
- What is AWS Step Functions?
- Overview Of Step Functions
- Features
- Working Of Step Functions
- Steps to create a State Machine
- AWS Step Functions Pricing
- Frequently Asked Questions
Also, if you want to know about AWS Lambda
What is AWS Step Functions?
- Step Functions allow you to create workflows that follow a fixed or dynamic sequence aka steps. That’s where the step name comes from.
- It provides serverless orchestration for modern applications.
- Step Functions are built up of state machines i.e.workflows and tasks.
- Built-in retry functionality i.e. doesn’t progress until success.
- Native integration with AWS services such as Lambda & SNS, SQS, Dynamo, and many others.
- GUI for auditing workflow process, input/output, etc.
- It is highly scalable and low in cost ( $0.025 / 1000 state transitions).
Overview of Step Functions
As already mentioned above AWS Step Function is based on the concept of State Machines and Tasks. Let’s try to understand these two terms first.
State Machines
- State Machine is a behavioral model that expresses algorithms as a finite number of states.
- These are also called Finite – State Machines (FSM)
- The state machines are defined using JSON based Amazon States Language
- A state is addressed by a name and it must be unique within the entire state machine.
There are different state types and all of them play an important role in the overall workflow
- Pass: This state pushes input to output.
- Choice: This state allows the user to make the choice among branches of execution on the basis of the output.
- Wait: This state provides a delay in state machine execution for some specified period of time.
- Fail: This state stops the execution with a failure because of an expected dead end.
- Success: This state stops the execution with success.
- Wait: This state provides a delay in state machine execution for either specified or until a specified period of time.
- Parallel: This state allows the user to start parallel branches of execution which mean the user can start many states simultaneously.
- Task: This state performs some task in the state machine.
- Mapping: For every input, this state runs some set of steps.
Tasks
- Tasks are those single units in which all the work is done.
- Tasks perform works by calling Activities, AWS Lambda, or API actions of other services by passing parameters.
- Tasks can even call an execution on EC2, ECS machines.
- Send SMS notifications and wait for the input.
Also Read Our blog post on AWS Secrets Manager.
Features
With AWS Step Function, application development has become quite fast as you are able to manage the workflow of your application independently from the business logic, and these workflows can be updated and modified very easily. No excess code is required which makes your applications faster and can be easily maintained. Some of the major features of AWS Step Functions are listed and explained below.
- Build and Update Apps quickly: With AWS Step Function you can build applications in minutes and if some changes are required in the application you can do it without updating the code but by reorganizing or exchanging the components.
- Improved Resiliency: Due to the resilient nature of AWS Step Functions, it easily deals with errors and exceptions due to retry and rollback capabilities. As AWS Step Functions manage state so it makes sure that the application executes in an appropriate manner.
- Write less code: AWS Step Functions removes the extra or the repeated code in your functions and performs branching, parallel execution, and timeouts. Thus managing the logic of your application.
- State Management: With AWS Step Functions you don’t have to worry about managing the states. AWS Step Functions manages the states, keeps track of the state during execution, and also store the data.
- Visual Monitoring: After launching the application you can visually monitor each step being executed and ensure everything is working in order as it should. Errors if any are also displayed so that you can understand them and fix them.
Check Out: Our blog post on AWS Storage.
Working of Step Functions
The diagram below explains the working of AWS Step Functions
Also Check: Our blog post on AWS Auto Scaling.
Steps to Create a State Machine
1) Log in to your AWS account by clicking here
Note: If you have not created the free tier account yet, please check this blog. How to create a free tier account
2) In the search box type Step Functions and click on it.
3) Click on the Hamburger menu on the left side.
4) Now click on State Machines
5) Here, click on Create State Machine
6) Under Define state machine selects Author with code snippets, and under Type select Standard
7) Now insert the JSON code, on the basis of which your state machine (workflow) will be created
8) Now you will see based on the JSON code a State diagram has been created on the right side
Note: This State diagram basically explains to us how our code shall execute step by step depending on the actions.
9) Now click on Next
10) Under Specify details provide any name to your state machine, and under Permissions select Create a role, by this AWS will automatically create a role for the permissions required by State Machines for you
11) Let everything default, scroll down and click on Create State machine
12) Now you shall see a message prompting that the State machine successfully created
So, these were the steps for creating a State Machine using AWS Steps Function.
Also Check: Our previous blog post on AWS IoT.
AWS Step Functions Pricing
Each time you execute your workflow, a state transition is counted. With AWS Step Functions you are basically charged on the number of state transitions needed to execute the workflow. You will be charged for all the state transitions happening in every state machine even retries. As far as the free tier is concerned, it includes 4000 free state transitions per month. Click here to get more insights about AWS Step Functions pricing.
Check Out: Our blog post on AWS Azure GCP Service Comparison.
Frequently Asked Questions
What are some common AWS Step Functions use cases?
AWS Step Functions helps with any computational problem or business process that can be subdivided into a series of steps. It’s also useful for creating end-to-end workflows to manage jobs with interdependencies. Common use cases include: Data processing: consolidate data from multiple databases into unified reports, refine and reduce large data sets into useful formats, or coordinate multi-step analytics and machine learning workflows DevOps and IT automation: build tools for continuous integration and continuous deployment or create event-driven applications that automatically respond to changes in infrastructure E-commerce: automate mission-critical business processes, such as order fulfillment and inventory tracking Web applications: implement robust user registration processes and sign-on authentication
What language does AWS Step Functions use?
AWS Step Functions state machines are defined in JSON using the declarative Amazon States Language. To create an activity worker, you may use any programming language, as long as you can communicate with AWS Step Functions using web service APIs. For convenience, you may use an AWS SDK in the language of your choosing. AWS Lambda supports code written in Node.js (JavaScript), Python, Golang (Go), and C# (using the .NET Core runtime and other languages)
How does AWS Step Functions connect and coordinate other AWS services?
Workflows that you create with AWS Step Functions can connect and coordinate other AWS services using service tasks. For example, you can: Invoke an AWS Lambda function Run an Amazon Elastic Container Service or AWS Fargate task Get an existing item from an Amazon DynamoDB table or put a new item into a DynamoDB table Submit an AWS Batch job and wait for it to complete Publish a message to an Amazon SNS topic Send a message to an Amazon SQS queue Start an AWS Glue job run Create an Amazon SageMaker job to train a machine learning model or batch transform a data set
Related Links/References
- Overview of Amazon Web Services & Concepts
- How to Create a free tier Account in AWS
- AWS Management Console Walkthrough
- AWS Solution Architect Certification [SAA-C03]
Next Task For You
Begin your journey toward becoming an AWS Data Engineer by clicking on the below image and joining the waitlist.
Leave a Reply