Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Tim Bray, Senior Principal Engineer
December 1, ...
λλ
λ DBMS
λ
λ
λ
λ
λ
λ λ
λ
λ
Queue
Modern
Serverless
app
Modern
Serverless
app
“I want to sequence functions”
“I want to select functions based on data”
“I want to retry functions”
“I want try/catch/fi...
Coordination by method call
λ λ
λ
λ
λ
λ
λ
Coordination by function chaining
λ
λ
λ
λ
λλ
λ
Coordination by database
λλ
λ
λ
λλ
λ
Coordination by queues
λ
λ
λ
λ λλ
λ
Coordination must-haves
• Scales out
• Doesn’t lose state
• Deals with errors/timeouts
• Easy to build & operate
• Auditab...
“State Machine”(noun)
1. A concept used by CompSci
profs for torturing
undergrads, full of arcane
math.
2. A practical way...
“I want to sequence functions”
AWS Step Functions, we can easily change and iterate on
the application workflow of our foo...
var Twit = require('twit');
var T = new Twit(require('botfiles/config.js'));
exports.handler = function myBot(event, conte...
(Demo)
How it works – API-level
Create State Machine – input is a
machine spec in a JSON DSL
Run Machine – input JSON blob,
retur...
How it works – API-level
Create State Machine – input is a
machine spec in a JSON DSL
Run Machine – input JSON blob,
retur...
https://states-language.net/spec
“I want to select functions based on data”
With AWS Step Functions, it was easy to build a multi-step product
updating sys...
"ChoiceState": {
"Type" : "Choice",
"Choices": [
{
"Variable": "$.productSource",
"StringEquals": "screen-scrape",
"Next":...
“I want to retry functions”
We get transient errors from a RESTful
service we depend on, once every four
or five times we ...
{
"Comment": "Call out to a RESTful service",
"StartAt": "Call out",
"States": {
"Call out": {
"Type": "Task",
"Resource":...
(Demo)
“I want to run functions in parallel”
We want to send the captured image to
three OCR providers and take the result
with t...
"Send for OCR": {
"Type": "Parallel",
"Next": "Pick result",
"Branches": [
{
"StartAt": "Prep1",
"States": {
"Prep1": {
"T...
Where does transient application
state live?
In the machine, in JSON texts
passing from state to state.A:
Q:
Input processing
{
"title": "Numbers to add",
"numbers": [ 3, 4 ]
}
{
"Type": "Task",
"InputPath": "$.numbers",
"Resource"...
Input processing
Q: InputPath not provided?
A: State gets raw input as-is.
Q: InputPath is null?
A: State gets an empty JS...
Result placement
{
"title": "Numbers to add",
"numbers": [ 3, 4 ]
}
{
"Type": "Task",
"InputPath": "$.numbers",
"ResultPat...
Result placement
Q: ResultPath not provided?
A: Input discarded, raw output used.
Q: ResultPath is null?
A: State input is...
“I want try/catch/finally”
AWS Step Functions makes it simple to coordinate information
from many different infrastructure...
13 AWS Lambda Task States
6 Choice States
1 Fail State
“I want try/catch/finally”
"Access Media": {
"Type": "Task",
"Resource": "arn:aws:lambda:eu-central-1:123456789012:function:FindMedia",
"TimeoutSecon...
“I have code that runs for hours”
We need to gather data from our
production line, in units of 8-hour shifts.
“
More APIs
Register Activity Task - Returns ARN
Poll For task (by ARN)
Report Success
Report Failure
Report Heartbeat
"NextShift": {
"Type": "Wait",
"TimestampPath": "$.ShiftStart",
"Next": "Gather Plant Data"
},
"Gather Plant Data": {
"Typ...
“I want to sequence functions”
“I want to select functions based on data”
“I want to retry functions”
“I want try/catch/fi...
2.5¢
How much?
per thousand
state transitions
4,000 free
transitions/month
Free tier:
Related Sessions
• CMP319: Building Distributed Applications with AWS
Step Functions (Thursday, 5:30 PM, Venetian, L4, Del...
Thank you!
timbray@amazon.com
Remember to complete
your evaluations!
NEW LAUNCH! Serverless Apps with AWS Step Functions
NEW LAUNCH! Serverless Apps with AWS Step Functions
NEW LAUNCH! Serverless Apps with AWS Step Functions
NEW LAUNCH! Serverless Apps with AWS Step Functions
NEW LAUNCH! Serverless Apps with AWS Step Functions
NEW LAUNCH! Serverless Apps with AWS Step Functions
NEW LAUNCH! Serverless Apps with AWS Step Functions
NEW LAUNCH! Serverless Apps with AWS Step Functions
NEW LAUNCH! Serverless Apps with AWS Step Functions
NEW LAUNCH! Serverless Apps with AWS Step Functions
Nächste SlideShare
Wird geladen in …5
×

NEW LAUNCH! Serverless Apps with AWS Step Functions

1.165 Aufrufe

Veröffentlicht am

AWS Step Functions is a new, fully-managed service that makes it easy to coordinate the components of distributed applications and microservices using visual workflows. Step Functions is a reliable way to connect and step through a series of AWS Lambda functions so that you can build and run multi-step applications in a matter of minutes. This session shows how to use AWS Step Functions to create, run, and debug cloud state machines to execute parallel, sequential, and branching steps of your application, with automatic catch and retry conditions. We share how customers are using AWS Step Functions to reliably scale multi-step applications such as order processing, report generation, and data transformation–all without managing any infrastructure.

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

NEW LAUNCH! Serverless Apps with AWS Step Functions

  1. 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Tim Bray, Senior Principal Engineer December 1, 2016 NEW LAUNCH! Serverless Apps with AWS Step Functions SVR201
  2. 2. λλ λ DBMS λ λ λ λ λ λ λ λ λ Queue Modern Serverless app
  3. 3. Modern Serverless app
  4. 4. “I want to sequence functions” “I want to select functions based on data” “I want to retry functions” “I want try/catch/finally” Functions into apps “I have code that runs for hours” “I want to run functions in parallel”
  5. 5. Coordination by method call λ λ λ λ λ λ λ
  6. 6. Coordination by function chaining λ λ λ λ λλ λ
  7. 7. Coordination by database λλ λ λ λλ λ
  8. 8. Coordination by queues λ λ λ λ λλ λ
  9. 9. Coordination must-haves • Scales out • Doesn’t lose state • Deals with errors/timeouts • Easy to build & operate • Auditable
  10. 10. “State Machine”(noun) 1. A concept used by CompSci profs for torturing undergrads, full of arcane math. 2. A practical way to build and manage modern Serverless Cloud apps. Dictionary
  11. 11. “I want to sequence functions” AWS 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 “
  12. 12. var Twit = require('twit'); var T = new Twit(require('botfiles/config.js')); exports.handler = function myBot(event, context, callback) { var list = event.inputList; var textToTweet = list.shift(); var output = { inputList: list } T.post('statuses/update', { status: textToTweet }, function(err, reply) { if (err) { console.log('error:', err); context.fail(); } else { console.log('tweet:', reply); callback(null, output); } }); };
  13. 13. (Demo)
  14. 14. How it works – API-level Create State Machine – input is a machine spec in a JSON DSL Run Machine – input JSON blob, returns Execution ID List Executions Describe Execution Stop Execution
  15. 15. How it works – API-level Create State Machine – input is a machine spec in a JSON DSL Run Machine – input JSON blob, returns Execution ID List Executions Describe Execution Stop Execution
  16. 16. https://states-language.net/spec
  17. 17. “I want to select functions based on data” With AWS Step Functions, it was easy to build a multi-step product updating system to ensure our database and website always have the latest price and availability information. AWS Step Functions let us replace a manual updating process with an automated series of steps, including built-in retry conditions and error handling, so we can reliably scale before a big show, and keep pace with rapidly changing fashions. Jared Browarnik, CTO, TheTake “
  18. 18. "ChoiceState": { "Type" : "Choice", "Choices": [ { "Variable": "$.productSource", "StringEquals": "screen-scrape", "Next": "ScreenScrapeState" },{ "Variable": "$.productSource", "StringEquals": "vendor-a", "Next": "VendorA" },{ "Variable": "$.productSource", "StringEquals": "vendor-b", "Next": "VendorB" }, { "Variable": "$.productSource", "StringEquals": "vendor-c", "Next":"VendorC" },{ "Variable": "$.productSource", "StringEquals": "updateProduct", "Next":"UpdateProduct" } ], "Default": "ScreenScrapeState” }
  19. 19. “I want to retry functions” We get transient errors from a RESTful service we depend on, once every four or five times we call it. But if we keep retrying, it eventually works. “
  20. 20. { "Comment": "Call out to a RESTful service", "StartAt": "Call out", "States": { "Call out": { "Type": "Task", "Resource": "arn:aws:lambda:eu-central-1:123456789012:function:RestCallout", "Retry": [ { "ErrorEquals": [ "HandledError" ], "MaxAttempts": 10 } ], "End": true } } }
  21. 21. (Demo)
  22. 22. “I want to run functions in parallel” We want to send the captured image to three OCR providers and take the result with the highest confidence value.“
  23. 23. "Send for OCR": { "Type": "Parallel", "Next": "Pick result", "Branches": [ { "StartAt": "Prep1", "States": { "Prep1": { "Type": "Pass", "Result": { "inputList": [ "OCR Provider 1" ] }, "Next": "Go1" }, "Go1": { "Type": "Task", "Resource": "arn:aws:lambda:eu-central-1:123456789012:function:StatesBot", "End": true } }
  24. 24. Where does transient application state live? In the machine, in JSON texts passing from state to state.A: Q:
  25. 25. Input processing { "title": "Numbers to add", "numbers": [ 3, 4 ] } { "Type": "Task", "InputPath": "$.numbers", "Resource": "arn:aws:lambda…" … [ 3, 4 ] Raw input: State spec: Task input:
  26. 26. Input processing Q: InputPath not provided? A: State gets raw input as-is. Q: InputPath is null? A: State gets an empty JSON object: {} Q: InputPath produces plural output? A: State gets it wrapped in a JSON array.
  27. 27. Result placement { "title": "Numbers to add", "numbers": [ 3, 4 ] } { "Type": "Task", "InputPath": "$.numbers", "ResultPath": "$.sum”, … Raw input: State spec: Output: { "title": "Numbers to add", "numbers": [ 3, 4 ], ”sum": 7 }
  28. 28. Result placement Q: ResultPath not provided? A: Input discarded, raw output used. Q: ResultPath is null? A: State input is state output. Q: ResultPath produces plural output? A: Not allowed, validator won’t accept.
  29. 29. “I want try/catch/finally” AWS Step Functions makes it simple to coordinate information from many different infrastructure systems using easy to design workflows and create a more intelligent monitoring system for our Platform as a Service (PaaS). With AWS Step Functions, we can reliably automate monitoring decisions and actions in order to reduce human intervention by over 60%, which improves infrastructure operation productivity and customer application availability on our platform. Pedro Pimenta, VP R&D, OutSystems “
  30. 30. 13 AWS Lambda Task States 6 Choice States 1 Fail State “I want try/catch/finally”
  31. 31. "Access Media": { "Type": "Task", "Resource": "arn:aws:lambda:eu-central-1:123456789012:function:FindMedia", "TimeoutSeconds": 2, "Next": "Graceful Exit", "Retry": [ { "ErrorEquals": [ "States.Timeout" ], "IntervalSeconds": 2, "MaxAttempts": 2, "BackoffRate": 1.5 } ], "Catch": [ { "ErrorEquals": [ "States.ALL" ], "Next": "Clean Up" } ] },
  32. 32. “I have code that runs for hours” We need to gather data from our production line, in units of 8-hour shifts. “
  33. 33. More APIs Register Activity Task - Returns ARN Poll For task (by ARN) Report Success Report Failure Report Heartbeat
  34. 34. "NextShift": { "Type": "Wait", "TimestampPath": "$.ShiftStart", "Next": "Gather Plant Data" }, "Gather Plant Data": { "Type": "Task", "Resource": "arn:aws:states:ap-northeast-1:123456789012:activity:PlWatch", "TimeoutSeconds": 30000, "HeartBeatSeconds": 120, "Next": "Clean up" }
  35. 35. “I want to sequence functions” “I want to select functions based on data” “I want to retry functions” “I want try/catch/finally” Is this you? “I have code that runs for hours” “I want to run functions in parallel”
  36. 36. 2.5¢ How much? per thousand state transitions 4,000 free transitions/month Free tier:
  37. 37. Related Sessions • CMP319: Building Distributed Applications with AWS Step Functions (Thursday, 5:30 PM, Venetian, L4, Delfino 4004) • In the hallway outside this room, starting now!
  38. 38. Thank you! timbray@amazon.com
  39. 39. Remember to complete your evaluations!

×