Upgrade to Pro — share decks privately, control downloads, hide ads and more …

何故私達はサーバレスアプリケーションをイベントドリブンで作るべきなのか / Why should we make serverless application as event driven?

何故私達はサーバレスアプリケーションをイベントドリブンで作るべきなのか / Why should we make serverless application as event driven?

Masashi Terui

May 24, 2018
Tweet

More Decks by Masashi Terui

Other Decks in Technology

Transcript

  1. WHY SHOULD WE MAKE SERVERLESS
    APPLICATION AS EVENT DRIVEN?
    MASASHI TERUI @ SAPPORO.AWS #2

    View full-size slide

  2. SERVERWORKS CO.,LTD.
    + FREELANCER
    • Serverless Oji-san
    • Serverless Framework Plugin Developer
    • Serverlessconf Tokyo 2016/2017 speaker
    • Remote worker (in Sapporo)
    • The best Cloud Engineer in Hokkaido!! (Ͱ͋Γ͍ͨʣ
    MASASHI TERUI
    ARCHITECT / DEVELOPER

    View full-size slide

  3. SERVERLESSͬͯͳΜ͚ͩͬʁ
    WHAT IS

    View full-size slide

  4. CNCF SERVERLESS WHITEPAPER V1.0
    • Serverless computing refers to the concept of building and
    running applications that do not require server management
    • A platform may provide one or both of the following:
    • Functions-as-a-Service (FaaS)
    • Backend-as-a-Service (BaaS)
    • Products or platforms deliver the following benefits to developers:
    • Zero Server Ops
    • No Compute Cost When Idle

    https://github.com/cncf/wg-serverless/tree/master/whitepaper

    View full-size slide

  5. SERVERLESS CLOUD NATIVE LANDSCAPE

    View full-size slide

  6. ͬͪ͜ͷํ͕෼͔Γ΍͍͢͠޷͖
    https://www.slideshare.net/acloudguru/ant-stanley-being-serverless

    View full-size slide

  7. SERVERLESS USE CASES (FROM CNCF WP)
    • Asynchronous, concurrent, easy to parallelize into independent
    units of work
    • Infrequent or has sporadic demand, with large, unpredictable
    variance in scaling requirements
    • Stateless, ephemeral, without a major need for instantaneous
    cold start time
    • Highly dynamic in terms of changing business requirements that
    drive a need for accelerated developer velocity
    • Non-HTTP-centric and non-elastic scale workloads that weren’t
    good fits for an IaaS, PaaS, or CaaS solution

    View full-size slide

  8. ͔͠͠ɺ͋ΔServerlessաܹ೿͸ݴ͍·ͨ͠
    https://speakerdeck.com/toricls/how-serverless-loves-event-driven-architecture
    “Event Driven͕ͦ͜ServerlessͦΕҎ֎͸ೝΊΜʂ”
    ※٭৭͕͋Γ·͢

    View full-size slide

  9. EVENT DRIVENͬͯԿ͕ඒຯ͍͠ͷʁ

    View full-size slide

  10. MICROSERVICESͱฉ͍ͯԿΛࢥ͍ු͔΂·͔͢ʁ

    View full-size slide

  11. ͜ΕͰ͸ʁ
    https://www.slideshare.net/apigee/is-microservices-soa-done-right

    View full-size slide

  12. ΈΜͳMicroservicesͬͯ͜͏͍͏ͷͩͱࢥ͍͕ͪ
    ґଘؔ܎͕ෳࡶɺ؅ཧ͕೉͍͠ɺ࡞Δͷ΋೉͍͠
    େن໛޲͚Ͱ͔͠ͳ͍

    View full-size slide

  13. Event Drivenʹ͢Δͱ͜͏ͳΔ
    ґଘؔ܎Λૄʹอͪͭͭू໿ɺ੔ཧͰ͖Δ
    ن໛Λ໰Θͣཧ૝తͳΞʔΩςΫνϟΛऔΓ΍͍͢

    View full-size slide

  14. ΋͏͢͜͠ৄ͘͠
    • Pub/Subͷؔ܎
    • Publisher͸ൃߦ͢΂͖Πϕϯτ͚ͩΛ஌͍ͬͯΔ
    • Subscriber͸ߪಡ͢΂͖Πϕϯτ͚ͩΛ஌͍ͬͯΔ
    • ґଘؔ܎ΛૄͰ͋Γͳ͕Βू໿ɺ੔ཧͰ͖Δ
    • ͜ͷؔ܎͸ٯస͠ͳ͍ͨΊɺྲྀΕ͕෼͔Γ΍͘͢ͳΔ
    • ࣗવͱඇಉظʹͳΔ
    • ඇಉظͰ͋Δͱ͍͏͜ͱ͸ϦτϥΠՄೳͰ͋Δͱ͍͏͜ͱ

    View full-size slide

  15. EVENT DRIVENͬͯͲ͏΍Δͷʁ

    View full-size slide

  16. େ͖͘෼͚Δͱ͔̎ͭ͠ͳ͍
    Pull Push

    View full-size slide

  17. ࢖͍෼͚ - Pull
    • େྔͷΠϕϯτΛϋϯυϦϯά͍ͨ͠
    • ࣮֬ʹॲཧ͍ͨ͠ɺࣦഊ͢Δ֬཰͕ൺֱతߴΊ
    • ϦτϥΠճ਺ɾظؒΛ௕͘औΕΔ
    • ಉ࣮࣌ߦ਺΍ฒྻ౓Λίϯτϩʔϧ͍ͨ͠
    • DBॻ͖ࠐΈͱ͔֎෦αʔϏεݺͼग़͠ͱ͔

    View full-size slide

  18. ࢖͍෼͚ - Push
    • ஗ԆΛͰ͖Δ͚ͩগͳ͘ॲཧ͍ͤͨ͞
    • ฒྻ౓Λ্͍͛ͨ
    • Ұ౓ʹଟ͘ͷॲཧΛىಈ͍ͨ͠
    • ϦτϥΠػߏ͸͋ΔͷͰجຊ͸ͬͪ͜Ͱߟ͑Δ
    • ̏ճϦτϥΠˠDLQ

    View full-size slide

  19. AWSαʔϏεͷ࢖͍෼͚

    View full-size slide

  20. Kinesis Streams
    • PullܕΠϕϯτιʔεͷ୅ද֨
    • େྔͷΠϕϯτΛόοϑΝͰ͖Δ
    • ॱংอূ͕͋Δ
    • ͨͩ͠ɺ͋ΒΏΔ৚݅ͰॱংΛҡ࣋͠Α͏ͱ͢Δͱ

    ॲཧΛࢭΊ͟ΔΛಘͳ͘ͳΔ
    • Ͱ͖Δ͚ͩॱংอূ͠ͳ͍ͰࡁΉΑ͏ʹ΂͖౳ʹઃܭ͢Δ

    View full-size slide

  21. Simple Queue Service (SQS)
    • ϙʔϦϯά͕ඞཁʹͳΔͨΊਖ਼௚͋·Γ࢖Θͳ͍ʢࢲ͸ʣ
    • KinesisͰࣦഊͨ͠ΠϕϯτΛPut͠௚ͤ͹ྑ͍͡ΌΜతͳ
    • PushܕͰ΋DLQ͋Δ͠తͳ

    View full-size slide

  22. Simple Nortification Service (SNS)
    • PushܕΠϕϯτιʔεͷ୅ද֨
    • 1:NͷN͕ଟ͘ͳΔέʔεʹڧ͍ (Fanout)
    • ͚ͬ͜͏୔ࢁ࢖͏ͷͰ

    Serverless Frameworkͱ͔࢖Θͳ͍ͱઃఆ͕͠ΜͲ͍

    View full-size slide

  23. Step Functions
    • Push͕਺चͭͳ͗ʹͳΔ࣌ͷϋϯυϦϯά͕ΊͬͪΌศར
    • ֎෦ೖྗ଴ͪͰϙʔϦϯάͤ͟ΔΛಘͳ͍৔߹ʹ΋
    • State Machine DataʹσʔλΛڞ༗Ͱ͖Δͷศར
    • ؾΛൈ͘ͱશ෦͜ΕͰ΍Γͨ͘ͳΔ

    View full-size slide

  24. API Gateway
    • جຊతʹ֎෦ΠϕϯτΛड͚औΔޱͱߟ͑Δ
    • ReadܥͳͲ݁Ռ͕ඞཁͰಉظͰॲཧ͢Δ৔߹ʹ಺෦Ͱ࢖͏
    • ͨͩ͠1Πϕϯτ1ίʔϧ(Read)Λ৺͕͚Δ
    • ෳ਺ͷίʔϧ(Read)͕ඞཁͳ৔߹͸SNSͰFanout

    ·ͨ͸Step FunctionsΛ࢖͏ͳͲͯ͠෼ղ͢Δ

    View full-size slide

  25. S3 Event Notification
    • ϖΠϩʔυͷେ͖ͳΠϕϯτΛѻ͏
    • ϑΝΠϧͱͯ͠֎෦ೖྗΛΠϕϯτͱͯ͠ѻ͏

    View full-size slide

  26. CloudWatch Events
    • Event-based
    • AWSͷαʔϏεΛτϦΨʔͱ͢ΔΠϕϯτΛൃߦ͢Δ
    • Time-based
    • ࣌ؒΛτϦΨʔͱ͢ΔΠϕϯτΛൃߦ͢Δ

    View full-size slide

  27. ʢ͓·͚ʣLambda -> Lambda
    • جຊ΍Βͳ͍ʢࢲ͸ʣ
    • େମSNSڬΉ or ਺चܨ͗ʹͳΔͳΒStep FunctionsΛ࢖͏
    • 1:1͕100%อূͰ͖Δ৔߹ͷΈ࢖ͬͯ΋ྑ͍ʢ͔΋ʣ
    • Ͱ΋ͦΕ1FunctionͰྑ͍Μ͡Όɾɾɾ

    View full-size slide

  28. ALL BECOME EVENT DRIVEN

    View full-size slide

  29. Event Driven͡Όͳͯ͘΋ͪ͠Ό͑Δ

    View full-size slide

  30. THANKS!!
    LET’S ENJOY SERVERLESS

    WITH EVENT DRIVEN ARCHITECTURE !!

    View full-size slide