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

X-Ray and ECS

8b52a1388cffd0ece8a6335464aefcae?s=47 Kousuke Miyauchi
December 12, 2017

X-Ray and ECS

How to use X-Ray in ECS

8b52a1388cffd0ece8a6335464aefcae?s=128

Kousuke Miyauchi

December 12, 2017
Tweet

Transcript

  1. SUPINF.Inc 2017/12/12 Tue AWS X-Ray and ECS X-RayͰԶΛݟΖʂ

  2. SUPINF.Inc 2017/12/12 Tue ࣗݾ঺հ ɾٶ಺ߞհ ɾSUPINF (2015/05 ʙ) ɾ৽ׁग़਎͚ͩͲΧʔϓϑΝϯ ɾҰԠ

    AWS SAA อ༗ͯ͠·͢
  3. SUPINF.Inc 2017/12/12 Tue ɾX-Rayͷ͍ܰ֓ཁͷ࿩ ɾX-RayͱECSͷ࿩ ɾX-RayͷϢʔεέʔε ΞδΣϯμ

  4. SUPINF.Inc 2017/12/12 Tue ͓͜ͱΘΓ ɾॳొஃ ɾଟ෼ۓுͯ͠·͢ ɾ࣌ؒͱ͔ϧʔϧͱ͔कΕͳ͔ͬͨΒ͍͢·ͤΜ

  5. SUPINF.Inc 2017/12/12 Tue ՄࢹԽɾ෼ੳ αʔϏεϚοϓʹΑΓɺΞϓϦέʔγϣ ϯ಺ͷαʔϏε΍Ϧιʔεͷؔ܎ΛϦΞϧ λΠϜͰදࣔͰ͖·͢ X-Rayͱ͸ ऩू ΞϓϦέʔγϣϯશମͰసૹ͞ΕΔϢʔ

    βʔϦΫΤετ͕τϨʔεՄೳ ໰୊఺ͷચ͍ग़͠ ύϑΥʔϚϯεͷ໰୊ͷݪҼͱɺ໰୊ʹ ؔ܎͢ΔΞϓϦέʔγϣϯ಺ͷ৔ॴΛಛ ఆՄೳ X-Rayͱ͸ɺϦΫΤετΛऩूͯ͠෼ੳ͢Δ͜ͱ͕Ͱ͖ΔαʔϏε
  6. SUPINF.Inc 2017/12/12 Tue ϚΠΫϩαʔϏεͱ෼ࢄΞʔΩςΫνϟͷॏཁੑͷߴ·Γ Why ? X-Ray ͔͠͠ɺ؅ཧऀ͸ଟ͘ͷϚΠΫϩαʔϏεΛ؅ཧ͢Δඞཁ ੑ͕͋Γɺ݁Ռతʹ؅ཧίετ͕૿େ͢Δ܏޲ʹ͋Δ ɾϞϊϦγοΫͳγεςϜ͔Β୤٫

    ɾΞϓϦΛػೳ͝ͱʹαʔϏεͰ෼ׂ ɾڊେͳ̍ͭͷγεςϜΑΓӨڹൣғΛݶఆ͠΍͘͢খճΓ͕͖͘
  7. SUPINF.Inc 2017/12/12 Tue ෼ࢄΞʔΩςΫνϟͷσϝϦοτ ɾγεςϜશମͱͯ͠ͷৼΔ෣͍Λ೺Ѳ͢Δ͜ͱ͕೉͍͠ ɾো֐ൃੜ࣌ͷݪҼڀ໌͕೉͍͠ ɾશମͰͷύϑΥʔϚϯεͷ෼ੳ͕೉͍͠

  8. SUPINF.Inc 2017/12/12 Tue X-RayΛ࢖͏ϝϦοτ X-RayΛ࢖͑͹ ɾγεςϜશମͱͯ͠ͷৼΔ෣͍Λ֬ೝͰ͖Δ ɾো֐ൃੜ࣌ͷݪҼڀ໌ΛՄࢹԽ͠΍͍͢(໰୊఺ͷચ͍ग़͠) ɾύϑΥʔϚϯε෼ੳՄೳ

  9. SUPINF.Inc 2017/12/12 Tue deamonΛཱͯΔඞཁ͕͋Δ σʔϞϯ͸ AWS X-Ray SDK ͱ࿈ಈ͠·͢ɻSDK ʹΑͬͯ

    ૹ৴͞Εͨσʔλ͕ X-Ray αʔϏεʹ౸ୡ͢ΔΑ͏ʹ͢Δ X-Ray SDK Python Java node Golfing etc X-Ray API XRay-APIΛ࢖༻ͯ͠ηάϝϯτΛΞοϓϩʔυ ͠ɺτϨʔε͓ΑͼαʔϏεϚοϓΛ࡞੒ X-RayΛ࢖͏ʹ͸ ͭ·ΓɺطଘͷϓϩάϥϜʹखΛೖΕΔඞཁ͕͋Γ·͢
  10. SUPINF.Inc 2017/12/12 Tue X-RayͷτϨʔε৘ใ ॴཁ͕࣌ؒҰ໨ͰΘ͔ΔϦετܗࣜ ηάϝϯτผʹ෼͔ΕΔ

  11. SUPINF.Inc 2017/12/12 Tue X-RayͷαʔϏεϚοϓ৘ใ σʔλͷྲྀΕ͕Θ͔ΔπϦʔܗࣜ ৭ͰεςʔλεΛදݱ

  12. SUPINF.Inc 2017/12/12 Tue LambdaͰͷಋೖ͸؆୯ νΣοΫΛ0/ $'OͰͷهड़ 5SBDJOHΛΞΫςΟϒʹ LambdaͰͷಋೖ͸͢ΜͳΓ؆୯

  13. SUPINF.Inc 2017/12/12 Tue LambdaͰͷಋೖ͸؆୯2 4%,ΛೖΕͯɺ
 DMJFOUʹରͯ͠QBUDIΛ ద༻͢Δ X-Ray-SDKΛೖΕͯΈ·͠ΐ͏ αϒηάϝϯτ͕ੜ੒͞Εɺ ΑΓৄࡉͳ5SBDFσʔλ͕࡞੒͞ΕΔ

  14. SUPINF.Inc 2017/12/12 Tue X-RayͱECS ͱ

  15. SUPINF.Inc 2017/12/12 Tue ίϯςφࢧ෦ͳͷͰECSͷ͓࿩ Docker Docker Docker Amazon EC2 Docker

    Docker Docker Amazon EC2 Docker Docker Docker Amazon EC2
  16. SUPINF.Inc 2017/12/12 Tue Docker Docker Docker Amazon EC2 Docker Docker

    Docker Amazon EC2 Docker Docker Docker Amazon EC2 ScalingPolicyͰ
 ϗετͷॖୀ͕Մೳ Configure serviceͰ
 ίϯςφͷ਺Λ੍ޚՄೳ ECSͷ৑௕ੑɾՄ༻ੑ ৑௕Խ͞ΕɺෛՙʹԠͨ͡εέʔϧΠϯ / Ξ΢τ͕Մೳ
  17. SUPINF.Inc 2017/12/12 Tue ECS্ʹX-RayσʔϞϯͷઃஔΛͯ͠ΈΔ Docker Docker Amazon EC2 Docker Docker

    Docker Amazon EC2 Docker Docker Docker Amazon EC2 93BZσʔϞϯΛઃஔ ͍ͭ͜΋ίϯςφͰ͢ ͦΕͧΕ͕ɺ%FBNPO
 ʹσʔλΛૹΔ
  18. SUPINF.Inc 2017/12/12 Tue ͔͜͜͠͠Ͱ໰୊͕ൃੜ ΋͠ɺAuto ScalingʹΑΓX-RayίϯςφͷೖͬͯΔϗετ͕ࢮΜͩΒʁ → ECSͷServiceͱͯ͠ొ࿥͓͍ͯͯ͠ɺৗʹίϯςφཱ͕ͭΑ͏ ɹʹ͓͚ͯ͠͹͍͍͡ΌΜ →͡Ό͋ɺALB͔NLBΛ࢖ͬͯλʔήοτάϧʔϓ࡞Βͳ͖Ό͍͚ͳ͍

    → ࡞ΓΌ͍͍͡ΌΜɻ Ͱ΋ɺ͔͠͠ →αʔϏεɾσΟεΧόϦ(αʔϏε΁ͷࣗಈϧʔςΟϯά)͕ඞཁʹͳΔ
  19. SUPINF.Inc 2017/12/12 Tue UDPϙʔτͱϩʔυόϥϯαʔ AWS X-RayσʔϞϯ͸UDPϙʔτΛϦεχϯά͍ͯ͠Δ

  20. SUPINF.Inc 2017/12/12 Tue UDPϙʔτͱϩʔυόϥϯαʔ ALBͱNLBٴͼCLB͸UDPʹରԠ͍ͯ͠ͳ͍

  21. SUPINF.Inc 2017/12/12 Tue ͠ΐ͏͕ͳ͍͔ΒX-RayίϯςφΛαΠυΧʔʹ 5BTL%FpOJUJPOͰ ΞϓϦέʔγϣϯͱҰॹʹ 93BZ༻ͷίϯςφΛ഑උ

  22. SUPINF.Inc 2017/12/12 Tue Docker Docker Docker Amazon EC2 Docker Docker

    Docker Amazon EC2 Docker Docker Docker Amazon EC2 ͦΕͧΕʹ 93BZίϯςφΛ഑උ ͠ΐ͏͕ͳ͍͔ΒX-RayίϯςφΛαΠυΧʔʹ
  23. SUPINF.Inc 2017/12/12 Tue Amazon EKS From re:Invent2017 EKSͳΒkubernetes͔ͩΒ͖ͬͱ͍͚Δ

  24. SUPINF.Inc 2017/12/12 Tue ݱ৔ͰͷϢʔεέʔε

  25. SUPINF.Inc 2017/12/12 Tue ྫ͑͹͜͏͍͏ߏ੒ͷγεςϜ͕͋ͬͨͱ͠·͢ ΞΫηε αʔόʔʹϦΫΤετ ॲཧ࣮ߦ Ϩεϙϯε 4̏QVU Amazon

    API Gateway* Lambda function bucket with objects Docker Docker Docker Amazon ECS
  26. SUPINF.Inc 2017/12/12 Tue AWSίϯϙʔωϯτΛෳ਺ލ͍ͩΞʔΩςΫνϟ ɾAPIGateway͔ΒσʔλIN ɾLambda͕࣮ߦ͞ΕɺαʔόʔʹϦΫΤετ ɾॲཧ͕࣮ߦ͞ΕϨεϙϯε͕ฦΔ ɾ࠷ऴతʹฦ͖ͬͯͨ݁ՌΛ΋ͱʹɺ
 S3ʹσʔλΛ࡞੒͢Δ ※ϙΠϯτͱͯ͠͸ɺAWSίϯϙʔωϯτΛෳ਺ލ͍ͰγεςϜ͕ߏங͞Ε͍ͯΔ఺

    Amazon API Gateway* Lambda function bucket with objects Docker Docker Docker Amazon ECS
  27. SUPINF.Inc 2017/12/12 Tue AWSίϯϙʔωϯτ͕ෳ਺ͷ৔߹ X-Ray X-Ray X-Ray͕ͦΕͧΕಠཱͯ͠αʔϏεϚοϓΛੜ੒ͯ͠͠·͏ Amazon API Gateway*

    Lambda function bucket with objects Docker Docker Docker Amazon ECS
  28. SUPINF.Inc 2017/12/12 Tue αʔϏεϚοϓ͕Ϳͭ੾ΓʹͳΔ ඒ͘͠ͳ͍ʴX-RayΛ׆͔͖͠Εͳ͍

  29. SUPINF.Inc 2017/12/12 Tue ରॲ๏ TraceIDΛ͔ͭ͏

  30. SUPINF.Inc 2017/12/12 Tue TraceIDͱ͸ ɾX-RayͷτϥϯβΫγϣϯʹͭ͘ݻ༗ͷID ɾ1ͭͷX-Rayʹ͖ͭ1ͭͷTraceID͕෇͍͍ͯΔ ɾݕࡧ͢ΔࡍͷҰҙͷIDͱͯ͠΋࢖͑Δ

  31. SUPINF.Inc 2017/12/12 Tue AWSίϯϙʔωϯτ͕ෳ਺ͷ৔߹ ֤ʑͰTraceIDΛੜ੒͍ͯ͠ΔͷͰಠཱͯ͠͠·͍ͬͯΔ TraceID:B X-Ray X-Ray Amazon API

    Gateway* Lambda function bucket with objects Docker Docker Docker Amazon ECS TraceID: A
  32. SUPINF.Inc 2017/12/12 Tue AWSίϯϙʔωϯτ͕ෳ਺ͷ৔߹ ಠࣗͰੜ੒͞Ε͍ͯΔTraceIDΛԼྲྀʹ఻೻͍ͤͯ͘͞ TraceID:A X-Ray X-Ray Amazon API

    Gateway* Lambda function bucket with objects Docker Docker Docker Amazon ECS TraceID: A
  33. SUPINF.Inc 2017/12/12 Tue X-Ray TraceIDऔಘྫ(Lambda) LambdaͰTrace=Onʹ͍ͯ͠Δͱ
 _X_AMZN_TRACE_ID͕؀ڥม਺ͱͯ͠ηοτ͞ΕΔ →͜ΕΛԼྲྀʹ఻೻͢Δ

  34. SUPINF.Inc 2017/12/12 Tue ޙଓॲཧͰTraceIDͷऔಘ ্هΛݩʹɺX-RayͷϔομΛ࡞੒͢Δͱɺ ॲཧͷଓ͖Λߦ͏͜ͱ͕Ͱ͖Δ

  35. SUPINF.Inc 2017/12/12 Tue E2EͰτϨʔεID͕౷Ұ͞Εͨੈք X-Ray TraceIDΛ౷Ұ͢ΔͱɺX-Rayຊདྷͷσʔλͷ׆༻͕Մೳʹʂ TraceID: A Amazon API

    Gateway* Lambda function bucket with objects Docker Docker Docker Amazon ECS
  36. SUPINF.Inc 2017/12/12 Tue αʔϏεϚοϓͷܶత Before After ͳΜͱ͍͏͜ͱͰ͠ΐ͏ before after ͍͍ײ͡ͷαʔϏεϚοϓΛ࡞Ζ͏

    ͱࢥ͕ͬͨ࣌ؒͷؔ܎Ͱ༻ҙͰ͖· ͤΜͰͨ͠
  37. SUPINF.Inc 2017/12/12 Tue Tips.Τϥʔ࣌ͷαʔνʹ໾ʹཱͭ ϩάʴTraceIDͰΤϥʔՕॴͷಛఆ͕ਝ଎ʹͳΔ ɾCloudWatchʹΞϓϦέʔγϣϯͰ࢖༻͍ͯ͠ΔIDͱڞʹTraceIDΛు͖ग़͠ ͓͚ͯ͹ɺΤϥʔ࣌ʹͲͷ΁Μ͕ո͍͔͠ɺ͋ͨΓ͕͙͢ʹΘ͔ΔΑ͏ʹͳΔ

  38. SUPINF.Inc 2017/12/12 Tue ·ͱΊΔͱ ɾAWSίϯϙʔωϯτΛෳ਺ލ͍ͩγεςϜߏ੒ͷ৔߹ʹ X-Rayͷॲཧ୯Ґ͕෼அ͞Εͯ͠·͏ ɾTraceIDΛऔಘͯ͠Լྲྀʹ఻೻Ͱ͖Ε͹ɺӡ༻ऀࢹ఺Ͱݟͨ࣌ʹ
 ɹҙຯͷ͋ΔॲཧͷྲྀΕͱͯ͠ڞ௨ͷIDΛ࡞Δ͜ͱ͕Ͱ͖Δ ɾTraceIDΛத৺ͱͯ͠ɺϩά΍X-RayαʔϏεΛݟΔ͜ͱͰɺ
 ɹ໰୊ൃੜ࣌ͷղܾ଎౓޲্͕ݟࠐΊΔ

  39. SUPINF.Inc 2017/12/12 Tue X-RayΛ্खʹ࢖͏͜ͱ͕Ͱ͖Δͱɺ ࠓΑΓ΋ɺӡ༻ָ͕ʹͳΔ͔΋͠Ε·ͤΜ ऴΘΓʹ

  40. SUPINF.Inc 2017/12/12 Tue Ҏ্Ͱ͢ ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠