Bulletproof Workflows with Temporal | Microservices orchestration the easy way

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I'm going to show you how we can create a bulletproof workflow in our favorite programming language with temporal buckle up let's start what's the important temporal is an open source runtime for managing distributed application status scale in other ways temporal is a solution to create and manage complex business workflows in a distributed system such it is the case in our microservices architecture or highly available monolithic application the two main selling points of temporal are it promises us to code smarter and faster we can pick our favorite language between Java core python typescript PHP and many more are on the way and Define the business logic in workflow and activity functions there is virtually no learning curve because we can use the native constructs of the programming language rather than a complicated framework the temporary runtime Max all the Fe lifting involved in executing the workflows it receives workflow execution requests schedule is then best is their state and communicates with all the relevant workers services Top that with the wonderful administrative panel that gives you full visibility on workflows and their state as well as management functions such as the ability to terminate a workflow this is massive this is a game changer temporal is addressing the pain points we find when we try to implement complex workflows in a distributed system temporal acts as the orchestrator in The Saga pattern as developers we are relieved from having to implement three tries timeouts and most importantly Texas State while the workflow is executing we get this out of the box that means that our workflows are resilient and durable a workflowing them portal can last hours days or even months the next question is how does it work The Core Concepts of temporal are workflows and activities the workflow represents the business process we want to model we could have a workflow to model orders in an online shop the activities represent the logical steps we need to perform in the workflow such as receiving a product from the inventory or booking Logistics a workflow in temporal is just a function written in our favorite programming language that uses the temporal SDK to interact with the temporal server as we already mentioned we can choose any language we wish in this particular video I'm going to slip to Java but please continue watching the video Even if you intend to use another programming language I'm just explaining the concepts this is not a step-by-step tutorial this is an example of a basic order workflow as you can see it's very readable any programmer can figure out what's happening without too much indulging we deserve products from inventory book Logistics wait for the package to be delivered and send a notification asking a review of the product one day after the delivery has been confirmed they were flow as a typo name and most importantly its code must be deterministic that means that given the same input values the function must generate the same commands in the same sequence all pieces of logic that are non-deterministic like those that would fail like invoking another service or storing data on a database must be enclosed in activities smaller tasks which we do not expect to fail but are still non-deterministic such as generating a random value are wrapped inside the effects the reason why where flaws must be deterministic is that they are replayed multiple times before their completion this is where you need to focus because this concept is not straightforward when we request a workflow execution the temporal server is responsible to store the necessary data and schedule its success foreign server does not actually know how to execute the workflow or what activities are part of it these are defined in our own code base and deployed in our applications known as workers each worker is following those skills and executing the relative tasks when our worker executes our flow function the execution is not done from start to end immediately anytime we walk an activity or other SDK method like side effect or weight we interact with the temporal server which decides whether we continue execution always stop and give control back to the orchestrator if the requested activity was already executed the temporal server would fetch its results from the event block and give it back to the workflow function that can continue its execution if the activity was never executed the temporary service schedules the activity execution waste for a worker to complete it and store its result once this is done the temporary server is going to schedule a replay of the workflow the workflow is replayed and stops anytime we need to execute a new activity or we want to wait for a specific condition or amount of time all the complexity of interactions with the temporal server or another orchestrator are abstracted by the SDK we don't need to define apis or events the integration piping is all obstructed to us and we can focus on defining the business logic another two important features of temporal are signals and timers a signal is a message sent to the workflow which can be used to change its state and control its execution flow if we look at our order workflow we wait for the package to be delivered with just one line of code using the await command the workflow will wait until the delivery flag is set to true however the question is how will the Boolean flag change its value from false to true that's exactly a perfect use case for a signal method we can have another micro service and the signal or even a human operator can work on the web UI we call this a delivered method and that unblocks the workflow execution timers are safe explanatory rather than waiting for a condition we wait for an amount of time it could be one second one hour one day or even one year implementing this ABAB without temporal would require persistence message Brokers it would be quite complex instead we can just Leverage The SDK and focus on the business logic getting started with temporal is releasing if you just want to try it out you can leverage the temporal lcli this is an executable that combines a lightweight server with the UI and lets you be up and running in few seconds if you want to deploy the full infrastructure you can reference their Docker compost repository any are you also find kubernetes manifest finally my favorite option is to use the temporal cloud service they take care of the temporal infrastructure and you can get started with coding your workflows without having to care for operations it's pepper use thus there is no upfront license to buy which is great as you know I like to keep these videos up to 10 minutes so I'm going to stop here however if you want a more in-depth tutorial leave me a comment I know that in this period I'm not creating too many videos but I read your comments and I do my best to answer your questions like subscribe and share and now it's time to learn something new foreign [Music]
Info
Channel: Marco Lenzo
Views: 8,514
Rating: undefined out of 5
Keywords:
Id: LulonIoYOP8
Channel Id: undefined
Length: 8min 34sec (514 seconds)
Published: Sat May 20 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.