<https://twitter.com/shivenz/status/14487218351436...
# random
a
More info.
k
Can someone enlighten me and tell me in what use cases I would use step functions? this might sound dumb but I might not have read about them enough. 😂
a
I have same question @Kujtim Hoxha
t
Yeah I was a bit confused by them at first too. They're great for coordinating a workflow of multiple steps. For example if you need to 1. Fetch a list of urls from an endpoint 2. For each item returned, spin up a lambda to fetch the html 3. For each of those count the number of words there are 4. Aggregate to a final count You can coordinate this with step functions so that steps 2+3 are run in massive parallel. Recently they added support for steps that just call an api method on an AWS service
Ultimately it's just another programming language, just more limited but because of those limitations, AWS can do some interesting things automatically for you
a
@thdxr so this coordination is on code?
t
It's using a declarative structure, not exactly like code
But very similar
a
But where is that stored?
Is that in CDK too?
Also, where that logic lives? is not infra, or is it?
t
Yeah you can do it through cdk. We've been trying to think of a good abstraction over it so it feels more like code
It's mostly in infra but your steps can be custom lambda functions
a
Nice.
Yes, the steps will be normal lambdas, but the workflow definition, want to see how is that stored/organized.
g
I use Step functions very often. I use for solve all asyncronous job, in particular I use it more often to: • Run a job when some event happen (for example when an api invocation imply a data elaboration which is not related to the api response, in this scenario I run a state machine on api invocation to perform all task, in this way I can close the http request fast (and I don’t reach 30 seconds limit on. api gateway) • Time Scheduler, using WAIT task is possibile to pause the state machine specifing “seconds to wait” or “timestamp to wait”
ö
@gio Does it cost much?
t
I use it in the same way, anywhere that I can't guarantee an instant response I kick off a step function instead
k
@thdxr are there any good abstractions on their way for sst to use step functions
t
We don't have any great ideas haha. We might start off with something small just to get the custom lambda step feeling less verbose
I need to understand the underlying spec better, see if it fits into a chaining type api
k
So when you say
I use it in the same way, anywhere that I can't guarantee an instant response I kick off a step function instead
Do you mean the last step before you return the api call is start a workflow that does behind the scene stuff. My current solution for that is EventBridge and SqS so basically I send an event out and have queues for handling those async things
Thinking maybe stepfunctions are a better solution
Plus no pulling needed for the SQS stuff
t
Yeah it's faster but you don't get the nice retry stuff automatically that you get with sqs
I actually recently just refactored something away from SFN to sqs
just depends on the situation
k
Got it, so basically like everything else it is good for some things 😂
t
yep lol
g
Step functions is a cool product but it’s very expensive: • 0.025 USD per 1000 state transaction for Standard workflow (no time execution limit, usable as time scheduler) • 1 USD per 1 milion request for Express workflow (5 minutes max execution time) I never had experience with SQS+Eventbridge, but it could be a cheaper solution as simple time scheduler.
a
It’s the cloud, who cares about price? 😂
g
If you are a freelancer of course AWS is a no profit company 😂