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
CloudでのMySQL
Search
rm-rf-slant
August 21, 2014
Technology
0
75
CloudでのMySQL
rm-rf-slant
August 21, 2014
Tweet
Share
More Decks by rm-rf-slant
See All by rm-rf-slant
The story behind AbemaTV
rmrfslant
10
10k
Akamai Training Day2
rmrfslant
0
100
PostgreSQL - maintenance -
rmrfslant
0
110
Other Decks in Technology
See All in Technology
エンジニアリングマネージャー視点での、自律的なスケーリングを実現するFASTという選択肢 / RSGT2025
yoshikiiida
4
3.7k
My small contributions - Fujiwara Tech Conference 2025
ijin
0
1.4k
実践! ソフトウェアエンジニアリングの価値の計測 ── Effort、Output、Outcome、Impact
nomuson
0
2.1k
Evolving Architecture
rainerhahnekamp
3
250
AWSマルチアカウント統制環境のすゝめ / 20250115 Mitsutoshi Matsuo
shift_evolve
0
110
I could be Wrong!! - Learning from Agile Experts
kawaguti
PRO
8
3.4k
AWS re:Invent 2024 recap in 20min / JAWSUG 千葉 2025.1.14
shimy
1
100
Goで実践するBFP
hiroyaterui
1
120
.NET AspireでAzure Functionsやクラウドリソースを統合する
tsubakimoto_s
0
190
CDKのコードレビューを楽にするパッケージcdk-mentorを作ってみた/cdk-mentor
tomoki10
0
210
データ基盤におけるIaCの重要性とその運用
mtpooh
4
500
Building Scalable Backend Services with Firebase
wisdommatt
0
110
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1366
200k
Rails Girls Zürich Keynote
gr2m
94
13k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Documentation Writing (for coders)
carmenintech
67
4.5k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.4k
Optimizing for Happiness
mojombo
376
70k
GitHub's CSS Performance
jonrohan
1030
460k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Scaling GitHub
holman
459
140k
Transcript
ୈ13ষɹΫϥυͰͷ MySQL
Agenda 4 ΫϥυͷϝϦοτɺσϝϦοτ 4 Ϋϥυͷ໎৴ 4 ܦࡁੑ 4 4ͭͷجຊϦιʔε͔ΒݟͨɺΫϥυͰͷMySQL ͷύϑΥʔϚϯε
4 MySQL DBaaS 4 ·ͱΊ
Agenda 4 ΫϥυͷϝϦοτɺσϝϦοτ 4 Ϋϥυͷ໎৴ 4 ܦࡁੑ 4 4ͭͷجຊϦιʔε͔ΒݟͨɺΫϥυͰͷMySQL ͷύϑΥʔϚϯε
4 MySQL DBaaS 4 ·ͱΊ
ΫϥυͷϝϦοτɺσϝϦοτ
ϝϦοτ 4 HWͷ֎෦ௐୡɺཧͷඞཁ͕Ұແ͠ 4 ӡ༻ίετݮ(ैྔ੍) 4 ιϦϡʔγϣϯͷ͕͍ͷͰɺࢢՁ্͕ Γɺ͕࣌ؒܦͭʹͭΕྑ͍ͷΛ͞ΒʹίετͰར༻Ͱ ͖ΔΑ͏ʹͳΔɻ 4
ϓϩϏδϣχϯά͕؆୯(ෆཁʹͳͬͨΒɺϘλϯҰͭͰղ ܾ)
σϝϦοτ 4 ΩϟύγςΟϓϥϯχϯά͕͍͠ (Ϧιʔεڞ༗͞ΕΔͷͰɺऔಘͨ͠Ϧιʔε͕࣮ࡍʹࢧ ͍ͬͯΔΛա͢Δ͜ͱ͕͋Δ) 4 ΩϟύγςΟՄ༹ੑʹؔ͢Δอূͳ͍ 4 τϥϒϧγϡʔςΟϯά͕͍͠ (࣮ࡍͷϋʔυͷϦιʔεΛܭଌ͢Δ͜ͱ͕Ͱ͖ͳ͍)
Agenda 4 ΫϥυͷϝϦοτɺσϝϦοτ 4 Ϋϥυͷ໎৴ 4 ܦࡁੑ 4 4ͭͷجຊϦιʔε͔ΒݟͨɺΫϥυͰͷMySQL ͷύϑΥʔϚϯε
4 MySQL DBaaS 4 ·ͱΊ
Ϋϥυͷ໎৴
ຊ࣭తʹεέʔϥϏϦςΟ͕ߴ͍ 4 ͜ΕɺCDP(Cloud Design Pattern)ʹΑΔɻ Ϋϥυ͔ͩΒͱ͍ͬͯɺԿ͠ͳͯ͘εέʔϥϒϧͳ Θ͚͕ͳ͍͠ɺϦιʔεΛબͯࣗ͠ಈతʹεέʔϥϒϧ ʹͳΔΘ͚Ͱͳ͍ɻ ڧ͍ͯݴ͑ɺϦιʔεΛඞཁʹԠͯ͡औಘͰ͖Δ͜ͱ εέʔϥϏϦςΟͷ̍ͭͱݴͬͯྑ͍ʢ͋͘·Ͱ̍ͭͷ
ଆ໘ʣ
ΞοϓλΠϜΛࣗಈతʹվળ͢Δɺ͋Δ ͍ͦΕΛอূ͢Δ 4 ࣮ɺઐ༻ͷΠϯϑϥετϥΫνϟΑΓμϯͨ͠Γػ ೳఀࢭͨ͠Γ͢ΔՄೳੑ͕ߴ͍ɻ
ʮʙΛఏڙ͢ΔͷΫϥυ͚ͩʯͱ͍ ͏ᨳ͍จ۟ 4 ࣮ࡍɺΫϥυͷ༗ແʹؔͳ͘खʹೖΕΔ͜ͱ͕Ͱ͖Δ ʢӕ͖ͭʣ
Ϋϥυಛޮༀ 4 ͍ɺҧ͍·͢w (࣮ͦͦࡍʹݴ͍ͬͯΔਓΛݟͨࣄ͕ແ͍)
Agenda 4 ΫϥυͷϝϦοτɺσϝϦοτ 4 Ϋϥυͷ໎৴ 4 ܦࡁੑ 4 4ͭͷجຊϦιʔε͔ΒݟͨɺΫϥυͰͷMySQL ͷύϑΥʔϚϯε
4 MySQL DBaaS 4 ·ͱΊ
ܦࡁੑ
ͳΜ͔͗ͬ͠Γॻ͍ͯ͋Γ·͕͢ɺ ͬ͘͟Γ·ͱΊΔͱ...
4 ΫϥυͷԸܙΛड͚͍ͯΔදྫɺήʔϜΞϓϦʹܞ ΘΔ։ൃऀɺϞόΠϧΞϓϦ։ൃऀ 4 ΞϓϦέʔγϣϯΛɺ͍ϥΠϑαΠΫϧͰߏங͠ɺ͙͢ ϦϦʔε͍ͨ͠߹࠷ద 4 εέʔϦϯάͷنͱ͞ʹࢿຊ͕ରԠ͖͠Εͳ͘ͳΔϦ εΫΛճආͰ͖Δ 4
ΫϥυϗεςΟϯάɺظతʹݟΔͱɺߴͭ͘͘͜ͱ ͕͋Δ
Agenda 4 ΫϥυͷϝϦοτɺσϝϦοτ 4 Ϋϥυͷ໎৴ 4 ܦࡁੑ 4 4ͭͷجຊϦιʔε͔ΒݟͨɺΫϥυͰͷMySQL ͷύϑΥʔϚϯε
4 MySQL DBaaS 4 ·ͱΊ
4ͭͷجຊϦιʔε͔ΒݟͨɺΫϥυͰͷ MySQLͷύϑΥʔϚϯε
MySQLΛಈ࡞ͤ͞ΔͨΊʹඞཁͳ جຊϦιʔε,,,
CPU ϝϞϦ I/O ωοτϫʔΫ
Ϋϥυͱཧαʔόͷൺֱ
CPU 4 CPUͷ͕গͳ͘ɺͰ͋Δ(࠷େͰɺίΞ8ͭ) 4 ίϞσΟςΟαʔόʹेݸͷCPUίΞ͕ࡌ͞Ε͍ͯ Δ
ϝϞϦ 4 Ϧιʔεྔଟ͍͕ɺ࠷େϝϞϦαΠζ͕ݶΒΕ͍ͯΔ (68.4GB) (ίϞςΟςΟͩͱ512GB ~ 1TB) ※ɹࠓɺi2r3͕͋Δ͔Βͬͱଟ͍(AWS)
I/O 4 εϧʔϓοτɺԆɺҰ؏ੑͷ໘ͰI/OύϑΥʔϚϯε͕ݶ ΒΕ͍ͯΔ 4 ༧ଌෆೳͳ͜ͱ͕͋Δ (ཧαʔόɺԿഒߴ)
ωοτϫʔΫ 4 ڞ༗ϦιʔεͳͷͰɺύϑΥʔϚϯεมԽ͍͑͢͠ 4 ௨ৗɺదͳύϑΥʔϚϯεΛҡ࣋͢Δ
͋Εʁ
̐ͭͷ͏ͪɺ̏ͭྼ͍ͬͯΔ...
ΫϥυͷجຊϦιʔε 4 CPUɺϝϞϦɺI/Oͷ̏ͭͷϦιʔεɺ͋Δఔ੍ݶ͕͋ ΔͬΆ͍ 4 શମతʹݟͯɺϦιʔεϋʔυΣΞʹൺΔͱɺߴੑ ೳͰͳ͍ ※ɹAWSͷΈΛൺֱ͍ͯ͠ΔͷͰɺ͋·ΓࢀߟʹͳΒͳ͍ɻ͔ ͳΓιϦϡʔγϣϯมΘ͍ͬͯΔͷͰҰ֓ʹྼ͍ͬͯΔͱ ݴ͍͍(ϕΞϝλϧͱ͔͋Δ͠ɺࠃϕϯμʔؤுͬͯΔ)
͜ΕΒΛ౿·্͑ͨͰɺύϑΥʔϚϯεݕ ূ
ྫ͑... Q. ΫϥυͰϗεςΟϯά͍ͯ͠ΔMySQLͱɺಉ͡Α͏ͳα ΠζͷཧϋʔυΣΞΛ༻ͨ͠߹Λൺֱ͢Δͱɺύ ϑΥʔϚϯε݁ՌͲ͏ͳΔʁ
εϖοΫ 4 ཧαʔό 8جͷCPUίΞɺ16GBͷϝϞϦɺதఔͷRAIDΞϨΠΛ ࡌ ɹ 4 EC2(AWS) 8جͷEC2ίϯϐϡʔτϢχοτɺ15GBͷϝϞϦɺ͍ͭ͘ ͔ͷEBS(Elastic
Block Store)Λࡌ
ྫ͑... Q. ΫϥυͰϗεςΟϯά͍ͯ͠ΔMySQLͱɺಉ͡Α͏ͳα ΠζͷཧϋʔυΣΞΛ༻ͨ͠߹Λൺֱ͢Δͱɺύ ϑΥʔϚϯε݁ՌͲ͏ͳΔʁ ɹ A. ಉఔͷύϑΥʔϚϯε͕ಘΒΕΔؾ͕͢Δ...
ݱ࣮ 4 ಉ͡͞Ͱ࣮ߦͰ͖ΔͱݶΒͳ͍ 4 EC2ΠϯελϯεͷύϑΥʔϚϯεɺཧαʔόͱൺ Δͱ҆ఆ͍ͯ͠ͳ͍ 4 ଞͷΠϯελϯεͱϦιʔεΛڞ༗͍ͯ͠Δ
ͭ·Γɺมಈతͳੑ࣭
େ
Կ͕ʁʢ1/2ʣ MySQLɺಛʹInnoDBɺύϑΥʔϚϯεͷΒ͖ͭ(I/Oύ ϑΥʔϚϯε͕มԽ͠қ͍)Λ·ͳ͍ɻI/Oॲཧɺαʔό ͰmutexϩοΫ(ഉଞ੍ޚػߏ)Λऔಘ͢ΔՄೳੑ͕͋Δɻ͜Ε ͕Ҿ͘ͱɺौ͕ى͖ͯଟ͘ͷϓϩηεཱ͕ͪԟੜ͠ɺΫΤ Ϧͷ࣮ߦʹෆࣗવͳ΄Ͳ͕͔͔࣌ؒΔΑ͏ʹͳΔɻ (ThreadsrunningɺThreadsconnectedͱ͍ͬͨঢ়ଶมͷ ͕Ͷ্͕Δ)
Կ͕ʁʢ2/2ʣ ͪߦྻͷ͞ʹӨڹ͢ΔɻԠ࣌ؒ౸ணײ֮ʹΒ͖ͭ ͕͋Εɺવɺͪߦྻ͘ͳΔɻϦιʔεͷύϑΥʔϚ ϯε͕มಈతͰ͋Ε͋Δ΄ͲɺϦΫΤετͷॏෳ͕සൃ͠ɺ ͪߦྻʹฒͿػձ͕૿͑Δɻ ݁Ռͱͯ͠ɺ΄ͱΜͲͷΫϥυίϯϐϡʔςΟϯάϓϥοτ ϑΥʔϜͰɺߴ͍ฒߦੑ҆ఆ͍ͨ͠Ԡ࣌ؒͷୡ͕ ࠔʹͳΔɻ
͏͢ज़ͳ͍ͷ͔ʁ
CPUͷ੍ݶʹؔͯ͠ɺͰ ͖Δ͜ͱͦΕ΄Ͳͳ͍ɻ
ͰɺI/Oผ
I/OύϑΥʔϚϯε্ͷͨΊͷղܾํ๏ ʢ1/4ʣ I/OʹɺشൃੑϝϞϦʢRAMʣͱӬଓϝϞϦ(σΟεΫɺ EBS)ͷͲͪΒΛར༻ͯ͠ߏΘͳ͍ɻ͜ͷͨΊɺγεςϜʹ ϝϞϦ͕ͲΕ͚ͩࡌ͞Ε͍ͯΔ͔ʹࠨӈ͞ΕΔՄೳੑ͕͋ ΔɻेͳϝϞϦ͕ࡌ͞Ε͍ͯΕɺಡΈऔΓΩϟογϡͰ ॲཧͰ͖ΔΑ͏ʹͳΔͨΊɺಡΈऔΓͱॻ͖ࠐΈʹඞཁͱͳΔ I/OΛݮͰ͖Δɻ
I/OύϑΥʔϚϯε্ͷͨΊͷղܾํ๏ ʢ2/4ʣ RAIDΛͬͯEBSϘϦϡʔϜΛετϥΠϐϯά/ϛϥʔϦϯ ά͢Εɺ͋ΔϙΠϯτ·ͰɺI/OύϑΥʔϚϯεΛվળͰ ͖Δɻ ※͔͠͠ɺEBSϘϦϡʔϜΛՃ͢ΔͱɺԿ͔ͷͣΈͰ͍ͣ Ε͔ͷϘϦϡʔϜͷύϑΥʔϚϯε͕ࠅ͘Լ͢ΔՄೳੑ͕ٯ ʹߴ͘ͳΔɻ
I/OύϑΥʔϚϯε্ͷͨΊͷղܾํ๏ ʢ3/4ʣ σʔλϕʔεͷཧઃܭͱཧઃܭ(εΩʔϚͱΠϯσοΫε) Λ৻ॏʹߦ͏Α͏ʹ͢ΕɺΞϓϦέʔγϣϯΫΤϦͷ࠷ద Խͱಉ͡Α͏ʹɺI/Oͷݮ͕ظͰ͖Δɻ͜ΕΒɺI/OΛ ݮͰ͖ΔͨΊʹద༻Ͱ͖Δ࠷ޮՌతͳखஈɻ ૠೖΛଟ༻͢ΔΑ͏ͳϫʔΫϩʔυͰɺύʔςΟγϣϯΛ্ खͬͯ͘ɺI/OΛ̍ͭͷύʔςΟγϣϯʹूதͤ͞ΔΑ͏ʹ ͢ΔͱޮՌత͔͠Εͳ͍ɻ
I/OύϑΥʔϚϯε্ͷͨΊͷղܾํ๏ ʢ4/4ʣ MySQLαʔόιϑτΣΞΛΞοϓάϨʔυ͢Δɻ
૯ධ 4 ΫϥυͷجຊϦιʔεɺཧαʔόʹൺΔͱɺ ΓߴੑೳͰͳ͍ ʢωοτϫʔΫྫ֎ʣ 4 ΫϥυͷϦιʔεมಈతͳੑ࣭ͳͷͰɺ͕ ଟ͍ 4 I/O࣍ୈͰɺύϑΥʔϚϯε্͕Ͱ͖Δ
Agenda 4 ΫϥυͷϝϦοτɺσϝϦοτ 4 Ϋϥυͷ໎৴ 4 ܦࡁੑ 4 4ͭͷجຊϦιʔε͔ΒݟͨɺΫϥυͰͷMySQL ͷύϑΥʔϚϯε
4 MySQL DBaaS 4 ·ͱΊ
MySQL DBaaS
DBaaSͱʁ ΫϥυͰϗεςΟϯά͍ͯ͠ΔαʔόʹMySQLΛΠϯε τʔϧ͢Δํ๏Ҏ֎ʹɺMySQLΛΫϥυͰ༻͢Δํ๏ ͕͋Γ·͢ɻ ͭ·Γɺσʔλϕʔε͍ͨ͠ΛϦιʔεͱͯ͠ఏڙ͢Δͱ͍͏ ͜ͱͰ͢ɻ ͦΕ͕ɺDBaaS(Database as a Service)
ͭ·ΓɺΫϥυͰDBΛऔಘ͠ɺ αʔϏεΛ࣮ࡍʹ࣮ߦ͢Δ࡞ۀ ͤΔ͜ͱ͕Ͱ͖Δ
Amazon RDS 4 ݱஈ֊Ͱ༻͍ͯ͠ΔMySQLαʔ όͱ΄΅มΘΒͳ͍ 4 γεςϜཧશͯAmazon͕ ߦͯ͘͠ΕΔ 4 ಛݖͷ੍͕͍͔ͭ͋͘ΔɹʢϨ
ϓϦέʔγϣϯؔ࿈ͷૢ࡞Ұ ࣮ߦͰ͖ͳ͍etc…ʣ
ϝϦοτ 4 σʔλϕʔεཧ࡞ۀͷେΛAmazonʹؙ͛Ͱ͖Δɻ ʢϨϓϦͱ͔શͯߦʣ 4 RDSͷ΄͏͕ଞͷํ๏ΑΓίετ͕͔͔Βͳ͍͜ͱ͕͋ Δɻ ※අ༻ߏɺਓతࢿݯʹΑͬͯ…(CDP͕͓Ζ͔ͦͩ ͱɺඅ༻ରޮՌΊͳ͍) 4
ݖݶͷ੍ݶͳͲͰɺώϡʔϚϯΤϥʔΛ͍Ͱ͘ΕΔ
σϝϦοτ 4 ͦͦαʔόʹΞΫηεͰ͖ͳ͍ ʢI/OͷԠ࣌ؒͳͲͷɺϦιʔεͷڍಈΛܭଌͰ͖ͳ͍ʣ 4 શͳεϩʔΫΤϦϩάϑΝΠϧΛऔಘͰ͖ͳ͍ʢࠅ͍ʣ 4 PerconaͷΑ͏ͳύϑΥʔϚϯεڧԽػೳɺଘࡏ͠ͳ͍ ʢΠέͯͳ͍ʣ 4
ࣗͨͪͰղܾͰ͖ΔΑ͏ͳͰɺશͯAmazonʹґ པ͠ͳ͚ΕͳΒͳ͍ʢࣃᙱ͍ʣ
͏ʔΜ…
૯ධ 4 ύϑΥʔϚϯεʹؔͯ͠ɺਖ਼ඍົɻ ίετ͔ΒݟͯɺϦιʔεࢹCloudWatchͱ͍͏ผ αʔϏεͷར༻͕ٻΊΒΕΔͷͰɺඅ༻͕༨ܭʹ͔͔Δɻ ͲͪΒ͔ͱ͍͏ͱɺϏδωεχʔζʹج͍ͮͯRDSΛ༻ ͢Δ͔൱͔Λஅ͢Δͷ͕ಘࡦɻ ύϑΥʔϚϯε͕Ͳ͏ͯ͠ඞཁͳ߹ɺܿ͘AWSΫϥ υΛఘΊ·͠ΐ͏ʂ
Cloud SQL 4 Google͕ఏڙ͍ͯ͠ΔɺϑϧϚ ωʔδυͷMySQLσʔλϕʔε 4 ෳͷκʔϯͰͷಉظɾඇಉظϨ ϓϦέʔγϣϯՄೳ 4 ಛݖͷ੍͕͍͔ͭ͋͘Δ
ʢϑΝΠϧૢ࡞ܥͷؔ(LOAD DATA INFILEͱ͔)࣮ߦͰ͖ͳ ͍etc…ʣ
ϝϦοτ 4 σʔλͷ҉߸ԽʹΑΔ҆શੑͷ্ 4 ॊೈͳྉۚମܥ 4 JDBCͱDBΞΫηεAPIΛαϙʔτ
σϝϦοτ 4 ݸʑͷΠϯελϯε500GB·Ͱ 4 GAE(Google App Engine)͋Γ͖ͷσʔλϕʔε 4 ରԠݴޠ͕গͳ͍ 4
ଞͷαʔϏεͷҠ২͕ࠔ
૯ධ 4 RDSͱൺֱ͢Δͱɺ͔ͳΓෑډ͕ߴ͍ɻ ɹ(ಋೖ͢Δʹɺ։ൃڥͳͲͰ༷ʑͳ͕ൃੜ͢Δ) 4 ύϑΥʔϚϯεະɹɹ 4 ྉۚମܥɺCloud SQLͷ΄͏͕ॊೈͳؾ͕͢Δ
Agenda 4 ΫϥυͷϝϦοτɺσϝϦοτ 4 Ϋϥυͷ໎৴ 4 ܦࡁੑ 4 4ͭͷجຊϦιʔε͔ΒݟͨɺΫϥυͰͷMySQL ͷύϑΥʔϚϯε
4 MySQL DBaaS 4 ·ͱΊ
·ͱΊ
4 Ϋϥυຐ๏Ͱͳ͍ɻ (ԿͰͰ͖Δ͠ɺສೳͱ͍͏͜ͱͰͳ͍) 4 Կߟ͑ͣΉΈʹ༻͢ΔͱɺಛޮༀͲ͜Ζ͔ಟʹͳ Δɻ (༻๏ɺ༻ྔΛकͬͯਖ਼͓͍͍ͩ͘͘͠͞) 4 ͱ͍͑ɺೖ೦ͳઃܭɺదͳઃఆΛͬͯ͢ΕԸܙΛ त͔Δ͜ͱ͕Ͱ͖Δɻ
4 ύϑΥʔϚϯε < Ϗδωεχʔζ
࠷ޙʹ
Ϋϥυͷྑ͞ɺ Agility(ػහੑ)
SlideShere http://www.slideshare.net/kuronuko/ cloudmysql
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝ ·ͨ͠