Announcing AWS Step Functions - December 2016 Monthly Webinar Series

  • Published on
    08-Jan-2017

  • View
    429

  • Download
    0

Embed Size (px)

Transcript

  • Enterprise Resource PlanningFinanceInventoryManu-facturingSales

    From Monoliths to Microservices to Functions

    Many of you have already or perhaps are about to experience this journey?

    Applications being built on a human scale. From the firm the monolith--to departments, to individuals, to tasks

    And it makes technical sense, too. Greater flexibility, more resilient, *

  • Modern Serverless app

    In 2014, the launch of AWS Lambda expanded our minds, with its core idea of a stateless function in the cloud, reacting to an event.

    But there arent that many apps with only one function, one entry point, one module, one component. So therell be more than one function. NEXT

    In fact, I suspect that itll be common to have LOTS of functions, lots of them talking to each other. NEXT

    And in fact applications, serverless or not, tend to have databases. NEXT

    And in the cloud, I notice that a lot of them have queues of one kind or another that gold thing is the iconfor Amazon Simple Queue Service, SQS, which I sometimes work on, and which Im seeing a lot of in Cloud-Native apps. NEXT

    And, now Im going to do something thats maybe in bad taste. This is the serverless track, but the world still does have servers. And this is a cloud conference, but some of those servers arent in the cloud. NEXT

    Now were starting to see a picture of what an actual modern serverless app might really look like.*

  • Modern Serverless app

    Youll notice that those arrows are in different colors thats because there are lots of ways for functions and other serverless components to talk with each other and control each other and orchestrate each other. Before we dive into the how, lets talk about WHAT we want to do with functions when we have more than one.*

  • I want to sequence functionsI want to select functions based on dataI want to retry functionsI want try/catch/finallyI have code that runs for hoursI want to run functions in parallelFunctions into apps

    These are the things that people are trying to accomplish with those different-colored arrows, and Im not gonna spend too much time diving in, because each one will get a little love of its own as we go through this story. But I suspect anyone whos tried to build a nontrivial serverless app around functions in the cloud has dealt with a few of these problems. I know I have. So what are the techniques that people are using today to make these things happen?

    *

  • Scales outDoesnt lose stateDeals with errors/timeoutsEasy to build & operateAuditable

    Coordination must-haves

    So what Im saying is that function co-ordination in the serverless world is possible, but its too ad-hoc and too difficult. So if we were going to automate all that, what are the must-haves. I suspect most fo these are pretty non-controversial or rather crushingly obvious, but I think its the last two that are really important. The things were trying to accomplish are easy to describe in words, so they should be easy for a developer to accomplish. And one of the things that *none* of the ad-hoc alternatives have is a good audit trail or log file.

    So, anyhow, that list is exactly what this announcement and this talk are all about.*

  • AWS Step Functionsmakes it easy to coordinate the components of distributed applications using visual workflows.

    AWS Step Functions makes it easy to coordinate the components of distributed applications using visual workflows. *

  • Benefits of AWS Step FunctionsDiagnose and debug problems fasterAdapt to changeEasy to connect and coordinate distributed components and microservices to quickly create appsManages the operations and infrastructure of service coordination to ensure availability at scale, and under failureProductivityAgilityResilience

    ProductivitySpend more time thinking about innovating the business logic that makes your application unique, and your applications are easier to operate and maintain.AgilityAWS Step Functions records a history of each execution, so you can review in one place, all the events in sequence, in one location. Scale instantly from one execution to hundreds of thousands of concurrent executions, especially when used with other serverless AWS resources such as AWS Lambda, Amazon S3, and Amazon DynamoDB. With AWS Step Functions, you pay only for what you use, when you use it.ResilienceAWS Step Functions supports automatic error handling for graceful exits, and operates at scale without you needing to configure or manage its underlying resources.*

  • How Does AWS Step Functions Work?

  • Application Lifecycle in AWS Step FunctionsVisualize in the ConsoleDefine in JSONMonitor ExecutionsAmazon Confidential

    With AWS Step Functions, you define your workflow as a series of steps and transitions between each step, also known as a state machine.

    In Step Functions, we call these states and state transitions. A simple state machine looks like this, and you define it using simple commands in JSON.

    When you start a state machine, you pass it input in the form of JSON, and each state changes or adds to this JSON blob as output, which becomes input to the next state. The console provides this visualization and uses it to provide near-real-time information on your state machine execution.

    Lets look at each of these more closely.*

  • Define in JSON and Then Visualize in the Console{ Comment: Hello World Example", "StartAt : "HelloWorld, "States : { "HelloWorld : { "Type : "Task", "Resource : "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTION_NAME, "End : true } }}

    This is a classic Hello World example. This code on the left, generates this graph on the right.

    We specify where we start, we define each state, and we define each state transition. And then we get back to working on the code that makes our apps unque.*

  • Execute One or One Million

    Ill talk a lot about individual state machines and single executions.

    The power of Step Functions is that you can define a state machine once, and then run thousands and thousand of concurrent executions.

    This allows you to break down big tasks into a set of smaller, simpler tasks.*

  • Monitor Executions from the Console

    The console provides all kinds of information. Anything you see in the console, with the exception of the graph, is also accessible through the API. Lets step through the elements. In the upper right, I can tab between my graph and my JSON code. This graph is color coded to show me successfully executed states, my current state in progress, failed states, or states not passed during exection.

    In the upper right panel, I get details about my execution. I can see general info, the input I gave to the execution, in the form of JSON key/value pairs, and the final output of the execution. The Step Details toggle at the bottom, allows me to inspect individual states. I can see the input and the output state by state. This is really useful in debugging when something unexpected occurs.

    Finally, at the bottom is the complete history my execution, step by step with timestamps. Again, this is accessible from the API as well as the console.*

  • Monitor Executions from Amazon CloudWatch

    I can also set up Amazon CloudWatch to monitor my executions. Here I am monitoring a different state machine that invoked an AWS Lambda function about 70 times per minute and I can see that the Lambda functions each executed in about 200 300 mS.*

  • I want to sequence functionsAWS Step Functions, we can easily change and iterate on the application workflow of our food delivery service in order to optimize operations and continually improve delivery times. AWS Step Functions lets us dynamically scale the steps in our food delivery algorithm so we can manage spikes in customer orders and meet demand. Mathias Nitzsche, CTO, foodpanda

    FoodPanda is a take-out food service that is focusing on the developing world, and are really making excellent use of Cloud Infrastructure. They have been in the Step Functions beta, and their problem is deceptively simple. They get food orders and have delivery people and get the dinners taken to the hungry. Of course, optimizing this which requires solving the NP-complete traveling salesman problem, but theyre you know, smart. Anyhow, they want to do this with Lambda functions.*

  • So heres the actual state machine they built. Most of the states are executed by Lambda tasks. But I want to zero in on one small part of the problem, in the middle there where they run their assignment code and then dispatch a vehicle. Which is an obvious basic thing that many people want to do all the time; run this Lambda function, then run another. So lets zero on in a small state machine that does just that. Also, if I only look at those two states, Ill have something small enough to fit all of on one slide.*

  • I dont feel the slightest bit guilty about investing time in this moronically simple sequencing problem, because I think its actually a strong real-world use case. Often, the first step you take after you deploy a cool Lambda function, is you realize that wait, what I want to do is run THIS function then run THAT function. This sounds easy and it should be easy.

    So theres a visual rendition of the machine on the top half, and a JSON expression of it on the bottom. This is an actual screen grab from the Step Functions console. The picture is self-explanatory, so lets look at the JSON. A state machines top level, NEXT along with a comment, has a structure called States that contains, well, all the States. And a string field StartAt that says which s