Mackerel の時系列データベースにおける Redis Cluster の利用と Amazon ElastiCache への移行について / AWS Purpose-Built Databases Week

81e8ac1d3a766b3d9880cd08d9a7aba4?s=47 astj
August 24, 2020

Mackerel の時系列データベースにおける Redis Cluster の利用と Amazon ElastiCache への移行について / AWS Purpose-Built Databases Week

81e8ac1d3a766b3d9880cd08d9a7aba4?s=128

astj

August 24, 2020
Tweet

Transcript

  1. Mackerel ͷ࣌ܥྻσʔλϕʔεʹ͓͚Δ Redis Cluster ͷར༻ͱ Amazon ElastiCache ΁ͷҠߦʹ͍ͭͯ "84163104&—#6*-5%"5"#"4&48&&, "TBUP8BLJTBLB

    )BUFOB$P -UE
  2. ΞδΣϯμ • Mackerel ͱͦͷ࣌ܥྻσʔλϕʔε • ෳ਺σʔλετΞͷซ༻Օॴʹ͓͚Δ Redis Cluster ͷબఆ •

    Amazon EC2 ্͔Β Amazon ElastiCache ΁ͷҠߦ • Amazon ElastiCache ʹΑΔ Redis Cluster ͷӡ༻
  3. ࣗݾ঺հ - Asato Wakisaka • GitHub @astj • גࣜձࣾ͸ͯͳ ΞϓϦέʔγϣϯΤϯδχΞ

    • Mackerel ։ൃνʔϜ ςοΫϦʔυ • Golang, TypeScript, Scala
  4. None
  5. None
  6. None
  7. Mackerel • αʔόʔ؂ࢹɾ؅ཧͷ SaaS • 2014೥ਖ਼ࣜϦϦʔε • 2017೥ΑΓαʔϏεશମ͕ AWS ্ͰՔಇ

    • VM ϕʔεͷϫʔΫϩʔυΛܧଓతʹϚωʔδυαʔϏεʹҠߦ • Amazon EC2 => Amazon ECS, Amazon RDS, Amazon ElastiCache, …
  8. Mackerel ͷ࣌ܥྻσʔλϕʔε

  9. ࣌ܥྻσʔλϕʔε (TSDB) hatena.mackerel.host1.cpu.user 2018/02/01T21:15:00Z 44.00 2018/02/01T21:16:00Z 6.00 2018/02/05T21:17:00Z 8.00 hatena.mackerel.host1.cpu.user

    2018/02/01T21:15:00Z 44.00 2018/02/01T21:16:00Z 6.00 2018/02/05T21:17:00Z 8.00 hatena.mackerel.host1.cpu.user 2018/02/01T21:15:00Z 44.00 2018/02/01T21:16:00Z 6.00 2018/02/05T21:17:00Z 8.00 hatena.mackerel.host1.cpu.user 2018/02/01T21:15:00Z 44.00 2018/02/01T21:16:00Z 6.00 2018/02/05T21:17:00Z 8.00 … … • Name ʹରͯ͠ (Timestamp, Value) ͷ૊Λه࿥͍ͯ͘͠ • యܕతʹ͸ʁ: αʔόʔ͝ͱͷ CPU ར༻཰ͷάϥϑ
  10. Mackerel ͷ࣌ܥྻσʔλϕʔε • ؂ࢹର৅ͷαʔόʔ΍αʔϏεͷϝτϦοΫΛऩूͯ͠ه࿥ • ΞϥʔτͷઃఆɺάϥϑʹΑΔՄࢹԽɺ etc… • ΞΫηεύλʔϯ •

    ߋ৽ස౓ > ࢀরස౓ • ࢀরہॴੑ • ݹ͍ߴղ૾౓ϝτϦοΫ͸͋·Γࢀর͞Εͳ͍
  11. Mackerel ͷ࣌ܥྻσʔλϕʔε • 2017೥ʹ AWS ʹҠߦ͢Δࡍʹ಺੡ • ӡ༻ෛՙͷ௿ݮͱকདྷతͳεέʔϥϏϦςΟ͕ཁ݅ • =>

    AWS ϚωʔδυαʔϏεΛར༻
  12. Mackerel ͷ࣌ܥྻσʔλϕʔε 8SJUF 'MVTI 3FBE 3FBE 3FBE 3FBE%BUB1PJOUT 8SJUF%BUB1PJOUT 55-5SJHHFS

    8SJUF "NB[PO,JOFTJT %BUB4USFBNT "NB[PO&MBTUJ$BDIF 3FEJT$MVTUFS "NB[PO %ZOBNP%# "NB[PO 4
  13. 8SJUF 'MVTI 3FBE 3FBE 3FBE 3FBE%BUB1PJOUT 8SJUF%BUB1PJOUT 55-5SJHHFS 8SJUF "NB[PO,JOFTJT

    %BUB4USFBNT "NB[PO&MBTUJ$BDIF 3FEJT$MVTUFS "NB[PO %ZOBNP%# "NB[PO 4 Mackerel ͷ࣌ܥྻσʔλϕʔε • ಺෦Ͱ͸ෳ਺ͷσʔλετΞΛซ༻ • ϝΠϯʹ Amazon DynamoDB • ίετ࠷దԽͷͨΊʹ Amazon ElastiCache (Redis Cluster) ͱ Amazon S3 • => σʔλετΞબఆΛ;Γ͔͑Γ·͢
  14. σʔλετΞͷબఆ • ϝΠϯͷσʔλετΞʹ͸ Amazon DynamoDB Λબఆ • ϑϧϚωʔδυܕͷ KVS •

    εϧʔϓοτɺετϨʔδ༰ྔͱ΋ʹߴ͍εέʔϥϏϦςΟ • Amazon DynamoDB ୯ମͰ͸ίετ໘Ͱ޻෉ͷ༨஍͕͋Δ • ߴස౓ʹσʔλΛॻ͖ࠐΉ͜ͱʹΑΔ Write Capacity Unit ͷফඅ • ௕ظؒͷ࣌ܥྻσʔλΛอ࣋͢Δ͜ͱʹΑΔετϨʔδඅ༻ • => ಛੑͷҟͳΔଞͷσʔλετΞΛซ༻ͯ͠ղফ
  15. ॻ͖ࠐΈϦΫΤετͷޮ཰Խ • ౎౓௚઀ Amazon DynamoDB ʹॻ͖ࠐΉͱIOίετ͕ਹΉ • ࣌ܥྻσʔλ͸ຖ෼౤ߘ͞Εͯ͘Δ • =>

    ॻ͖ࠐΈ API ϦΫΤετΛόοϑΝͯ͠ίετΛ௿ݮ • Amazon DynamoDB ΑΓ IO ʹ༏ΕͨσʔλετΞ • => Amazon ElastiCache ʹΑΔ Redis Cluster • Lambda Function ʹόοϑΝϦϯάΛ࣮૷ 8SJUF 3FBE 'MVTI 3FBE
  16. ࣌ܥྻσʔλͷ௕ظอଘ • ݹ͍࣌ܥྻσʔλ͸ߋ৽͞Εͣɺࢀরස౓΋௿͍ • => ࢀরͰ͖Δඞཁ͸͋Δ͕ɺϨΠςϯγཁ݅͸؇ΊΒΕΔ • σʔλྔతʹ͸͜ͷ”ݹ͍”σʔλ͕ଟ͘Λ઎ΊΔ • ͜ͷ”ݹ͍”σʔλͷ༰ྔίετΛ཈͑ΒΕΔͱޮՌత

    • => ༰ྔίετͷΑΓ௿͍σʔλετΞʹҠಈͯ͠ίετΛ௿ݮ • => Amazon S3 • ௿྿ͳετϨʔδίετͱݱ࣮తͳϨΠςϯγͰར༻Մೳ • DynamoDB ͔ΒͷσʔλҠߦʹ͸ TTL ͱ DynamoDB Streams Λར༻ 3FBE 3FBE 55-5SJHHFS 8SJUF
  17. ·ͱΊ: Mackerel ͷ࣌ܥྻσʔλϕʔε • ࣌ܥྻσʔλϕʔεΛ AWS ʹҠߦ͢Δࡍʹ಺੡ʹ੾Γ׵͑ • ಛੑͷҟͳΔσʔλετΞΛ૊Έ߹Θͤͯߏங •

    εέʔϥϏϦςΟʹ༏ΕΔ Amazon DynamoDB • લஈͷόοϑΝͱͯ͠ Redis Cluster (Amazon ElastiCache) • ݹ͍σʔλͷ௕ظอ࣋ʹ Amazon S3
  18. Amazon ElastiCache ͱ Redis Cluster

  19. Redis Cluster • Redis ෳ਺ϊʔυʹΑΔγϟʔσΟϯάͱ৑௕ԽΛࣗಈߏ੒ • ΩϟογϡΩʔͷϋογϡϕʔεͰਫฏ෼ׂ • ҆ఆӡ༻ͱεέʔϧΞ΢τΛ࣮ݱͰ͖Δ •

    Amazon ElastiCache ͰϚωʔδυͳΫϥελʔΛߏஙՄೳ
  20. Redis Cluster ͷ͓΋ͳߟྀࣄ߲ɾ੍໿ • ݸʑͷϊʔυ͸௨ৗͷ Redis ϊʔυͱେࠩͳ͍ͷͰಉ༷ͷ੍໿͕͋Δ • ϚϧνίΞεέʔϧ͠ͳ͍ɺϝϞϦྔҎ্ͷσʔλΛѻ͑ͳ͍ɺ etc…

    • γϟʔσΟϯά͸ΩϟογϡΩʔͷϋογϡϕʔε ʢʮεϩοτʯʣ • ৔߹ʹΑͬͯ͸ϗοτεϙοτ͕ग़ݱ͢Δ৔߹͕͋Δ • ΦϯϥΠϯͰγϟʔυ΍ϊʔυͷ૿ݮɾεϩοτͷ࠶഑ஔΛߦ͏͜ͱ͕Ͱ͖Δ
  21. Amazon ElastiCache ʹΑΔ Redis Cluster • Amazon ElastiCache Ͱ͸ Redis

    Cluster ͷΫϥελʔΛߏஙͰ͖Δ • υΩϡϝϯτ্͸ʮΫϥελʔϞʔυ͕༗ޮʯͱઆ໌͞Ε͍ͯΔ • ElastiCache ༻ޠͱͯ͠ͷ”Ϋϥελʔ”ͱͷ࢖͍෼͚ʹ஫ҙ • ʮRedis (ΫϥελʔϞʔυ͕༗ޮ) Ϋϥελʔʯ͸ Redis Cluster Ͱ͋Δ • ʮRedis (ΫϥελʔϞʔυ͕ແޮ) Ϋϥελʔʯ͸ Redis Cluster Ͱ͸ͳ͍ IUUQTEPDTBXTBNB[PODPNKB@KQ"NB[PO&MBTUJ$BDIFMBUFTUSFEVH$MVTUFSTIUNM
  22. ElastiCache Ͱͷ Redis Cluster ͷෛՙ෼ࢄ • ElastiCache Ͱ͸ Redis Cluster

    ͷΦϯϥΠϯΦϖϨʔγϣϯͷҰ෦Λ API ܦ༝Ͱ࣮ࢪͰ͖Δ • εϩοτͷ࠶഑ஔʹؔͯ͠͸ɺΩϟογϡΩʔͷ෼෍͕౳͘͠ͳΔΑ͏ͳ࠶഑ஔ͕Մೳ • ಛఆͷΩʔʹΞΫηε͕ภ͍ͬͯͳ͚Ε͹ɺ͜ΕͰϊʔυ/γϟʔυͷෛՙ΋֓Ͷἧ͏͸ͣ • ಛఆͷεϩοτΛಛఆͷγϟʔυʹҠಈͤ͞ΔΑ͏ͳɺΑΓࡉ͔͍഑ஔมߋ͸ߦ͑ͳ͍ • ಛఆͷΩϟογϡΩʔʹΞΫηε͕ภ͍ͬͯΔ৔߹ɺҎԼͷ͍ͣΕ͔ͰରԠ͢Δ͜ͱʹͳΔ • ϊʔυͷεέʔϧΞοϓɾγϟʔυͷεέʔϧΞ΢τʢΦϯϥΠϯͰՄೳʣ • ΫϥελʔΛ࡞Γ௚ͤ͹೚ҙͷׂΓ౰ͯʹมߋՄೳ
  23. Mackerel Ͱͷ EC2 Redis Cluster

  24. Mackerel ͷ TSDB ʹ͓͚Δ Redis Cluster • લड़ TSDB Ͱ͸

    Amazon ElastiCache ͷ࠾༻Λ༧ఆ͍ͯͨ͠ • ͔͠͠ઃܭɾ։ൃ࣌఺(2016~17೥)͸ཁ݅Λຬͨͤͳ͔ͬͨ • γϟʔυ਺্ݶ͕গͳ͘ɺΦϯϥΠϯεέʔϧ΋Ͱ͖ͳ͔ͬͨ • Amazon EC2 ্ʹ Redis Cluster Λߏஙɾӡ༻͢Δ͜ͱΛબ୒ • কདྷతʹ ElastiCache ΁Ҡߦ͢Δ·Ͱͷܨ͗ • => 3৑௕ * 18γϟʔυ = 54ϊʔυͷ Redis Cluster ͕஀ੜ
  25. Amazon EC2 ্ͷ Redis Cluster • Redis Cluster ʹΑΔ৑௕ੑʹΑΓఆৗ࣌͸҆ఆͯ͠Քಇ •

    গ਺ͷϊʔυো֐ఔ౓͸ηϧϑώʔϧՄೳ • ΞΫηεूதͰͷߴෛՙ࣌ͷରԠͳͲͰӡ༻՝୊ • Ϋϥελʔ಺௨৴ʹґΔඅ༻͕૝ఆΑΓߴֹ • ෳ਺ AZ ߏ੒ͷͨΊ AZ ؒ௨৴ͷసૹྔʹର͢Δඅ༻͕ൃੜ
  26. Redis Cluster ͷӡ༻՝୊ʢൈਮʣ • ଟ਺ͷ EC2 ΠϯελϯεͷϝϯςφϯεΦϖϨʔγϣϯ • εέʔϧΞ΢τɾεέʔϧΞοϓΛճආ͢Δ৺ཧతѹྗ •

    γϟʔυؒͷෛՙ෼ࢄ • ෛՙΛݟͳ͕ΒஸೡʹεϩοτΛ࠶഑ஔ͢ΔΦϖϨʔγϣϯ • ͨͩ͠ஸೡͳ࠶഑ஔͰط஌ͷϗοτεϙοτͷϐϯϙΠϯτରࡦ͸Մೳ • ϊʔυো֐͔Βͷ෮ؼ࣌ͳͲكʹ৑௕ߏ੒͕ཚΕΔ͜ͱ͕͋Δ • 3৑௕ͣͭͷ͸͕ͣผͷγϟʔυͷϨϓϦΧʹੜ·ΕมΘͬͯ2৑௕/4৑௕ʹͳΔ
  27. Redis Cluster ͷ Amazon ElastiCache ΁ͷҠߦ

  28. Ҡߦݕ౼։࢝ͷ͖͔͚ͬ • ElastiCache ଆͷػೳ֦ॆʹΑΓ౰ॳෆ࠾༻ͱͨ͠ཧ༝͕ղফ • => ΦϯϥΠϯεέʔϧ͸2017೥ळʹՄೳʹ • => γϟʔυ਺্ݶ͸2018೥ౙʹ֦େ

    • => ౰ॳͷߏ੒ʹҠߦͯ͠ӡ༻ෛՙΛԼ͛ΔͨΊݕ౼։࢝
  29. Ҡߦʹ౰ͨͬͯͷݕ౼ཁૉ • ElastiCache Խͨ͠΋ͷ͕ཁ݅Λຬ͍ͨͯ͠Δ͔ • طଘͷ Cluster Λ ElastiCache ʹͲ͏Ҡߦ͢Δ͔

  30. Ҡߦʹ౰ͨͬͯͷݕ౼ཁૉ • ElastiCache Խͨ͠΋ͷ͕ཁ݅Λຬ͍ͨͯ͠Δ͔ => • طଘͷ Cluster Λ ElastiCache

    ʹͲ͏Ҡߦ͢Δ͔
  31. ElastiCache ԽʹΑΔओͳมԽ Redis API ޓ׵ͳͷͰΞϓϦέʔγϣϯϨϕϧ͔Βҙࣝ͢Δ͜ͱ͸ͳ͍ ΦϖϨʔγϣϯ͸ ElastiCache ͷ API ૢ࡞Ͱߦ͑ΔΑ͏ʹͳΔ

    • ͨͩ͠γϟʔυؒͷෛՙͷࡉ͔͍ίϯτϩʔϧ͸ͮ͠Β͘ͳΔ ಉ౳ΠϯελϯελΠϓͰߏங͢Ε͹جૅεϖοΫ͸΄΅ಉ౳ EC2 Ͱߏங͢ΔΑΓΠϯελϯεʢϊʔυʣඅ༻͕໿6ׂ૿ • AZ ؒͷΫϥελʔ಺௨৴ʹΑΔసૹྔඅ༻෼ͰҰ෦؇࿨͸͞ΕΔ͕…
  32. ElastiCache ԽʹΑΔओͳมԽ • ӡ༻ෛՙͷ௿ݮ͸େ׻ܴ • ͦͷͨΊͷҠߦͳͷͰ… • σϝϦοτ͸ӡ༻ෛՙͷͨΊʹड͚ೖΕΒΕΔͱ൑அ • අ༻্ঢ͸ରՁͱͯ͠ଥ౰

    • ෛՙ෼ࢄͷࡉ੍͔͍ޚ͕ޮ͔ͳ͘ͳΔ͜ͱ΋ڐ༰ • ͍͟ͱ͍͏ͱ͖͸εέʔϧΞ΢τͤ͞Δ͜ͱͰରॲՄೳ
  33. ੑೳධՁ • ࣗ෼ͨͪͷϢʔεέʔεʹ͓͚ΔੑೳධՁ • ඇఆৗঢ়ଶͰ Redis ʹॻ͖ࠐΉ Lambda Function ͷΤϥʔ཰ɾܧଓ࣌ؒΛධՁ

    • ΦϯϥΠϯΦϖϨʔγϣϯ࣌ • εέʔϧΞ΢τɺεέʔϧΠϯ • Redis ΤϯδϯͷόʔδϣϯΞοϓ • ϊʔυͷϑΣΠϧΦʔόʔൃੜ࣌ • Kinesis Data Streams ͔Β Redis ʹࢸΔܥΛຊ൪ಉ༷ʹߏங
  34. ੑೳධՁ্ͷ݁Ռ • ֤छΦϖϨʔγϣϯ͸ಛʹΤϥʔͳ͘ΦϯϥΠϯͰ࣮ݱՄೳ • εέʔϧΞ΢τɾεέʔϧΠϯ • Redis ΤϯδϯͷόʔδϣϯΞοϓ • ϑΣΠϧΦʔόʔൃੜ࣌ʹ͸Ұ෦Ͱ୹࣌ؒॻ͖ࠐΈΤϥʔΛ؍ଌ

    • f/o ͷؔΘΔεϩοτͰͷ෦෼తͳΤϥʔ • ॻ͖ࠐΈػߏͷ଱ো֐ੑͰٵऩͰ͖Δ • EC2 ্ͷΫϥελʔͱ΄΅ಉঢ়گͱ͍͏͜ͱ΋͋Γڐ༰
  35. ӡ༻্ͷධՁ • ΋ͱ΋ͱ Mackerel ͷ AWS Ϧιʔε͸ CloudFormation Ͱ؅ཧ •

    ॳظߏஙޙͷΦϯϥΠϯૢ࡞ΛπʔϧͰ؅ཧՄೳ͔ௐࠪ • CloudFormation ͱ͋Θͤͯ Terraform ΋ݕূ • Terraform ͸ https://github.com/terraform-providers/ terraform-provider-aws Λར༻
  36. ӡ༻্ͷධՁ (2019/1࣌఺) • γϟʔυͷ૿ݮ΍Τϯδϯͷόʔδϣϯ͸྆ऀͱ΋ʹΦϯϥΠϯͰՄೳ • CloudFormation ͷ৔߹ɺϦγϟʔσΟϯά͸୯ମͰͷߋ৽͕ਪ঑͞Ε͍ͯΔ (ref: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/ aws-attribute-updatepolicy.html#cfn-attributes-updatepolicy-

    useonlineresharding ) • ϨϓϦΧ਺ͷߋ৽͸྆ऀͱ΋ΦϯϥΠϯͰ͸ෆՄೳ • Terraform ͸֎෦Ͱมߋͯ͠ޙ state ͷखಈมߋͰ⁋᧒͋ΘͤՄೳ • => ⁋᧒͋ΘͤΛڐ༰͢Δ͜ͱͰ Terraform ʹΑΔ؅ཧɾӡ༻͕Մೳͱ൑அ
  37. Ҡߦʹ౰ͨͬͯͷݕ౼ཁૉ • ElastiCache Խͨ͠΋ͷ͕ཁ݅Λຬ͍ͨͯ͠Δ͔ => OK • طଘͷ Cluster Λ

    ElastiCache ʹͲ͏Ҡߦ͢Δ͔ =>
  38. σʔλϚΠάϨʔγϣϯʢҰൠ࿦ʣ • Redis ಺ʹ͔͠ଘࡏ͠ͳ͍σʔλ͸ϚΠάϨʔγϣϯ͕ඞཁ • ΦϯϥΠϯҠߦ͕ඞཁ͔Ͱ೉қ౓͕େ͖͘มԽ͢Δ • ఀࢭͯ͠ͷҠߦͰΑ͚Ε͹೉қ౓͸େ͖͘Լ͕Δ • ElastiCache

    ͷ૊ΈࠐΈػೳͰ࣮ݱͰ͖Δ͔Ͱ΋೉қ౓͸มԽ
  39. ElastiCache ͷσʔλҠߦ • ඇ Redis Cluster Ͱ͋Ε͹ EC2 ͔ΒϨϓϦέʔγϣϯՄೳ •

    ͘͝୹࣌ؒͷॻ͖ࠐΈఀࢭͰ੾Γ׵͑Մೳ • Redis Cluster ʹର͢ΔΦϯϥΠϯϚΠάϨʔγϣϯखஈ͸ʮ·ͩʯͳ͍ • EC2 ଆͰऔͬͨεφοϓγϣοτ͔ΒΫϥελʔΛ෮ݩ͢Δ͜ͱ͸Մೳ • ॻ͖ࠐΈΛఀࢭͯ͠ͷ੾Γ׵͑ͳΒ͜Ε͚ͩͰྑ͍ • େن໛ͳ Redis Cluster ͷ৔߹੾Γ׵͑ʹͲ͏ͯ͠΋͕࣌ؒඞཁ • => Redis Cluster ͷΦϯϥΠϯҠߦखஈ͸ࣗલͰ༻ҙ͢Δඞཁ͕͋Δ
  40. Mackerel ͰͷϚΠάϨʔγϣϯ • σʔλҠߦࣗମ͸ඞཁ • ແఀࢭͰͷσʔλҠߦ͸౰ॳͷඞୡཁ݅Ͱ͸ͳ͔ͬͨ • ͱ͸͍͑ͳΔ΂͘ճආ͍ͨ͠ • ΞϓϦέʔγϣϯվमʹΑΔೋॏॻ͖ࠐΈΛݕ౼

    => ࠾༻ • ޙड़͢Δ੔߹ੑ·ΘΓͷཁ݅ΛΫϦΞͰ͖ͨͷ͕େ͖͍
  41. ೋॏॻ͖ࠐΈʹΑΔϚΠάϨʔγϣϯ • ߋ৽ॲཧΛɺ৽چ૒ํͷ Redis Cluster ʹॻ͖ࠐΉΑ͏ʹվम͢Δ • σʔλͷಉظ͕औΕͨ࣌఺ͰࢀরΛ৽ Cluster ʹ੾Γ׵͑Δ

    • => ࢀরॲཧ͸վमͤͣ୯७ʹΤϯυϙΠϯτΛ੾Γ׵͑Δ͚ͩ • σʔλͷಉظ͕͍ͭ׬ྃ͢Δ͔͸Ϣʔεέʔε࣍ୈʢࠓճͷέʔεͰ͸໿1िؒʣ • ੾Γ׵͑׬ྃޙɺچ Cluster ΁ͷॻ͖ࠐΈΛࢭΊͯ੾Γ׵͑ऴྃ 3 ⭐ 38 3 ⭐ 8 38 3 ⭐ 8 38 8
  42. ೋॏॻ͖ࠐΈʹΑΔϚΠάϨʔγϣϯ ܦ࣌มԽͰσʔλ͕ೖΕସΘΔέʔεͰ͔͠ར༻Ͱ͖ͳ͍ ݹ͍σʔλ͕࢒Γଓ͚͍ͯΔ৔߹͸ผݸҠߦ͢Δඞཁ͕͋Δ Ϋϥελʔ͕ฒߦՔಇ͍ͯ͠Δؒ૒ํͷΠϯϑϥඅ༻͕ൃੜ ೋॏॻ͖ࠐΈΛߦ͍ͬͯΔؒ͸੾Γ໭͢͠Δ͜ͱ΋Ͱ͖Δ ೋॏॻ͖ࠐΈͷؒɺߋ৽ͷΤϥʔ࣌ʹ͸੔߹ੑΛอͭඞཁ͕͋Δ ยํͷΈॻ͖ࠐΈΤϥʔΛىͨ࣌͜͠ʹͲ͏ରॲ͢Δ͔ʁ

  43. ೋॏॻ͖ࠐΈʹ͓͚Δ੔߹ੑ • ೋॏॻ͖ࠐΈΛ͢ΔͨΊʹ͸྆ऀ΁ͷ੔߹ੑΛอͬͨॻ͖ࠐΈ͕ඞཁ • Ұൠʹ͸΍΍໘౗ • ยํͷࣦഊ࣌ʹ΋͏ยํΛר͖໭͢ඞཁ͕͋Δ • ႈ౳ͳॻ͖ࠐΈͰ͋Ε͹ר͖໭͠Λলུ͢Δ͜ͱ͕Ͱ͖Δ •

    ยํ΁ͷॻ͖ࠐΈʹࣦഊͨ͠Β·Δ͝ͱ΍Γ௚ͤ͹Α͍ • ࠷ऴతʹ͸͍͔ͭ੒ޭͯ͠੔߹ੑ͕ಘΒΕΔ
  44. Mackerel ʹ͓͚Δೋॏॻ͖ࠐΈͷ࣮૷ • Lambda Function ʹೋॏॻ͖ࠐΈΛ࣮૷ • ݩʑႈ౳Ͱ࠶ࢼߦ͞ΕΔߏ੒ͩͬͨͨΊר͖໭͠ͷߟྀ͕ෆཁ • ྆ํ΁ͷॻ͖ࠐΈʹ੒ޭ͠ͳ͍ݶΓΤϥʔͱ͢Δ୯७ͳ࣮૷

    set(...args) { return Promise.all([ this.primary.set(...args), this.secondary && this.secondary.set(...args), ]).then(([prim, sec]) => prim); } get(...args) { return this.primary.get(...args); }
  45. ·ͱΊ: ElastiCache ΁ͷσʔλҠߦ • ࠓ͸ ElastiCache ଆͰ͸ Redis Cluster ͸ΦϯϥΠϯҠߦͰ͖ͳ͍

    • ΞϓϦέʔγϣϯ͔ΒͷೋॏॻࠐͰΦϯϥΠϯҠߦՄೳͱ൑அ • σʔλ͓ΑͼΞϓϦέʔγϣϯಛੑ͕͜ΕΛຬͨͨͨ͠Ί • ႈ౳ͳߋ৽ॲཧͱͯ͠ઃܭͰ͖͍ͯΔ͜ͱ͕๬·͍͠
  46. Ҡߦʹ౰ͨͬͯͷݕ౼ཁૉ => ׬ྃ • ElastiCache Խͨ͠΋ͷ͕ཁ݅Λຬ͍ͨͯ͠Δ͔ => OK • طଘͷ

    Cluster Λ ElastiCache ʹͲ͏Ҡߦ͢Δ͔ => OK
  47. ࣮ࡍͷ ElastiCache ΁ͷҠߦ Ҡߦ։ൃߏங ධՁ     σʔλҠߦ

    ࢀর੾׵ • ໿1ϲ݄൒ͷධՁϑΣΠζͰҠߦՄ൱ͱํ਑Λܾఆ • Ҡߦ։ൃ։͔࢝ΒҠߦ׬ྃ·Ͱ͸໿5ϲ݄ • ׬શઐ೚Ͱ͸ͳ͘ଞͷϓϩδΣΫτΛڬΈͳ͕Βͷ࣮ࢪ • Ϣʔβʔ޲͚ͷτϥϒϧͳ͘ҠߦΛ׬ྃ ݕূ  ݕূ 
  48. ·ͱΊ: ElastiCache ΁ͷҠߦ • ElastiCache ଆͷػೳ֦ॆʹΑΓҠߦΛ࣮ࢪ • අ༻૿͸͋Δ΋ͷͷड͚ೖΕՄೳͱ൑அ • εέʔϧૢ࡞࣌ͷӡ༻΍ΞϓϦέʔγϣϯͷڍಈΛௐࠪ

    • σʔλಉظɾ੾Γ׵͑ͷ࢓૊Έ͸ࣗ෼ͨͪͰߏங • ϢʔβʔӨڹΛग़͢͜ͱͳ͘ແఀࢭͰҠߦ
  49. ElastiCache Խ͞Ε͔ͯΒͷӡ༻

  50. ӡ༻τϐοΫ • ύϑΥʔϚϯεɾ҆ఆੑ • Πϯϑϥඅ༻ • ϞχλϦϯά • ΦϖϨʔγϣϯ

  51. ύϑΥʔϚϯεɾ҆ఆੑ • ElastiCache Խͨ͠Ϋϥελʔ͸҆ఆͯ͠Քಇ • Ұ෦γϟʔυͰ CPU Λ࢖͍੾Δߴෛՙ࣌΋ߴෛՙͳΓʹ҆ఆՔಇ • Lambda

    ͔Βͷॻ͖ࠐΈύϑΥʔϚϯε͸গ͠޲্͔ͨ͠΋͠Εͳ͍ʁ • ͍͔ͭ͘ཁҼ͕͋ΔͷͰ ElastiCache Խͱ͸੾Γ෼͚Ͱ͖ͳ͍ • ΠϯελϯελΠϓͷੈ୅มߋ (r4 => r5) • Redis ΤϯδϯͷόʔδϣϯΞοϓ (3ܥ => 5ܥ)
  52. Πϯϑϥඅ༻ • අ༻มಈ෯͸΄΅ࣄલͷݟੵ΋Γ௨Γ • Ϋϥεϥʔ಺௨৴సૹྔʹΑΔඅ༻࡟ݮͰҰ෦૬ࡴ • ࣮ࡍ͸ϦβʔϒυϊʔυΛར༻ͯ͠අ༻Λ཈͍͑ͯΔ • ͱ͸͍͑ EC2

    ΋ϦβʔϒυΠϯελϯε͕͋Δ • ʢͪ͜Βͷํ͕஋Ҿ཰΋ߴ͍……ʣ
  53. ϞχλϦϯά • Amazon CloudWatch ͔ΒಘΒΕΔϝτϦοΫΛར༻ • ࣮ࡍ͸ Mackerel ͷ AWS

    ΠϯςάϨʔγϣϯͷ࢓૊ΈͰ Mackerel ʹऔΓࠐΜͰѻ͏ • ஫ࢹ͢΂͖ϝτϦοΫ͸ ElastiCache ͷެࣜυΩϡϝϯτʹ΋هࡌ͞Ε͍ͯΔ • EC2 ࣌୅ͷ؂ࢹࢦඪͱ֓Ͷಉ౳ͷ΋ͷΛ CloudWatch ܦ༝ͰಡΈସ͑ͯ؂ࢹ • ओͳ؂ࢹࢦඪ • ϊʔυͷϦιʔεར༻ঢ়گ: EngineCPUUtilization, FreeableMemory • Ϣʔεέʔεʹ͋Θͤͨ Swap Usage, Eviction ͷ؂ࢹ
  54. ΦϖϨʔγϣϯ • खಈͰߦ͍ͬͯͨΦϖϨʔγϣϯͷ΄΅શ͕ͯ AWS API ܦ༝ʹ • ࡞ۀखॱͷѹ౗తͳ؆ུԽʹΑΔӡ༻ෛՙͷ࡟ݮ • όοΫΞοϓ΍εφοϓγϣοτͷऔΓѻ͍΋େ෯ʹָʹ

    • ӡ༻Λશͯ์غͰ͖ΔΑ͏ʹͳͬͨ༁Ͱ͸ͳ͍͜ͱʹ͸஫ҙ • Redis Cluster ࣗମΛ·Δ͝ͱӅṭͯ͘͠ΕΔ༁Ͱ͸ͳ͍ • τϥϑΟοΫٸ૿ͳͲͷߴෛՙ࣌ͷεέʔϧૢ࡞ͦͷ΋ͷ͸ඞཁ • => ElastiCache ͰͷΦϖϨʔγϣϯखॱͷ੔උɾܗࣜԽ
  55. ·ͱΊ: ӡ༻τϐοΫ • ElastiCache ΁ͷҠߦޙ҆ఆͯ͠Քಇ • Πϯϑϥඅ༻ͷ্ঢ͸૝ఆ௨Γ • CloudWatch ͔ΒಘΒΕΔΑ͏ʹͳͬͨϝτϦοΫΛݩʹ؂ࢹ

    • ΦϖϨʔγϣϯ͸ AWS API ܦ༝Ͱ׬݁͢ΔΑ͏ʹͳΓෛՙܰݮ
  56. Conclusion

  57. • Mackerel Ͱ͸ɺ AWS ্ͷෳ਺ͷσʔλετΞΛ૊Έ߹Θͤͨ࣌ܥྻσʔλϕʔε Λӡ༻͓ͯ͠ΓɺͦͷதͰ Redis Cluster ΋ར༻͍ͯ͠·͢ •

    ౰ॳ͸ EC2 ্ʹߏங͍ͯ͠·͕ͨ͠ɺ ElastiCache ͕ػೳ֦ॆ͞Εͯཁ݅Λຬͨ͢ Α͏ʹͳͬͨͨΊɺӡ༻ෛՙ࡟ݮͷͨΊҠߦ͠·ͨ͠ • Redis Cluster ͷΦϯϥΠϯσʔλҠߦ͸ ElastiCache ଆͷϚωʔδυͳ࢓૊Έ͸༻ ҙ͞Ε͍ͯͳ͍ͨΊɺΞϓϦέʔγϣϯଆͰೋॏॻ͖ࠐΈΛߦͬͯҠߦ͠·ͨ͠ • ΋ͱ΋ͱඇಉظ͔ͭႈ౳ͳॻ͖ࠐΈॲཧͰ͋ͬͨͨΊɺগͳ͍खؒͰೋॏॻ͖ࠐΈ ͕࣮ݱͰ͖·ͨ͠ • ElastiCache Λར༻͢Δ͜ͱͰɺେن໛ͳ Redis Cluster Λগͳ͍࿑ྗͰӡ༻Ͱ͖ͯ ͓Γɺ࣌ܥྻσʔλϕʔεͷίετ࠷దԽʹߩݙ͍ͯ͠·͢