Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

AWS Step Functions를 이용한 마이크로서비스 개발하기 - 김현민 (4CSoft)

2,564 views

Published on

AWS Step Functions를 사용하면 시각적 워크플로를 사용해 분산 애플리케이션 및 마이크로서비스의 구성 요소를 손쉽게 조정할 수 있습니다.

Published in: Software
  • Be the first to comment

AWS Step Functions를 이용한 마이크로서비스 개발하기 - 김현민 (4CSoft)

  1. 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. , 4CSoft 2017.01.21 AWS Step Functions AWSKRUG re:Invent
  2. 2. • (hmkim84@4csoft.com) • 4CSoft Inc. • iOS 4 • Node.js 1 • AWSKRUG • AWS : EC2, S3, Route53 … Lambda
  3. 3. re:Invent 2016
  4. 4. re:Invent 2016
  5. 5. λ
  6. 6. λλ λ
  7. 7. λλ λ λ λ λ λ λ λ λ λ λ
  8. 8. λλ λ λ λ λ λ λ λ λ λ λ Queue
  9. 9. λλ λ DBMS λ λ λ λ λ λ λ λ λ Queue
  10. 10. λλ λ DBMS λ λ λ λ λ λ λ λ λ Queue
  11. 11. “ ” “ ” “ ” “try/catch/finally ” “ ” “ ”
  12. 12. λ λ λ λ λ λ λ
  13. 13. λ λ λ λ λλ λ
  14. 14. λ λ λ λ λλ λ
  15. 15. λ λ λ λ λλ λ
  16. 16. • • state • / • • ( )
  17. 17. AWS Step Functions
  18. 18. “ ” AWS Step Functions, . AWS Step Functions .. 
 
 Mathias Nitzsche, CTO “
  19. 19. var Twitter = require(‘twitter'); var client = new Twitter({ consumer_key: process.env.TWITTER_CONSUMER_KEY, consumer_secret: process.env.TWITTER_CONSUMER_SECRET, access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY, access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET }); exports.handler = (event, context, callback) => { var list = event.inputList; var textToTweet = list.shift(); var output = { inputList: list }; client.post('statuses/update', {status: textToTweet}, function(err, reply) { if (err) { console.log('error', err); context.fail(); } else { console.log('tweet', reply); callback(null, output); } }); };
  20. 20. (Demo)
  21. 21. – API-level Create State Machine – JSON DSL Run Machine – JSON blob , Execution ID . List Executions Describe Execution Stop Execution
  22. 22. https://states-language.net/spec.html
  23. 23. 7 State Types Task Choice Parallel Wait Fail Succeed Pass
  24. 24. “ ” AWS Step Function . AWS . Jared Browarnik, CTO, TheTake “
  25. 25. "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” }
  26. 26. (Demo)
  27. 27. “ ” RESTful . 4~5 . , . “
  28. 28. { "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 } } }
  29. 29. (Demo)
  30. 30. “I want to run functions in parallel” 3 OCR . “
  31. 31. "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 } }
  32. 32. (Demo)
  33. 33. ? , JSON .A: Q:
  34. 34. 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:
  35. 35. Input processing Q: InputPath ? A: State raw . Q: InputPath null ? A: State JSON : {} Q: InputPath ? A: State JSON .
  36. 36. 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 }
  37. 37. Result placement Q: ResultPath ? A: , raw . Q: ResultPath null ? A: State state . Q: ResultPath ? A: . .
  38. 38. “try/catch/finally ” AWS Step Functions Platform as a Service . With AWS Step Functions, 60 % . Pedro Pimenta, VP R&D, OutSystems “
  39. 39. 13 AWS Lambda Task States 6 Choice States 1 Fail State “try/catch/finally ”
  40. 40. "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" } ] }, 

  41. 41. (Demo)
  42. 42. “ ” 8 . “
  43. 43. APIs Register Activity Task - Returns ARN Poll For task (by ARN) Report Success Report Failure Report Heartbeat (Inside the Activity)
  44. 44. "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" }
  45. 45. “ ” “ ” “ ” “try/catch/finally ” ? “ ” “ ”
  46. 46. 2.5¢ ? 1,000 0.025 USD 4,000 
 / :
  47. 47. AWS Step Functions ? Region Region Code US East (N. Virginia) us-east-1 US East (Ohio) us-east-2 US West (Oregon) us-west-2 EU (Dublin) eu-west-1 Asia Pacific (Tokyo) ap-northeast-1
  48. 48. • SVR201: Serverless Apps with AWS Step Functions
 - https://www.youtube.com/watch?v=75MRve4nv8s • CMP319: Building Distributed Applications with AWS Step Functions
 - https://www.youtube.com/watch?v=-qCFLXY1xa8 • Announcing AWS Step Functions - December 2016 Monthly Webinar Series
 - https://www.youtube.com/watch?v=vi0q9bODbTE
  49. 49. ! hmkim84@4csoft.com

×