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

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

astj
August 24, 2020

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

astj

August 24, 2020
Tweet

More Decks by astj

Other Decks in Technology

Transcript

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

    View full-size slide

  2. ΞδΣϯμ
    • Mackerel ͱͦͷ࣌ܥྻσʔλϕʔε
    • ෳ਺σʔλετΞͷซ༻Օॴʹ͓͚Δ Redis Cluster ͷબఆ
    • Amazon EC2 ্͔Β Amazon ElastiCache ΁ͷҠߦ
    • Amazon ElastiCache ʹΑΔ Redis Cluster ͷӡ༻

    View full-size slide

  3. ࣗݾ঺հ - Asato Wakisaka
    • GitHub @astj
    • גࣜձࣾ͸ͯͳ ΞϓϦέʔγϣϯΤϯδχΞ
    • Mackerel ։ൃνʔϜ ςοΫϦʔυ
    • Golang, TypeScript, Scala

    View full-size slide

  4. Mackerel
    • αʔόʔ؂ࢹɾ؅ཧͷ SaaS
    • 2014೥ਖ਼ࣜϦϦʔε
    • 2017೥ΑΓαʔϏεશମ͕ AWS ্ͰՔಇ
    • VM ϕʔεͷϫʔΫϩʔυΛܧଓతʹϚωʔδυαʔϏεʹҠߦ
    • Amazon EC2 => Amazon ECS, Amazon RDS, Amazon ElastiCache, …

    View full-size slide

  5. Mackerel ͷ࣌ܥྻσʔλϕʔε

    View full-size slide

  6. ࣌ܥྻσʔλϕʔε (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 ར༻཰ͷάϥϑ

    View full-size slide

  7. Mackerel ͷ࣌ܥྻσʔλϕʔε
    • ؂ࢹର৅ͷαʔόʔ΍αʔϏεͷϝτϦοΫΛऩूͯ͠ه࿥
    • ΞϥʔτͷઃఆɺάϥϑʹΑΔՄࢹԽɺ etc…
    • ΞΫηεύλʔϯ
    • ߋ৽ස౓ > ࢀরස౓
    • ࢀরہॴੑ
    • ݹ͍ߴղ૾౓ϝτϦοΫ͸͋·Γࢀর͞Εͳ͍

    View full-size slide

  8. Mackerel ͷ࣌ܥྻσʔλϕʔε
    • 2017೥ʹ AWS ʹҠߦ͢Δࡍʹ಺੡
    • ӡ༻ෛՙͷ௿ݮͱকདྷతͳεέʔϥϏϦςΟ͕ཁ݅
    • => AWS ϚωʔδυαʔϏεΛར༻

    View full-size slide

  9. 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

    View full-size slide

  10. 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
    • => σʔλετΞબఆΛ;Γ͔͑Γ·͢

    View full-size slide

  11. σʔλετΞͷબఆ
    • ϝΠϯͷσʔλετΞʹ͸ Amazon DynamoDB Λબఆ
    • ϑϧϚωʔδυܕͷ KVS
    • εϧʔϓοτɺετϨʔδ༰ྔͱ΋ʹߴ͍εέʔϥϏϦςΟ
    • Amazon DynamoDB ୯ମͰ͸ίετ໘Ͱ޻෉ͷ༨஍͕͋Δ
    • ߴස౓ʹσʔλΛॻ͖ࠐΉ͜ͱʹΑΔ Write Capacity Unit ͷফඅ
    • ௕ظؒͷ࣌ܥྻσʔλΛอ࣋͢Δ͜ͱʹΑΔετϨʔδඅ༻
    • => ಛੑͷҟͳΔଞͷσʔλετΞΛซ༻ͯ͠ղফ

    View full-size slide

  12. ॻ͖ࠐΈϦΫΤετͷޮ཰Խ
    • ౎౓௚઀ Amazon DynamoDB ʹॻ͖ࠐΉͱIOίετ͕ਹΉ
    • ࣌ܥྻσʔλ͸ຖ෼౤ߘ͞Εͯ͘Δ
    • => ॻ͖ࠐΈ API ϦΫΤετΛόοϑΝͯ͠ίετΛ௿ݮ
    • Amazon DynamoDB ΑΓ IO ʹ༏ΕͨσʔλετΞ
    • => Amazon ElastiCache ʹΑΔ Redis Cluster
    • Lambda Function ʹόοϑΝϦϯάΛ࣮૷
    8SJUF
    3FBE
    'MVTI
    3FBE

    View full-size slide

  13. ࣌ܥྻσʔλͷ௕ظอଘ
    • ݹ͍࣌ܥྻσʔλ͸ߋ৽͞Εͣɺࢀরස౓΋௿͍
    • => ࢀরͰ͖Δඞཁ͸͋Δ͕ɺϨΠςϯγཁ݅͸؇ΊΒΕΔ
    • σʔλྔతʹ͸͜ͷ”ݹ͍”σʔλ͕ଟ͘Λ઎ΊΔ
    • ͜ͷ”ݹ͍”σʔλͷ༰ྔίετΛ཈͑ΒΕΔͱޮՌత
    • => ༰ྔίετͷΑΓ௿͍σʔλετΞʹҠಈͯ͠ίετΛ௿ݮ
    • => Amazon S3
    • ௿྿ͳετϨʔδίετͱݱ࣮తͳϨΠςϯγͰར༻Մೳ
    • DynamoDB ͔ΒͷσʔλҠߦʹ͸ TTL ͱ DynamoDB Streams Λར༻
    3FBE
    3FBE
    55-5SJHHFS
    8SJUF

    View full-size slide

  14. ·ͱΊ: Mackerel ͷ࣌ܥྻσʔλϕʔε
    • ࣌ܥྻσʔλϕʔεΛ AWS ʹҠߦ͢Δࡍʹ಺੡ʹ੾Γ׵͑
    • ಛੑͷҟͳΔσʔλετΞΛ૊Έ߹Θͤͯߏங
    • εέʔϥϏϦςΟʹ༏ΕΔ Amazon DynamoDB
    • લஈͷόοϑΝͱͯ͠ Redis Cluster (Amazon ElastiCache)
    • ݹ͍σʔλͷ௕ظอ࣋ʹ Amazon S3

    View full-size slide

  15. Amazon ElastiCache ͱ
    Redis Cluster

    View full-size slide

  16. Redis Cluster
    • Redis ෳ਺ϊʔυʹΑΔγϟʔσΟϯάͱ৑௕ԽΛࣗಈߏ੒
    • ΩϟογϡΩʔͷϋογϡϕʔεͰਫฏ෼ׂ
    • ҆ఆӡ༻ͱεέʔϧΞ΢τΛ࣮ݱͰ͖Δ
    • Amazon ElastiCache ͰϚωʔδυͳΫϥελʔΛߏஙՄೳ

    View full-size slide

  17. Redis Cluster ͷ͓΋ͳߟྀࣄ߲ɾ੍໿
    • ݸʑͷϊʔυ͸௨ৗͷ Redis ϊʔυͱେࠩͳ͍ͷͰಉ༷ͷ੍໿͕͋Δ
    • ϚϧνίΞεέʔϧ͠ͳ͍ɺϝϞϦྔҎ্ͷσʔλΛѻ͑ͳ͍ɺ etc…
    • γϟʔσΟϯά͸ΩϟογϡΩʔͷϋογϡϕʔε ʢʮεϩοτʯʣ
    • ৔߹ʹΑͬͯ͸ϗοτεϙοτ͕ग़ݱ͢Δ৔߹͕͋Δ
    • ΦϯϥΠϯͰγϟʔυ΍ϊʔυͷ૿ݮɾεϩοτͷ࠶഑ஔΛߦ͏͜ͱ͕Ͱ͖Δ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  20. Mackerel Ͱͷ EC2 Redis Cluster

    View full-size slide

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

    View full-size slide

  22. Amazon EC2 ্ͷ Redis Cluster
    • Redis Cluster ʹΑΔ৑௕ੑʹΑΓఆৗ࣌͸҆ఆͯ͠Քಇ
    • গ਺ͷϊʔυো֐ఔ౓͸ηϧϑώʔϧՄೳ
    • ΞΫηεूதͰͷߴෛՙ࣌ͷରԠͳͲͰӡ༻՝୊
    • Ϋϥελʔ಺௨৴ʹґΔඅ༻͕૝ఆΑΓߴֹ
    • ෳ਺ AZ ߏ੒ͷͨΊ AZ ؒ௨৴ͷసૹྔʹର͢Δඅ༻͕ൃੜ

    View full-size slide

  23. Redis Cluster ͷӡ༻՝୊ʢൈਮʣ
    • ଟ਺ͷ EC2 ΠϯελϯεͷϝϯςφϯεΦϖϨʔγϣϯ
    • εέʔϧΞ΢τɾεέʔϧΞοϓΛճආ͢Δ৺ཧతѹྗ
    • γϟʔυؒͷෛՙ෼ࢄ
    • ෛՙΛݟͳ͕ΒஸೡʹεϩοτΛ࠶഑ஔ͢ΔΦϖϨʔγϣϯ
    • ͨͩ͠ஸೡͳ࠶഑ஔͰط஌ͷϗοτεϙοτͷϐϯϙΠϯτରࡦ͸Մೳ
    • ϊʔυো֐͔Βͷ෮ؼ࣌ͳͲكʹ৑௕ߏ੒͕ཚΕΔ͜ͱ͕͋Δ
    • 3৑௕ͣͭͷ͸͕ͣผͷγϟʔυͷϨϓϦΧʹੜ·ΕมΘͬͯ2৑௕/4৑௕ʹͳΔ

    View full-size slide

  24. Redis Cluster ͷ Amazon
    ElastiCache ΁ͷҠߦ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  28. ElastiCache ԽʹΑΔओͳมԽ
    Redis API ޓ׵ͳͷͰΞϓϦέʔγϣϯϨϕϧ͔Βҙࣝ͢Δ͜ͱ͸ͳ͍
    ΦϖϨʔγϣϯ͸ ElastiCache ͷ API ૢ࡞Ͱߦ͑ΔΑ͏ʹͳΔ
    • ͨͩ͠γϟʔυؒͷෛՙͷࡉ͔͍ίϯτϩʔϧ͸ͮ͠Β͘ͳΔ
    ಉ౳ΠϯελϯελΠϓͰߏங͢Ε͹جૅεϖοΫ͸΄΅ಉ౳
    EC2 Ͱߏங͢ΔΑΓΠϯελϯεʢϊʔυʣඅ༻͕໿6ׂ૿
    • AZ ؒͷΫϥελʔ಺௨৴ʹΑΔసૹྔඅ༻෼ͰҰ෦؇࿨͸͞ΕΔ͕…

    View full-size slide

  29. ElastiCache ԽʹΑΔओͳมԽ
    • ӡ༻ෛՙͷ௿ݮ͸େ׻ܴ
    • ͦͷͨΊͷҠߦͳͷͰ…
    • σϝϦοτ͸ӡ༻ෛՙͷͨΊʹड͚ೖΕΒΕΔͱ൑அ
    • අ༻্ঢ͸ରՁͱͯ͠ଥ౰
    • ෛՙ෼ࢄͷࡉ੍͔͍ޚ͕ޮ͔ͳ͘ͳΔ͜ͱ΋ڐ༰
    • ͍͟ͱ͍͏ͱ͖͸εέʔϧΞ΢τͤ͞Δ͜ͱͰରॲՄೳ

    View full-size slide

  30. ੑೳධՁ
    • ࣗ෼ͨͪͷϢʔεέʔεʹ͓͚ΔੑೳධՁ
    • ඇఆৗঢ়ଶͰ Redis ʹॻ͖ࠐΉ Lambda Function ͷΤϥʔ཰ɾܧଓ࣌ؒΛධՁ
    • ΦϯϥΠϯΦϖϨʔγϣϯ࣌
    • εέʔϧΞ΢τɺεέʔϧΠϯ
    • Redis ΤϯδϯͷόʔδϣϯΞοϓ
    • ϊʔυͷϑΣΠϧΦʔόʔൃੜ࣌
    • Kinesis Data Streams ͔Β Redis ʹࢸΔܥΛຊ൪ಉ༷ʹߏங

    View full-size slide

  31. ੑೳධՁ্ͷ݁Ռ
    • ֤छΦϖϨʔγϣϯ͸ಛʹΤϥʔͳ͘ΦϯϥΠϯͰ࣮ݱՄೳ
    • εέʔϧΞ΢τɾεέʔϧΠϯ
    • Redis ΤϯδϯͷόʔδϣϯΞοϓ
    • ϑΣΠϧΦʔόʔൃੜ࣌ʹ͸Ұ෦Ͱ୹࣌ؒॻ͖ࠐΈΤϥʔΛ؍ଌ
    • f/o ͷؔΘΔεϩοτͰͷ෦෼తͳΤϥʔ
    • ॻ͖ࠐΈػߏͷ଱ো֐ੑͰٵऩͰ͖Δ
    • EC2 ্ͷΫϥελʔͱ΄΅ಉঢ়گͱ͍͏͜ͱ΋͋Γڐ༰

    View full-size slide

  32. ӡ༻্ͷධՁ
    • ΋ͱ΋ͱ Mackerel ͷ AWS Ϧιʔε͸ CloudFormation Ͱ؅ཧ
    • ॳظߏஙޙͷΦϯϥΠϯૢ࡞ΛπʔϧͰ؅ཧՄೳ͔ௐࠪ
    • CloudFormation ͱ͋Θͤͯ Terraform ΋ݕূ
    • Terraform ͸ https://github.com/terraform-providers/
    terraform-provider-aws Λར༻

    View full-size slide

  33. ӡ༻্ͷධՁ (2019/1࣌఺)
    • γϟʔυͷ૿ݮ΍Τϯδϯͷόʔδϣϯ͸྆ऀͱ΋ʹΦϯϥΠϯͰՄೳ
    • CloudFormation ͷ৔߹ɺϦγϟʔσΟϯά͸୯ମͰͷߋ৽͕ਪ঑͞Ε͍ͯΔ
    (ref: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/
    aws-attribute-updatepolicy.html#cfn-attributes-updatepolicy-
    useonlineresharding )
    • ϨϓϦΧ਺ͷߋ৽͸྆ऀͱ΋ΦϯϥΠϯͰ͸ෆՄೳ
    • Terraform ͸֎෦Ͱมߋͯ͠ޙ state ͷखಈมߋͰ⁋᧒͋ΘͤՄೳ
    • => ⁋᧒͋ΘͤΛڐ༰͢Δ͜ͱͰ Terraform ʹΑΔ؅ཧɾӡ༻͕Մೳͱ൑அ

    View full-size slide

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

    View full-size slide

  35. σʔλϚΠάϨʔγϣϯʢҰൠ࿦ʣ
    • Redis ಺ʹ͔͠ଘࡏ͠ͳ͍σʔλ͸ϚΠάϨʔγϣϯ͕ඞཁ
    • ΦϯϥΠϯҠߦ͕ඞཁ͔Ͱ೉қ౓͕େ͖͘มԽ͢Δ
    • ఀࢭͯ͠ͷҠߦͰΑ͚Ε͹೉қ౓͸େ͖͘Լ͕Δ
    • ElastiCache ͷ૊ΈࠐΈػೳͰ࣮ݱͰ͖Δ͔Ͱ΋೉қ౓͸มԽ

    View full-size slide

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

    View full-size slide

  37. Mackerel ͰͷϚΠάϨʔγϣϯ
    • σʔλҠߦࣗମ͸ඞཁ
    • ແఀࢭͰͷσʔλҠߦ͸౰ॳͷඞୡཁ݅Ͱ͸ͳ͔ͬͨ
    • ͱ͸͍͑ͳΔ΂͘ճආ͍ͨ͠
    • ΞϓϦέʔγϣϯվमʹΑΔೋॏॻ͖ࠐΈΛݕ౼ => ࠾༻
    • ޙड़͢Δ੔߹ੑ·ΘΓͷཁ݅ΛΫϦΞͰ͖ͨͷ͕େ͖͍

    View full-size slide

  38. ೋॏॻ͖ࠐΈʹΑΔϚΠάϨʔγϣϯ
    • ߋ৽ॲཧΛɺ৽چ૒ํͷ Redis Cluster ʹॻ͖ࠐΉΑ͏ʹվम͢Δ
    • σʔλͷಉظ͕औΕͨ࣌఺ͰࢀরΛ৽ Cluster ʹ੾Γ׵͑Δ
    • => ࢀরॲཧ͸վमͤͣ୯७ʹΤϯυϙΠϯτΛ੾Γ׵͑Δ͚ͩ
    • σʔλͷಉظ͕͍ͭ׬ྃ͢Δ͔͸Ϣʔεέʔε࣍ୈʢࠓճͷέʔεͰ͸໿1िؒʣ
    • ੾Γ׵͑׬ྃޙɺچ Cluster ΁ͷॻ͖ࠐΈΛࢭΊͯ੾Γ׵͑ऴྃ
    3

    38
    3

    8
    38
    3

    8
    38
    8

    View full-size slide

  39. ೋॏॻ͖ࠐΈʹΑΔϚΠάϨʔγϣϯ
    ܦ࣌มԽͰσʔλ͕ೖΕସΘΔέʔεͰ͔͠ར༻Ͱ͖ͳ͍
    ݹ͍σʔλ͕࢒Γଓ͚͍ͯΔ৔߹͸ผݸҠߦ͢Δඞཁ͕͋Δ
    Ϋϥελʔ͕ฒߦՔಇ͍ͯ͠Δؒ૒ํͷΠϯϑϥඅ༻͕ൃੜ
    ೋॏॻ͖ࠐΈΛߦ͍ͬͯΔؒ͸੾Γ໭͢͠Δ͜ͱ΋Ͱ͖Δ
    ೋॏॻ͖ࠐΈͷؒɺߋ৽ͷΤϥʔ࣌ʹ͸੔߹ੑΛอͭඞཁ͕͋Δ
    ยํͷΈॻ͖ࠐΈΤϥʔΛىͨ࣌͜͠ʹͲ͏ରॲ͢Δ͔ʁ

    View full-size slide

  40. ೋॏॻ͖ࠐΈʹ͓͚Δ੔߹ੑ
    • ೋॏॻ͖ࠐΈΛ͢ΔͨΊʹ͸྆ऀ΁ͷ੔߹ੑΛอͬͨॻ͖ࠐΈ͕ඞཁ
    • Ұൠʹ͸΍΍໘౗
    • ยํͷࣦഊ࣌ʹ΋͏ยํΛר͖໭͢ඞཁ͕͋Δ
    • ႈ౳ͳॻ͖ࠐΈͰ͋Ε͹ר͖໭͠Λলུ͢Δ͜ͱ͕Ͱ͖Δ
    • ยํ΁ͷॻ͖ࠐΈʹࣦഊͨ͠Β·Δ͝ͱ΍Γ௚ͤ͹Α͍
    • ࠷ऴతʹ͸͍͔ͭ੒ޭͯ͠੔߹ੑ͕ಘΒΕΔ

    View full-size slide

  41. 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);
    }

    View full-size slide

  42. ·ͱΊ: ElastiCache ΁ͷσʔλҠߦ
    • ࠓ͸ ElastiCache ଆͰ͸ Redis Cluster ͸ΦϯϥΠϯҠߦͰ͖ͳ͍
    • ΞϓϦέʔγϣϯ͔ΒͷೋॏॻࠐͰΦϯϥΠϯҠߦՄೳͱ൑அ
    • σʔλ͓ΑͼΞϓϦέʔγϣϯಛੑ͕͜ΕΛຬͨͨͨ͠Ί
    • ႈ౳ͳߋ৽ॲཧͱͯ͠ઃܭͰ͖͍ͯΔ͜ͱ͕๬·͍͠

    View full-size slide

  43. Ҡߦʹ౰ͨͬͯͷݕ౼ཁૉ => ׬ྃ
    • ElastiCache Խͨ͠΋ͷ͕ཁ݅Λຬ͍ͨͯ͠Δ͔ => OK
    • طଘͷ Cluster Λ ElastiCache ʹͲ͏Ҡߦ͢Δ͔ => OK

    View full-size slide

  44. ࣮ࡍͷ ElastiCache ΁ͷҠߦ
    Ҡߦ։ൃߏங
    ධՁ


    σʔλҠߦ ࢀর੾׵
    • ໿1ϲ݄൒ͷධՁϑΣΠζͰҠߦՄ൱ͱํ਑Λܾఆ
    • Ҡߦ։ൃ։͔࢝ΒҠߦ׬ྃ·Ͱ͸໿5ϲ݄
    • ׬શઐ೚Ͱ͸ͳ͘ଞͷϓϩδΣΫτΛڬΈͳ͕Βͷ࣮ࢪ
    • Ϣʔβʔ޲͚ͷτϥϒϧͳ͘ҠߦΛ׬ྃ
    ݕূ
    ݕূ

    View full-size slide

  45. ·ͱΊ: ElastiCache ΁ͷҠߦ
    • ElastiCache ଆͷػೳ֦ॆʹΑΓҠߦΛ࣮ࢪ
    • අ༻૿͸͋Δ΋ͷͷड͚ೖΕՄೳͱ൑அ
    • εέʔϧૢ࡞࣌ͷӡ༻΍ΞϓϦέʔγϣϯͷڍಈΛௐࠪ
    • σʔλಉظɾ੾Γ׵͑ͷ࢓૊Έ͸ࣗ෼ͨͪͰߏங
    • ϢʔβʔӨڹΛग़͢͜ͱͳ͘ແఀࢭͰҠߦ

    View full-size slide

  46. ElastiCache Խ͞Ε͔ͯΒͷӡ༻

    View full-size slide

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

    View full-size slide

  48. ύϑΥʔϚϯεɾ҆ఆੑ
    • ElastiCache Խͨ͠Ϋϥελʔ͸҆ఆͯ͠Քಇ
    • Ұ෦γϟʔυͰ CPU Λ࢖͍੾Δߴෛՙ࣌΋ߴෛՙͳΓʹ҆ఆՔಇ
    • Lambda ͔Βͷॻ͖ࠐΈύϑΥʔϚϯε͸গ͠޲্͔ͨ͠΋͠Εͳ͍ʁ
    • ͍͔ͭ͘ཁҼ͕͋ΔͷͰ ElastiCache Խͱ͸੾Γ෼͚Ͱ͖ͳ͍
    • ΠϯελϯελΠϓͷੈ୅มߋ (r4 => r5)
    • Redis ΤϯδϯͷόʔδϣϯΞοϓ (3ܥ => 5ܥ)

    View full-size slide

  49. Πϯϑϥඅ༻
    • අ༻มಈ෯͸΄΅ࣄલͷݟੵ΋Γ௨Γ
    • Ϋϥεϥʔ಺௨৴సૹྔʹΑΔඅ༻࡟ݮͰҰ෦૬ࡴ
    • ࣮ࡍ͸ϦβʔϒυϊʔυΛར༻ͯ͠අ༻Λ཈͍͑ͯΔ
    • ͱ͸͍͑ EC2 ΋ϦβʔϒυΠϯελϯε͕͋Δ
    • ʢͪ͜Βͷํ͕஋Ҿ཰΋ߴ͍……ʣ

    View full-size slide

  50. ϞχλϦϯά
    • Amazon CloudWatch ͔ΒಘΒΕΔϝτϦοΫΛར༻
    • ࣮ࡍ͸ Mackerel ͷ AWS ΠϯςάϨʔγϣϯͷ࢓૊ΈͰ Mackerel ʹऔΓࠐΜͰѻ͏
    • ஫ࢹ͢΂͖ϝτϦοΫ͸ ElastiCache ͷެࣜυΩϡϝϯτʹ΋هࡌ͞Ε͍ͯΔ
    • EC2 ࣌୅ͷ؂ࢹࢦඪͱ֓Ͷಉ౳ͷ΋ͷΛ CloudWatch ܦ༝ͰಡΈସ͑ͯ؂ࢹ
    • ओͳ؂ࢹࢦඪ
    • ϊʔυͷϦιʔεར༻ঢ়گ: EngineCPUUtilization, FreeableMemory
    • Ϣʔεέʔεʹ͋Θͤͨ Swap Usage, Eviction ͷ؂ࢹ

    View full-size slide

  51. ΦϖϨʔγϣϯ
    • खಈͰߦ͍ͬͯͨΦϖϨʔγϣϯͷ΄΅શ͕ͯ AWS API ܦ༝ʹ
    • ࡞ۀखॱͷѹ౗తͳ؆ུԽʹΑΔӡ༻ෛՙͷ࡟ݮ
    • όοΫΞοϓ΍εφοϓγϣοτͷऔΓѻ͍΋େ෯ʹָʹ
    • ӡ༻Λશͯ์غͰ͖ΔΑ͏ʹͳͬͨ༁Ͱ͸ͳ͍͜ͱʹ͸஫ҙ
    • Redis Cluster ࣗମΛ·Δ͝ͱӅṭͯ͘͠ΕΔ༁Ͱ͸ͳ͍
    • τϥϑΟοΫٸ૿ͳͲͷߴෛՙ࣌ͷεέʔϧૢ࡞ͦͷ΋ͷ͸ඞཁ
    • => ElastiCache ͰͷΦϖϨʔγϣϯखॱͷ੔උɾܗࣜԽ

    View full-size slide

  52. ·ͱΊ: ӡ༻τϐοΫ
    • ElastiCache ΁ͷҠߦޙ҆ఆͯ͠Քಇ
    • Πϯϑϥඅ༻ͷ্ঢ͸૝ఆ௨Γ
    • CloudWatch ͔ΒಘΒΕΔΑ͏ʹͳͬͨϝτϦοΫΛݩʹ؂ࢹ
    • ΦϖϨʔγϣϯ͸ AWS API ܦ༝Ͱ׬݁͢ΔΑ͏ʹͳΓෛՙܰݮ

    View full-size slide

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

    View full-size slide