$30 off During Our Annual Pro Sale. View details »

AppSync를 활용한 리얼타임 서버리스 아키텍쳐

Taewoo Kim
February 13, 2020

AppSync를 활용한 리얼타임 서버리스 아키텍쳐

제21차 AWSKRUG 서버리스 소모임에서 발표한 내용입니다.

Taewoo Kim

February 13, 2020
Tweet

More Decks by Taewoo Kim

Other Decks in Programming

Transcript

  1. ӣక਋ AppSync ܳ ഝਊೠ ܻ঴ఋ੐ ࢲߡܻझ ইఃఫ୛

  2. ߊ಴੗ ࣗѐ • Solutions Architect, Classmethod (ੌࠄ) • Front-end, Back-end,

    Android, iOS, Machine Learning, Computer Vision, etc • ୭Ӕ 1֙р AWS ࠙ঠীࢲ੄ ੹ޙࢿਸ ऺӝਤ೧ Ҋҵ࠙ై઺ • Serverless on AWS, ؊ աইоࢲ Builder on AWS ܳ ૑ೱೞݴ ழܻযܳ ऺח ઺ • য়ט ୊਺ੑפ׮!!!! AWSKRUG ٜ࠙җ ݆੉݆੉ ҮܨೞҊ रणפ׮!!!!ƃƃ https://dev.classmethod.jp/author/kim-taewoo/ ೠҴয & ੌࠄয ӝࣿ࠶۽Ӓ
  3. ࢲߡܻझ ইఃఫ୛੄ ౠ૚ী ؀೧ рױ൤ غ૝যࠇद׮

  4. ࢲߡܻझ ইఃఫ୛੄ ౠ૚ • ҙܻೡ ࢲߡо হ׮ (NoOps) • ೙ਃೡ

    ٸ݃׮ ೙ਃೠ ࠗ࠙݅ ೙ਃೠ ݅ఀ ࢎਊೡ ࣻ ੓׮ • ஹೊ౴ ܻࣗझח Lambda (഑਷ Fargate) • Lambda ੄ ҃਋ ੗୓੸ਵ۽ connection ਸ ਬ૑ೡ ࣻ হ׮
  5. Ӓۢ ࢲߡܻझ ইఃఫ୛۽ח ܻ঴ఋ੐ ӝמ ޅ ݅٘աਃ?

  6. ٜ݅ ࣻ ੓ભ!

  7. How? API Gateway ীࢲ ਢࣗ௄ ૑ਗ API Gateway websocket

  8. How? PubSub ழ֏࣌ ӝ߈੄ ࣛܖ࣌਷ ইפ૑݅ PubSub ࣛܖ࣌ب (ੌױ਷) оמ

  9. It’s possible, but … • ೐ۿ౟ূ٘৬ ߔূ٘ р੄ ాनਸ ਤೠ

    Data structure ܳ ੿੄೧ঠೞҊ • ׼োೞ૑݅ ؘ੉ఠܳ ઱Ҋ ߉ਸ ٸ੄ Validation ب ೙ਃೞҊ • ׼োೞ૑݅ ߔূ٘৬ ೐ۿ౟ূ٘ নஏীࢲ ѐߊ੉ ੉ܖযઉঠೞҊ • ౠ൤ ߔূ٘ ஏ੄ ֢۱੉ (࢚׼൤) ݆੉ ٜযцפ׮
 High Availability .. Reliability .. Scalability ..
  10. AppSync ܳ ࢎਊೞݶ ੉ ݽٚѪ੉ рױ೧૘פ׮!!

  11. AWS AppSync • Strong typing ਵ۽ ੋ೧ Validation ௏٘ (Ѣ੄)

    ࢤۚ оמ
 (GraphQL ੄ ౠ૚) • ܻ঴ఋ੐ ాनਸ ਤ೧ࢲ ߔূ٘ীࢲ ೧ঠೡ Ѫ਷ Subscription ਸ झః݃ী ࢶ঱೧ فח Ѫ ߆ী হ਺ • ೐ۿ౟ূ٘ ஏীࢲח AppSync SDK ա Amplify ܳ ࢎਊೞݶ рױ൤ Subscription оמ
  12. ܻ঴ఋ੐ ؘ੉ఠ ాनਸ ਤೠ AppSync ইఃఫ୛

  13. AppSync ܻ঴ఋ੐ ইఃఫ୛ Micro services Subscription Data Streaming Mutation Trigger

  14. ݃੉௼۽ ࢲ࠺झ Stream ਵ۽ࠗఠ Lambda ౟ܻѢ Subscription Micro services Subscription

    Data Streaming Mutation Trigger AppSync ܻ঴ఋ੐ ইఃఫ୛ ੉ ࠗ࠙੉ য়ט ߊ಴੄ ೨ब
  15. ࢲߡܻझ झ౟ܻ߁ ইఃఫ୛

  16. DynamoDB Streams → Lambda

  17. DynamoDB Streams → Lambda • ੹ഋ੸ੋ ࢲߡܻझ ؘ੉ఠ झ౟ܻ߁ ಁఢ

    ઺ ೞա • Eventual Consistency ഑਷ Event-driven processing ١ਸ ୊ܻೞӝী ੸೤ • ScalableɾReliableɾCost Effective • ߽۳بо ݒ਋ ֫਷ ੘সী ؀೧ࢲח पदрࢿਸ ࠁ੢ೞ૑ ঋਵ޲۽ Kinesis DS о જ਺
  18. RDS → DMS → Kinesis → Lambda

  19. RDS → DMS → Kinesis → Lambda • RDS ܳ

    ࢎਊೠ ҃਋ীب झ౟ܻ߁ ୊ܻо оמೣ • Kinesis Data Streams ח ࢥ٘ܳ ੸੺൤ ஶ౟܀ ೡ ࣻ ੓যঠ ೣ • Kinesis Data Streams ীࢲ Ҷ੉ Lambda ۽ ো҅ೡ ೙ਃח হ਺ • Ӓ۞ա ࠄ ߊ಴੄ ݾ੸ (AppSync ো҅) ਸ ਤೠ ਊب۽ח Lambda ۽ ୽࠙ • DB (MySQL, PostgreSQL ١) ਵ۽ ࠗఠ ૒੽ Lambda ܳ प೯दఃח ߑߨب ઓ੤
  20. ӝఋ ੉߮౟ ࣗझ

  21. • SQS ীࢲ Lambda ۽ ো҅غח ಁఢ • Kinesis ীࢲ

    Lambda ۽ ো҅غח ಁఢ • API Gateway ীࢲ Lambda ۽ ো҅غח ಁఢ • CloudWatch Alarms ীࢲ Lambda ۽ ো҅غח ಁఢ • CloudWatch Events ীࢲ Lambda ۽ ো҅غח ಁఢ • Ӓ ৻ীب ޖࣻ൤ ݆਺ ӝఋ ੉߮౟ ࣗझ
  22. Lambda ۽ ؘ੉ఠܳ ߉ই৳ਵݶ ׮਺਷ рױೞભ!

  23. Lambda → AppSync

  24. ؘݽ ೐۽ં౟ ইఃఫ୛

  25. ؘݽ ইఃఫ୛ Microservice DynamoDB Subscription ੐द۽ ࢎਊೡ AppSyncਊ DB Mutation

    DynamoDB Streams
  26. Microservice • API Gateway → Lambda → DynamoDB ҳࢿ •

    о੢ ݆੉ ॳ੉ח ࢲߡܻझ ইఃఫ୛ API ߔূ٘ ಁఢ • рױೠ ੑ۱ ಬਸ ୊ܻೞח ࢲ࠺झܳ ৘۽ ٜয ؘݽ௏٘ ੘ࢿ
  27. AWS AppSync • AppSync ҳ୷दীח Serverless Framework ܳ ୶ୌ •

    Subscription ܳ झః݃ী ୶оೞח Ѫ݅ਵ۽ ௿ۄ੉঱౟ ஏীࢲ Subscription ੉ оמ 
 ( ߔূ٘ ੘সߊࢤ X ) • ೙ਃೠ ӝמ਷ Mutation җ Subscription ࡺ੉૑݅, Query ܳ झః݃ী ١۾ೞ૑ ঋਵݶ GraphQL झః݃ ী۞о غ޲۽ рױೠ ௪ܻ ೞաܳ ୶о೧ঠೣ (getOrder ੘ࢿ) • Mutation ೞӝ ਤ೧ࢲ੄ DynamoDB ܳ ؘ੉ఠ ࣗझ۽ࢲ ࢤࢿೞҊ, TTL (Time-To-Live) ܳ ࢸ੿ೠ׮. (expiresAt ܳ AWSTimestamp ఋੑਵ۽ ࢶ঱ೠ׮)
  28. DynamoDB Streams → Lambda • DynamoDB Streams ח ୭؀ 24

    दр੄ ؘ੉ఠ ࠁઓ, ؘ੉ఠ ߸҃੄ ࣽߣ੉ ࠁૐоמೠ ࢲ࠺झ • Ӓ۞ա ܻ঴ఋ੐ ࢲ࠺झীࢲח ୭؀ 24दр੄ ؘ੉ఠ ࠁઓ਷ ߹ ੄޷о হӟ ೤פ׮. • ߽۳بܳ ֫੉۰ݶ ߓ஖ ࢎ੉ૉܳ ઑ੺ೞݶ ؽ
  29. Lambda → AppSync • पࢲ࠺झਊਵ۽ ܾܻૉػ AppSync Client SDK ח

    javascript ߡ੹ ࡺ (Amplify ܳ ӂ੢) • AppSync Client SDK ܳ Lambda ࢚ীࢲ ز੘दఃӝ ਤ೧ࢲח ݻо૑ ઱੄੼੉ ੓਺ • ismorphic-fetch ܳ ੐ನ౟ ೧ঠೣ • disableOffline ܳ true ۽ ߸҃೧ঠೣ
  30. DEMO TIMEʂ

  31. None
  32. ૒੽ ௏٘ܳ ೠߣ ࢓ಝࠅөਃ https://github.com/twkiiim/serverless-tutorials/tree/master/realtime-stream-with-appsync

  33. AppSync Subscription ী ؀ೞৈ

  34. AppSync WebSockets MQTT over WebSockets WebSockets (NEW) Payload Size 128Kb

    240Kb CloudWatch Metrics X O Selection Set Filtering X O Enhanced Connection Rates X O Enhanced Broadcast Rates X O https://aws.amazon.com/jp/blogs/mobile/appsync-realtime/
  35. re:Invent 2019 Builders Fair ীࢲ ࣗѐػ Smart Chair

  36. 42

  37. AppSync ী ؀೧ ؊ ঌҊ र׮ݶ?

  38. AppSync ҙ۲ ࠶۽Ӓ • AWS ੤ੑޙ ࠶۽Ӓ – AppSync ಞ

    (ೠҴয)
 https://dev.classmethod.jp/cloud/aws/aws-appsync-re-introduction-2019-korean-ver/
  39. AppSync ҙ۲ ࠶۽Ӓ • [AppSync ѐ֛੿ܻ] AWS AppSync ߂ Resolver

    Mapping Template ী ؀೧ ѐ֛ਸ ੿ܻ೧ࠇद׮!
 https://dev.classmethod.jp/cloud/appsync-resolver-vtl-tutorial-ko/
  40. AppSync ҙ۲ ࠶۽Ӓ • [AWS AppSync] ΤοδσόΠεͷσʔλΛ AWS IoTܦ༝Ͱऔಘͯ͠GraphQLΛߋ৽ͯ͠Έ·ͨ͠ɻ
 https://dev.classmethod.jp/cloud/aws-appsync-with-awsiot/

  41. AppSync ҙ۲ ࠶۽Ӓ • [AWS AppSync] ΤοδσόΠεͷσʔλΛ AWS IoTܦ༝Ͱऔಘͯ͠GraphQLΛߋ৽ͯ͠Έ·ͨ͠ɻ
 https://dev.classmethod.jp/cloud/aws-appsync-with-awsiot/

  42. AppSync ۽ ੉۠Ѫب غ૑ ঋਸө?

  43. State Management by AppSync • ࢲߡܻझ ইఃఫ୛ ಁఢীࢲח Rich Client

    ܳ ૑ೱ • Ӓ۞ա ೐ۿ౟ূ٘੄ ௏٘ ࠂ੟بо ૑ա஖ѱ ૐоೞחѪ਷ જ૑ ঋ਺ • ೐ۿ౟ূ٘੄ ௏٘ ࠂ੟ب੄ ࢚׼ࠗ࠙ী ӝৈೞח State Management • State Management ܳ بੑೞӝ ਤೠ ௏٘੄ ࠂ੟بܳ AppSync Subscription ী ੄ઓ ೧ࢲ ೧Ѿೡ ࣻب ੓૑ ঋਸө? • ֎౟ਕ௼੄ ࣘب/উ੿ࢿ ١ী ੄ઓࢿ੉ ࢤӣ. • Ӓ۞ա 5G द؀ীח ௾ ޙઁח হ૑ ঋਸө?
  44. State Management by AppSync • ࢲߡܻझ ইఃఫ୛ ಁఢীࢲח Rich Client

    ܳ ૑ೱ • Ӓ۞ա ೐ۿ౟ূ٘੄ ௏٘ ࠂ੟بо ૑ա஖ѱ ૐоೞחѪ਷ જ૑ ঋ਺ • ೐ۿ౟ূ٘੄ ௏٘ ࠂ੟ب੄ ࢚׼ࠗ࠙ী ӝৈೞח State Management • State Management ܳ بੑೞӝ ਤೠ ௏٘੄ ࠂ੟بܳ AppSync Subscription ী ੄ઓ ೧ࢲ ೧Ѿೡ ࣻب ੓૑ ঋਸө? • ֎౟ਕ௼੄ ࣘب/উ੿ࢿ ١ী ੄ઓࢿ੉ ࢤӣ. • Ӓ۞ա 5G द؀ীח ௾ ޙઁח হ૑ ঋਸө? Let’s discuss together!
  45. хࢎ೤פ׮