Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Mackerel の時系列データベースにおける Redis Cluster の利用と Amaz...
Search
astj
PRO
August 24, 2020
Technology
3
5.5k
Mackerel の時系列データベースにおける Redis Cluster の利用と Amazon ElastiCache への移行について / AWS Purpose-Built Databases Week
https://aws.amazon.com/jp/about-aws/events/2020/purpose-built-databases-week/
astj
PRO
August 24, 2020
Tweet
Share
More Decks by astj
See All by astj
Mackerel のコンテナ監視の近況 / Mackerel Meetup #13
astj
PRO
1
2.1k
Observability: Mackerel による観測と Mackerel の観測 / NoOps Meetup Tokyo #8
astj
PRO
2
1.9k
サービス開発と健全なプロダクトメンテナンスを開発チームで持続的に取り組む / Developers Boost KANSAI
astj
PRO
1
1.3k
Mackerel and Stripe / Qiita x Stripe Meetup
astj
PRO
0
5.3k
Mackerel をオンプレミスから AWS に移してからの1年半を振り返る / Hatena Engineer Seminar #11
astj
PRO
0
1k
AWS で実現した Mackerel 時系列データ1分粒度長期保存の裏側 / Mackerel Meetup #11 Tokyo
astj
PRO
6
29k
稼働中の Web サービスの perl のバージョンを上げていく
astj
PRO
0
7.2k
Perl 6 で Web Application Framework をつくる
astj
PRO
0
4.4k
Other Decks in Technology
See All in Technology
Amplify Gen2 Deep Dive / バックエンドの型をいかにしてフロントエンドへ伝えるか #TSKaigi #TSKaigiKansai #AWSAmplifyJP
tacck
PRO
0
380
Taming you application's environments
salaboy
0
190
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
500
Platform Engineering for Software Developers and Architects
syntasso
1
520
透過型SMTPプロキシによる送信メールの可観測性向上: Update Edition / Improved observability of outgoing emails with transparent smtp proxy: Update edition
linyows
2
210
AIチャットボット開発への生成AI活用
ryomrt
0
170
Amazon CloudWatch Network Monitor のススメ
yuki_ink
1
200
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
770
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
400
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
250
Featured
See All Featured
For a Future-Friendly Web
brad_frost
175
9.4k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Statistics for Hackers
jakevdp
796
220k
Done Done
chrislema
181
16k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Adopting Sorbet at Scale
ufuk
73
9.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Happy Clients
brianwarren
98
6.7k
Building Your Own Lightsaber
phodgson
103
6.1k
Code Review Best Practice
trishagee
64
17k
The Language of Interfaces
destraynor
154
24k
Transcript
Mackerel ͷ࣌ܥྻσʔλϕʔεʹ͓͚Δ Redis Cluster ͷར༻ͱ Amazon ElastiCache ͷҠߦʹ͍ͭͯ "84163104*-5%"5"#"4&48&&, "TBUP8BLJTBLB
)BUFOB$P -UE
ΞδΣϯμ • Mackerel ͱͦͷ࣌ܥྻσʔλϕʔε • ෳσʔλετΞͷซ༻Օॴʹ͓͚Δ Redis Cluster ͷબఆ •
Amazon EC2 ্͔Β Amazon ElastiCache ͷҠߦ • Amazon ElastiCache ʹΑΔ Redis Cluster ͷӡ༻
ࣗݾհ - Asato Wakisaka • GitHub @astj • גࣜձࣾͯͳ ΞϓϦέʔγϣϯΤϯδχΞ
• Mackerel ։ൃνʔϜ ςοΫϦʔυ • Golang, TypeScript, Scala
None
None
None
Mackerel • αʔόʔࢹɾཧͷ SaaS • 2014ਖ਼ࣜϦϦʔε • 2017ΑΓαʔϏεશମ͕ AWS ্ͰՔಇ
• VM ϕʔεͷϫʔΫϩʔυΛܧଓతʹϚωʔδυαʔϏεʹҠߦ • Amazon EC2 => Amazon ECS, Amazon RDS, Amazon ElastiCache, …
Mackerel ͷ࣌ܥྻσʔλϕʔε
࣌ܥྻσʔλϕʔε (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 ར༻ͷάϥϑ
Mackerel ͷ࣌ܥྻσʔλϕʔε • ࢹରͷαʔόʔαʔϏεͷϝτϦοΫΛऩूͯ͠ه • ΞϥʔτͷઃఆɺάϥϑʹΑΔՄࢹԽɺ etc… • ΞΫηεύλʔϯ •
ߋ৽ස > ࢀরස • ࢀরہॴੑ • ݹ͍ߴղ૾ϝτϦοΫ͋·Γࢀর͞Εͳ͍
Mackerel ͷ࣌ܥྻσʔλϕʔε • 2017ʹ AWS ʹҠߦ͢Δࡍʹ • ӡ༻ෛՙͷݮͱকདྷతͳεέʔϥϏϦςΟ͕ཁ݅ • =>
AWS ϚωʔδυαʔϏεΛར༻
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
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 • => σʔλετΞબఆΛ;Γ͔͑Γ·͢
σʔλετΞͷબఆ • ϝΠϯͷσʔλετΞʹ Amazon DynamoDB Λબఆ • ϑϧϚωʔδυܕͷ KVS •
εϧʔϓοτɺετϨʔδ༰ྔͱʹߴ͍εέʔϥϏϦςΟ • Amazon DynamoDB ୯ମͰίετ໘Ͱͷ༨͕͋Δ • ߴසʹσʔλΛॻ͖ࠐΉ͜ͱʹΑΔ Write Capacity Unit ͷফඅ • ظؒͷ࣌ܥྻσʔλΛอ࣋͢Δ͜ͱʹΑΔετϨʔδඅ༻ • => ಛੑͷҟͳΔଞͷσʔλετΞΛซ༻ͯ͠ղফ
ॻ͖ࠐΈϦΫΤετͷޮԽ • Amazon DynamoDB ʹॻ͖ࠐΉͱIOίετ͕ਹΉ • ࣌ܥྻσʔλຖߘ͞Εͯ͘Δ • =>
ॻ͖ࠐΈ API ϦΫΤετΛόοϑΝͯ͠ίετΛݮ • Amazon DynamoDB ΑΓ IO ʹ༏ΕͨσʔλετΞ • => Amazon ElastiCache ʹΑΔ Redis Cluster • Lambda Function ʹόοϑΝϦϯάΛ࣮ 8SJUF 3FBE 'MVTI 3FBE
࣌ܥྻσʔλͷظอଘ • ݹ͍࣌ܥྻσʔλߋ৽͞Εͣɺࢀরස͍ • => ࢀরͰ͖Δඞཁ͋Δ͕ɺϨΠςϯγཁ݅؇ΊΒΕΔ • σʔλྔతʹ͜ͷ”ݹ͍”σʔλ͕ଟ͘ΛΊΔ • ͜ͷ”ݹ͍”σʔλͷ༰ྔίετΛ͑ΒΕΔͱޮՌత
• => ༰ྔίετͷΑΓ͍σʔλετΞʹҠಈͯ͠ίετΛݮ • => Amazon S3 • ྿ͳετϨʔδίετͱݱ࣮తͳϨΠςϯγͰར༻Մೳ • DynamoDB ͔ΒͷσʔλҠߦʹ TTL ͱ DynamoDB Streams Λར༻ 3FBE 3FBE 55-5SJHHFS 8SJUF
·ͱΊ: Mackerel ͷ࣌ܥྻσʔλϕʔε • ࣌ܥྻσʔλϕʔεΛ AWS ʹҠߦ͢ΔࡍʹʹΓ͑ • ಛੑͷҟͳΔσʔλετΞΛΈ߹Θͤͯߏங •
εέʔϥϏϦςΟʹ༏ΕΔ Amazon DynamoDB • લஈͷόοϑΝͱͯ͠ Redis Cluster (Amazon ElastiCache) • ݹ͍σʔλͷظอ࣋ʹ Amazon S3
Amazon ElastiCache ͱ Redis Cluster
Redis Cluster • Redis ෳϊʔυʹΑΔγϟʔσΟϯάͱԽΛࣗಈߏ • ΩϟογϡΩʔͷϋογϡϕʔεͰਫฏׂ • ҆ఆӡ༻ͱεέʔϧΞτΛ࣮ݱͰ͖Δ •
Amazon ElastiCache ͰϚωʔδυͳΫϥελʔΛߏஙՄೳ
Redis Cluster ͷ͓ͳߟྀࣄ߲ɾ੍ • ݸʑͷϊʔυ௨ৗͷ Redis ϊʔυͱେࠩͳ͍ͷͰಉ༷ͷ੍͕͋Δ • ϚϧνίΞεέʔϧ͠ͳ͍ɺϝϞϦྔҎ্ͷσʔλΛѻ͑ͳ͍ɺ etc…
• γϟʔσΟϯάΩϟογϡΩʔͷϋογϡϕʔε ʢʮεϩοτʯʣ • ߹ʹΑͬͯϗοτεϙοτ͕ग़ݱ͢Δ߹͕͋Δ • ΦϯϥΠϯͰγϟʔυϊʔυͷ૿ݮɾεϩοτͷ࠶ஔΛߦ͏͜ͱ͕Ͱ͖Δ
Amazon ElastiCache ʹΑΔ Redis Cluster • Amazon ElastiCache Ͱ Redis
Cluster ͷΫϥελʔΛߏஙͰ͖Δ • υΩϡϝϯτ্ʮΫϥελʔϞʔυ͕༗ޮʯͱઆ໌͞Ε͍ͯΔ • ElastiCache ༻ޠͱͯ͠ͷ”Ϋϥελʔ”ͱͷ͍͚ʹҙ • ʮRedis (ΫϥελʔϞʔυ͕༗ޮ) Ϋϥελʔʯ Redis Cluster Ͱ͋Δ • ʮRedis (ΫϥελʔϞʔυ͕ແޮ) Ϋϥελʔʯ Redis Cluster Ͱͳ͍ IUUQTEPDTBXTBNB[PODPNKB@KQ"NB[PO&MBTUJ$BDIFMBUFTUSFEVH$MVTUFSTIUNM
ElastiCache Ͱͷ Redis Cluster ͷෛՙࢄ • ElastiCache Ͱ Redis Cluster
ͷΦϯϥΠϯΦϖϨʔγϣϯͷҰ෦Λ API ܦ༝Ͱ࣮ࢪͰ͖Δ • εϩοτͷ࠶ஔʹؔͯ͠ɺΩϟογϡΩʔͷ͕͘͠ͳΔΑ͏ͳ࠶ஔ͕Մೳ • ಛఆͷΩʔʹΞΫηε͕ภ͍ͬͯͳ͚Εɺ͜ΕͰϊʔυ/γϟʔυͷෛՙ֓Ͷἧ͏ͣ • ಛఆͷεϩοτΛಛఆͷγϟʔυʹҠಈͤ͞ΔΑ͏ͳɺΑΓࡉ͔͍ஔมߋߦ͑ͳ͍ • ಛఆͷΩϟογϡΩʔʹΞΫηε͕ภ͍ͬͯΔ߹ɺҎԼͷ͍ͣΕ͔ͰରԠ͢Δ͜ͱʹͳΔ • ϊʔυͷεέʔϧΞοϓɾγϟʔυͷεέʔϧΞτʢΦϯϥΠϯͰՄೳʣ • ΫϥελʔΛ࡞ΓͤҙͷׂΓͯʹมߋՄೳ
Mackerel Ͱͷ EC2 Redis Cluster
Mackerel ͷ TSDB ʹ͓͚Δ Redis Cluster • લड़ TSDB Ͱ
Amazon ElastiCache ͷ࠾༻Λ༧ఆ͍ͯͨ͠ • ͔͠͠ઃܭɾ։ൃ࣌(2016~17)ཁ݅Λຬͨͤͳ͔ͬͨ • γϟʔυ্ݶ͕গͳ͘ɺΦϯϥΠϯεέʔϧͰ͖ͳ͔ͬͨ • Amazon EC2 ্ʹ Redis Cluster Λߏஙɾӡ༻͢Δ͜ͱΛબ • কདྷతʹ ElastiCache Ҡߦ͢Δ·Ͱͷܨ͗ • => 3 * 18γϟʔυ = 54ϊʔυͷ Redis Cluster ͕ੜ
Amazon EC2 ্ͷ Redis Cluster • Redis Cluster ʹΑΔੑʹΑΓఆৗ࣌҆ఆͯ͠Քಇ •
গͷϊʔυোఔηϧϑώʔϧՄೳ • ΞΫηεूதͰͷߴෛՙ࣌ͷରԠͳͲͰӡ༻՝ • Ϋϥελʔ௨৴ʹґΔඅ༻͕ఆΑΓߴֹ • ෳ AZ ߏͷͨΊ AZ ؒ௨৴ͷసૹྔʹର͢Δඅ༻͕ൃੜ
Redis Cluster ͷӡ༻՝ʢൈਮʣ • ଟͷ EC2 ΠϯελϯεͷϝϯςφϯεΦϖϨʔγϣϯ • εέʔϧΞτɾεέʔϧΞοϓΛճආ͢Δ৺ཧతѹྗ •
γϟʔυؒͷෛՙࢄ • ෛՙΛݟͳ͕ΒஸೡʹεϩοτΛ࠶ஔ͢ΔΦϖϨʔγϣϯ • ͨͩ͠ஸೡͳ࠶ஔͰطͷϗοτεϙοτͷϐϯϙΠϯτରࡦՄೳ • ϊʔυো͔Βͷ෮ؼ࣌ͳͲكʹߏ͕ཚΕΔ͜ͱ͕͋Δ • 3ͣͭͷ͕ͣผͷγϟʔυͷϨϓϦΧʹੜ·ΕมΘͬͯ2/4ʹͳΔ
Redis Cluster ͷ Amazon ElastiCache ͷҠߦ
Ҡߦݕ౼։࢝ͷ͖͔͚ͬ • ElastiCache ଆͷػೳ֦ॆʹΑΓॳෆ࠾༻ͱͨ͠ཧ༝͕ղফ • => ΦϯϥΠϯεέʔϧ2017ळʹՄೳʹ • => γϟʔυ্ݶ2018ౙʹ֦େ
• => ॳͷߏʹҠߦͯ͠ӡ༻ෛՙΛԼ͛ΔͨΊݕ౼։࢝
Ҡߦʹͨͬͯͷݕ౼ཁૉ • ElastiCache Խͨ͠ͷ͕ཁ݅Λຬ͍ͨͯ͠Δ͔ • طଘͷ Cluster Λ ElastiCache ʹͲ͏Ҡߦ͢Δ͔
Ҡߦʹͨͬͯͷݕ౼ཁૉ • ElastiCache Խͨ͠ͷ͕ཁ݅Λຬ͍ͨͯ͠Δ͔ => • طଘͷ Cluster Λ ElastiCache
ʹͲ͏Ҡߦ͢Δ͔
ElastiCache ԽʹΑΔओͳมԽ Redis API ޓͳͷͰΞϓϦέʔγϣϯϨϕϧ͔Βҙࣝ͢Δ͜ͱͳ͍ ΦϖϨʔγϣϯ ElastiCache ͷ API ૢ࡞Ͱߦ͑ΔΑ͏ʹͳΔ
• ͨͩ͠γϟʔυؒͷෛՙͷࡉ͔͍ίϯτϩʔϧͮ͠Β͘ͳΔ ಉΠϯελϯελΠϓͰߏங͢ΕجૅεϖοΫ΄΅ಉ EC2 Ͱߏங͢ΔΑΓΠϯελϯεʢϊʔυʣඅ༻͕6ׂ૿ • AZ ؒͷΫϥελʔ௨৴ʹΑΔసૹྔඅ༻ͰҰ෦؇͞ΕΔ͕…
ElastiCache ԽʹΑΔओͳมԽ • ӡ༻ෛՙͷݮେܴ • ͦͷͨΊͷҠߦͳͷͰ… • σϝϦοτӡ༻ෛՙͷͨΊʹड͚ೖΕΒΕΔͱஅ • අ༻্ঢରՁͱͯ͠ଥ
• ෛՙࢄͷࡉ੍͔͍ޚ͕ޮ͔ͳ͘ͳΔ͜ͱڐ༰ • ͍͟ͱ͍͏ͱ͖εέʔϧΞτͤ͞Δ͜ͱͰରॲՄೳ
ੑೳධՁ • ࣗͨͪͷϢʔεέʔεʹ͓͚ΔੑೳධՁ • ඇఆৗঢ়ଶͰ Redis ʹॻ͖ࠐΉ Lambda Function ͷΤϥʔɾܧଓ࣌ؒΛධՁ
• ΦϯϥΠϯΦϖϨʔγϣϯ࣌ • εέʔϧΞτɺεέʔϧΠϯ • Redis ΤϯδϯͷόʔδϣϯΞοϓ • ϊʔυͷϑΣΠϧΦʔόʔൃੜ࣌ • Kinesis Data Streams ͔Β Redis ʹࢸΔܥΛຊ൪ಉ༷ʹߏங
ੑೳධՁ্ͷ݁Ռ • ֤छΦϖϨʔγϣϯಛʹΤϥʔͳ͘ΦϯϥΠϯͰ࣮ݱՄೳ • εέʔϧΞτɾεέʔϧΠϯ • Redis ΤϯδϯͷόʔδϣϯΞοϓ • ϑΣΠϧΦʔόʔൃੜ࣌ʹҰ෦Ͱ࣌ؒॻ͖ࠐΈΤϥʔΛ؍ଌ
• f/o ͷؔΘΔεϩοτͰͷ෦తͳΤϥʔ • ॻ͖ࠐΈػߏͷোੑͰٵऩͰ͖Δ • EC2 ্ͷΫϥελʔͱ΄΅ಉঢ়گͱ͍͏͜ͱ͋Γڐ༰
ӡ༻্ͷධՁ • ͱͱ Mackerel ͷ AWS Ϧιʔε CloudFormation Ͱཧ •
ॳظߏஙޙͷΦϯϥΠϯૢ࡞ΛπʔϧͰཧՄೳ͔ௐࠪ • CloudFormation ͱ͋Θͤͯ Terraform ݕূ • Terraform https://github.com/terraform-providers/ terraform-provider-aws Λར༻
ӡ༻্ͷධՁ (2019/1࣌) • γϟʔυͷ૿ݮΤϯδϯͷόʔδϣϯ྆ऀͱʹΦϯϥΠϯͰՄೳ • CloudFormation ͷ߹ɺϦγϟʔσΟϯά୯ମͰͷߋ৽͕ਪ͞Ε͍ͯΔ (ref: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/ aws-attribute-updatepolicy.html#cfn-attributes-updatepolicy-
useonlineresharding ) • ϨϓϦΧͷߋ৽྆ऀͱΦϯϥΠϯͰෆՄೳ • Terraform ֎෦Ͱมߋͯ͠ޙ state ͷखಈมߋͰ⁋᧒͋ΘͤՄೳ • => ⁋᧒͋ΘͤΛڐ༰͢Δ͜ͱͰ Terraform ʹΑΔཧɾӡ༻͕Մೳͱஅ
Ҡߦʹͨͬͯͷݕ౼ཁૉ • ElastiCache Խͨ͠ͷ͕ཁ݅Λຬ͍ͨͯ͠Δ͔ => OK • طଘͷ Cluster Λ
ElastiCache ʹͲ͏Ҡߦ͢Δ͔ =>
σʔλϚΠάϨʔγϣϯʢҰൠʣ • Redis ʹ͔͠ଘࡏ͠ͳ͍σʔλϚΠάϨʔγϣϯ͕ඞཁ • ΦϯϥΠϯҠߦ͕ඞཁ͔Ͱқ͕େ͖͘มԽ͢Δ • ఀࢭͯ͠ͷҠߦͰΑ͚Εқେ͖͘Լ͕Δ • ElastiCache
ͷΈࠐΈػೳͰ࣮ݱͰ͖Δ͔ͰқมԽ
ElastiCache ͷσʔλҠߦ • ඇ Redis Cluster Ͱ͋Ε EC2 ͔ΒϨϓϦέʔγϣϯՄೳ •
࣌ؒ͘͝ͷॻ͖ࠐΈఀࢭͰΓ͑Մೳ • Redis Cluster ʹର͢ΔΦϯϥΠϯϚΠάϨʔγϣϯखஈʮ·ͩʯͳ͍ • EC2 ଆͰऔͬͨεφοϓγϣοτ͔ΒΫϥελʔΛ෮ݩ͢Δ͜ͱՄೳ • ॻ͖ࠐΈΛఀࢭͯ͠ͷΓ͑ͳΒ͜Ε͚ͩͰྑ͍ • େنͳ Redis Cluster ͷ߹Γ͑ʹͲ͏͕ͯ࣌ؒ͠ඞཁ • => Redis Cluster ͷΦϯϥΠϯҠߦखஈࣗલͰ༻ҙ͢Δඞཁ͕͋Δ
Mackerel ͰͷϚΠάϨʔγϣϯ • σʔλҠߦࣗମඞཁ • ແఀࢭͰͷσʔλҠߦॳͷඞୡཁ݅Ͱͳ͔ͬͨ • ͱ͍͑ͳΔ͘ճආ͍ͨ͠ • ΞϓϦέʔγϣϯվमʹΑΔೋॏॻ͖ࠐΈΛݕ౼
=> ࠾༻ • ޙड़͢Δ߹ੑ·ΘΓͷཁ݅ΛΫϦΞͰ͖ͨͷ͕େ͖͍
ೋॏॻ͖ࠐΈʹΑΔϚΠάϨʔγϣϯ • ߋ৽ॲཧΛɺ৽چํͷ Redis Cluster ʹॻ͖ࠐΉΑ͏ʹվम͢Δ • σʔλͷಉظ͕औΕͨ࣌ͰࢀরΛ৽ Cluster ʹΓ͑Δ
• => ࢀরॲཧվमͤͣ୯७ʹΤϯυϙΠϯτΛΓ͑Δ͚ͩ • σʔλͷಉظ͕͍ͭྃ͢Δ͔Ϣʔεέʔε࣍ୈʢࠓճͷέʔεͰ1िؒʣ • Γ͑ྃޙɺچ Cluster ͷॻ͖ࠐΈΛࢭΊͯΓ͑ऴྃ 3 ⭐ 38 3 ⭐ 8 38 3 ⭐ 8 38 8
ೋॏॻ͖ࠐΈʹΑΔϚΠάϨʔγϣϯ ܦ࣌มԽͰσʔλ͕ೖΕସΘΔέʔεͰ͔͠ར༻Ͱ͖ͳ͍ ݹ͍σʔλ͕Γଓ͚͍ͯΔ߹ผݸҠߦ͢Δඞཁ͕͋Δ Ϋϥελʔ͕ฒߦՔಇ͍ͯ͠ΔؒํͷΠϯϑϥඅ༻͕ൃੜ ೋॏॻ͖ࠐΈΛߦ͍ͬͯΔؒΓ͢͠Δ͜ͱͰ͖Δ ೋॏॻ͖ࠐΈͷؒɺߋ৽ͷΤϥʔ࣌ʹ߹ੑΛอͭඞཁ͕͋Δ ยํͷΈॻ͖ࠐΈΤϥʔΛىͨ࣌͜͠ʹͲ͏ରॲ͢Δ͔ʁ
ೋॏॻ͖ࠐΈʹ͓͚Δ߹ੑ • ೋॏॻ͖ࠐΈΛ͢ΔͨΊʹ྆ऀͷ߹ੑΛอͬͨॻ͖ࠐΈ͕ඞཁ • Ұൠʹ໘ • ยํͷࣦഊ࣌ʹ͏ยํΛר͖͢ඞཁ͕͋Δ • ႈͳॻ͖ࠐΈͰ͋Εר͖͠Λলུ͢Δ͜ͱ͕Ͱ͖Δ •
ยํͷॻ͖ࠐΈʹࣦഊͨ͠Β·Δ͝ͱΓͤΑ͍ • ࠷ऴతʹ͍͔ͭޭͯ͠߹ੑ͕ಘΒΕΔ
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); }
·ͱΊ: ElastiCache ͷσʔλҠߦ • ࠓ ElastiCache ଆͰ Redis Cluster ΦϯϥΠϯҠߦͰ͖ͳ͍
• ΞϓϦέʔγϣϯ͔ΒͷೋॏॻࠐͰΦϯϥΠϯҠߦՄೳͱஅ • σʔλ͓ΑͼΞϓϦέʔγϣϯಛੑ͕͜ΕΛຬͨͨͨ͠Ί • ႈͳߋ৽ॲཧͱͯ͠ઃܭͰ͖͍ͯΔ͜ͱ͕·͍͠
Ҡߦʹͨͬͯͷݕ౼ཁૉ => ྃ • ElastiCache Խͨ͠ͷ͕ཁ݅Λຬ͍ͨͯ͠Δ͔ => OK • طଘͷ
Cluster Λ ElastiCache ʹͲ͏Ҡߦ͢Δ͔ => OK
࣮ࡍͷ ElastiCache ͷҠߦ Ҡߦ։ൃߏங ධՁ σʔλҠߦ
ࢀর • 1ϲ݄ͷධՁϑΣΠζͰҠߦՄ൱ͱํΛܾఆ • Ҡߦ։ൃ։͔࢝ΒҠߦྃ·Ͱ5ϲ݄ • શઐͰͳ͘ଞͷϓϩδΣΫτΛڬΈͳ͕Βͷ࣮ࢪ • Ϣʔβʔ͚ͷτϥϒϧͳ͘ҠߦΛྃ ݕূ ݕূ
·ͱΊ: ElastiCache ͷҠߦ • ElastiCache ଆͷػೳ֦ॆʹΑΓҠߦΛ࣮ࢪ • අ༻૿͋Δͷͷड͚ೖΕՄೳͱஅ • εέʔϧૢ࡞࣌ͷӡ༻ΞϓϦέʔγϣϯͷڍಈΛௐࠪ
• σʔλಉظɾΓ͑ͷΈࣗͨͪͰߏங • ϢʔβʔӨڹΛग़͢͜ͱͳ͘ແఀࢭͰҠߦ
ElastiCache Խ͞Ε͔ͯΒͷӡ༻
ӡ༻τϐοΫ • ύϑΥʔϚϯεɾ҆ఆੑ • Πϯϑϥඅ༻ • ϞχλϦϯά • ΦϖϨʔγϣϯ
ύϑΥʔϚϯεɾ҆ఆੑ • ElastiCache Խͨ͠Ϋϥελʔ҆ఆͯ͠Քಇ • Ұ෦γϟʔυͰ CPU Λ͍Δߴෛՙ࣌ߴෛՙͳΓʹ҆ఆՔಇ • Lambda
͔Βͷॻ͖ࠐΈύϑΥʔϚϯεগ্͔ͨ͠͠͠Εͳ͍ʁ • ͍͔ͭ͘ཁҼ͕͋ΔͷͰ ElastiCache ԽͱΓ͚Ͱ͖ͳ͍ • ΠϯελϯελΠϓͷੈมߋ (r4 => r5) • Redis ΤϯδϯͷόʔδϣϯΞοϓ (3ܥ => 5ܥ)
Πϯϑϥඅ༻ • අ༻มಈ෯΄΅ࣄલͷݟੵΓ௨Γ • Ϋϥεϥʔ௨৴సૹྔʹΑΔඅ༻ݮͰҰ෦૬ࡴ • ࣮ࡍϦβʔϒυϊʔυΛར༻ͯ͠අ༻Λ͍͑ͯΔ • ͱ͍͑ EC2
ϦβʔϒυΠϯελϯε͕͋Δ • ʢͪ͜Βͷํ͕Ҿߴ͍……ʣ
ϞχλϦϯά • Amazon CloudWatch ͔ΒಘΒΕΔϝτϦοΫΛར༻ • ࣮ࡍ Mackerel ͷ AWS
ΠϯςάϨʔγϣϯͷΈͰ Mackerel ʹऔΓࠐΜͰѻ͏ • ࢹ͖͢ϝτϦοΫ ElastiCache ͷެࣜυΩϡϝϯτʹهࡌ͞Ε͍ͯΔ • EC2 ࣌ͷࢹࢦඪͱ֓ͶಉͷͷΛ CloudWatch ܦ༝ͰಡΈସ͑ͯࢹ • ओͳࢹࢦඪ • ϊʔυͷϦιʔεར༻ঢ়گ: EngineCPUUtilization, FreeableMemory • Ϣʔεέʔεʹ͋Θͤͨ Swap Usage, Eviction ͷࢹ
ΦϖϨʔγϣϯ • खಈͰߦ͍ͬͯͨΦϖϨʔγϣϯͷ΄΅શ͕ͯ AWS API ܦ༝ʹ • ࡞ۀखॱͷѹతͳ؆ུԽʹΑΔӡ༻ෛՙͷݮ • όοΫΞοϓεφοϓγϣοτͷऔΓѻ͍େ෯ʹָʹ
• ӡ༻Λશͯ์غͰ͖ΔΑ͏ʹͳͬͨ༁Ͱͳ͍͜ͱʹҙ • Redis Cluster ࣗମΛ·Δ͝ͱӅṭͯ͘͠ΕΔ༁Ͱͳ͍ • τϥϑΟοΫٸ૿ͳͲͷߴෛՙ࣌ͷεέʔϧૢ࡞ͦͷͷඞཁ • => ElastiCache ͰͷΦϖϨʔγϣϯखॱͷඋɾܗࣜԽ
·ͱΊ: ӡ༻τϐοΫ • ElastiCache ͷҠߦޙ҆ఆͯ͠Քಇ • Πϯϑϥඅ༻ͷ্ঢఆ௨Γ • CloudWatch ͔ΒಘΒΕΔΑ͏ʹͳͬͨϝτϦοΫΛݩʹࢹ
• ΦϖϨʔγϣϯ AWS API ܦ༝Ͱ݁͢ΔΑ͏ʹͳΓෛՙܰݮ
Conclusion
• Mackerel Ͱɺ AWS ্ͷෳͷσʔλετΞΛΈ߹Θͤͨ࣌ܥྻσʔλϕʔε Λӡ༻͓ͯ͠ΓɺͦͷதͰ Redis Cluster ར༻͍ͯ͠·͢ •
ॳ EC2 ্ʹߏங͍ͯ͠·͕ͨ͠ɺ ElastiCache ͕ػೳ֦ॆ͞Εͯཁ݅Λຬͨ͢ Α͏ʹͳͬͨͨΊɺӡ༻ෛՙݮͷͨΊҠߦ͠·ͨ͠ • Redis Cluster ͷΦϯϥΠϯσʔλҠߦ ElastiCache ଆͷϚωʔδυͳΈ༻ ҙ͞Ε͍ͯͳ͍ͨΊɺΞϓϦέʔγϣϯଆͰೋॏॻ͖ࠐΈΛߦͬͯҠߦ͠·ͨ͠ • ͱͱඇಉظ͔ͭႈͳॻ͖ࠐΈॲཧͰ͋ͬͨͨΊɺগͳ͍खؒͰೋॏॻ͖ࠐΈ ͕࣮ݱͰ͖·ͨ͠ • ElastiCache Λར༻͢Δ͜ͱͰɺେنͳ Redis Cluster Λগͳ͍࿑ྗͰӡ༻Ͱ͖ͯ ͓Γɺ࣌ܥྻσʔλϕʔεͷίετ࠷దԽʹߩݙ͍ͯ͠·͢