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
Webアプリケーションのキャッシュ戦略とそのパターン / Pattern and Strate...
Search
moznion
March 04, 2017
Technology
72
360k
Webアプリケーションのキャッシュ戦略とそのパターン / Pattern and Strategy of Web Application Caching
YAPC::Kansai OSAKA 2017の資料です
moznion
March 04, 2017
Tweet
Share
More Decks by moznion
See All by moznion
Develop to Survive - YAPC::Hakodate 2024 Keynote
moznion
9
13k
これはPerl? それともRuby? クイズ〜〜〜〜〜!!!- Perl or Ruby Quiz
moznion
3
2.2k
Perl 5 OOP機構30年史 - Perl 5's OOP Mechanism over the past 30 years
moznion
1
880
RuboCopのカスタムCopを書いてContributionしてみる - Contributing a Custom Cop to RuboCop: A Hands-on Experience
moznion
0
56
AWS上に構築する メンテ容易なElasticsearch System / Maintainable Elasticsearch system on AWS
moznion
2
3.9k
PROXY Protocol aware Proxy Server on Node.js
moznion
2
2.4k
Perl meets AWS Lambda
moznion
0
4.6k
ソフトウェア開発における 「設計」と「パフォーマンス」の相互作用 / Interaction Between Design and Performance on Software Development
moznion
12
6.8k
Javaカードの世界 / The world of Java Card
moznion
9
13k
Other Decks in Technology
See All in Technology
Figma Dev Modeで進化するデザインとエンジニアリングの協働 / figma-with-engineering
cyberagentdevelopers
PRO
1
430
IaC運用を楽にするためにCDK Pipelinesを導入したけど、思い通りにいかなかった話
smt7174
1
110
君は隠しイベントを見つけれるか?
mujyun
0
270
APIテスト自動化の勘所
yokawasa
7
4.1k
プロダクト成長に対応するプラットフォーム戦略:Authleteによる共通認証基盤の移行事例 / Building an authentication platform using Authlete and AWS
kakehashi
1
150
【技術書典17】OpenFOAM(自宅で極める流体解析)2次元円柱まわりの流れ
kamakiri1225
0
210
AIを駆使したゲーム開発戦略: 新設AI組織の取り組み / sge-ai-strategy
cyberagentdevelopers
PRO
1
130
とあるユーザー企業におけるリスクベースで考えるセキュリティ業務のお話し
4su_para
3
320
新卒1年目が向き合う生成AI事業の開発を加速させる技術選定 / ai-web-launcher
cyberagentdevelopers
PRO
7
1.5k
Fargateを使った研修の話
takesection
0
110
「最高のチューニング」をしないために / hack@delta 24.10
fujiwara3
21
3.4k
[AWS JAPAN 生成AIハッカソン] Dialog の紹介
yoshimi0227
0
140
Featured
See All Featured
Fireside Chat
paigeccino
32
3k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
We Have a Design System, Now What?
morganepeng
50
7.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
Documentation Writing (for coders)
carmenintech
65
4.4k
Become a Pro
speakerdeck
PRO
24
5k
Fontdeck: Realign not Redesign
paulrobertlloyd
81
5.2k
Producing Creativity
orderedlist
PRO
341
39k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
Measuring & Analyzing Core Web Vitals
bluesmoon
1
39
Thoughts on Productivity
jonyablonski
67
4.3k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.9k
Transcript
WebΞϓϦέʔγϣϯͷ Ωϟογϡઓུͱ ͦͷύλʔϯ @moznion
None
໔ ੈͷத৭ʑͳέʔε͕͋Γ·͔͢Β શͯΛΧόʔ͢Δ༰ແཧͰͨ͠ ͜ͷ༰҃ΔҰྫͩͱࢥͬͯ ϦϥοΫεͯ͠ோΊ͍ͯͩ͘͞
@moznion Web application server side engineer Twitter: @moznion GitHub: moznion
Ωϟογϡ
ࠓճ͢͜ͱ - WebΞϓϦέʔγϣϯʹ͓͚ΔΩϟογϡʹ͍ͭͯ - HTTPϨΠϠͰͷΩϟογϡ - ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ - ΩϟογϡΛΊΑ͏
લఏ: ߴͳ (Web) ΞϓϦέʔγϣϯΛ ߏஙɾӡ༻͍ͯ͘͠ඞཁ͕͋Δ
Ωϟογϡͱͳʹ͔ʁ
Ωϟογϡʁ ʮΩϟογϡ: ΛӅͨ͠Γ֨ೲͨ͠Γ͓ͯ͘͠ͷʹ҆શͳॴʯ ― Webster ৽ੈքถޠࣙయɼΧϨοδ൛ ୈ3൛ ʮΩϟογϡͱௐΔඞཁͷ͋ΔͷΛஔ͍͓ͯ҆͘શͳॴͷ ͜ͱͰ͋ΔɽΩϟογϡͱ͍͏༻ޠɼ࠷ॳͷ༻ίϯϐϡʔλʹ ͓͍ͯɼϓϩηοαͱओهԱͱͷؒʹૠೖ͞ΕͨهԱ֊ϨϕϧΛ
දͨ͢Ίʹ༻͞Εͨɽ(தུ) ͜ͷ༻ޠࠓͰࢀরͷہॴੑΛ ར༻͢ΔΑ͏ʹཧ͞ΕͨҙͷهԱΛࢦͯ͠༻͞ΕΔʯ ― σΠϏου A ύλʔιϯ, δϣϯ ̡ ϔωγʔ ஶ, ా ޫজ ༁ ίϯϐϡʔλͷߏͱઃܭɼୈ5൛ [Լ] ❞ ❞
ͳΔ΄Ͳ…
લఏ: ߴͳ (Web) ΞϓϦέʔγϣϯΛ ߏஙɾӡ༻͍ͯ͘͠ඞཁ͕͋Δ
લఏ: ߴͳ (Web) ΞϓϦέʔγϣϯΛ ߏஙɾӡ༻͍ͯ͘͠ඞཁ͕͋Δ
Ωϟογϡʁ ʮΩϟογϡ: ΛӅͨ͠Γ֨ೲͨ͠Γ͓ͯ͘͠ͷʹ҆શͳॴʯ ― Webster ৽ੈքถޠࣙయɼΧϨοδ൛ ୈ3൛ ʮΩϟογϡͱௐΔඞཁͷ͋ΔͷΛஔ͍͓ͯ҆͘શͳॴͷ ͜ͱͰ͋ΔɽΩϟογϡͱ͍͏༻ޠɼ࠷ॳͷ༻ίϯϐϡʔλʹ ͓͍ͯɼϓϩηοαͱओهԱͱͷؒʹૠೖ͞ΕͨهԱ֊ϨϕϧΛ
දͨ͢Ίʹ༻͞Εͨɽ(தུ) ͜ͷ༻ޠࠓͰࢀরͷہॴੑΛ ར༻͢ΔΑ͏ʹཧ͞ΕͨҙͷهԱΛࢦͯ͠༻͞ΕΔʯ ― σΠϏου A ύλʔιϯ, δϣϯ ̡ ϔωγʔ ஶ, ా ޫজ ༁ ίϯϐϡʔλͷߏͱઃܭɼୈ5൛ [Լ] ❞ ❞
Ωϟογϡʁ ʮΩϟογϡ: ΛӅͨ͠Γ֨ೲͨ͠Γ͓ͯ͘͠ͷʹ҆શͳॴʯ ― Webster ৽ੈքถޠࣙయɼΧϨοδ൛ ୈ3൛ ʮΩϟογϡͱௐΔඞཁͷ͋ΔͷΛஔ͍͓ͯ҆͘શͳॴͷ ͜ͱͰ͋ΔɽΩϟογϡͱ͍͏༻ޠɼ࠷ॳͷ༻ίϯϐϡʔλʹ ͓͍ͯɼϓϩηοαͱओهԱͱͷؒʹૠೖ͞ΕͨهԱ֊ϨϕϧΛ
දͨ͢Ίʹ༻͞Εͨɽ(தུ) ͜ͷ༻ޠࠓͰࢀরͷہॴੑΛ ར༻͢ΔΑ͏ʹཧ͞ΕͨҙͷهԱΛࢦͯ͠༻͞ΕΔʯ ― σΠϏου A ύλʔιϯ, δϣϯ ̡ ϔωγʔ ஶ, ా ޫজ ༁ ίϯϐϡʔλͷߏͱઃܭɼୈ5൛ [Լ] ❞ ❞ جຊతͳ֓೦ͱͯͦ͠ͷ௨Γ Ͱ͜Εϓϩηοαͷͩʂ
ࠓճ͞ͳ͍͜ͱ - WebΞϓϦέʔγϣϯҎ֎ͷΩϟογϡʹ͍ͭͯ - e.g - ϓϩηοαͷΩϟογϡ - DNSΩϟογϡʹ͍ͭͯࠓճ͠·ͤΜ -
ଞʹ৭ʑͳΛ͠·ͤΜ
WebΞϓϦέʔγϣϯʹ͓͚Δ Ωϟογϡͱͳʹ͔ʁ
WebΞϓϦέʔγϣϯʹ͓͚ΔΩϟογϡʁ αʔό͕ฦ͖͢ίϯςϯπʹ͍ͭͯ…… - 1࣍ετϨʔδΑΓߴͳετϨʔδʹ ஔ͓͍͔ͯͯͦ͜͠Βฦ͢ - ͘͠ฦ͞ͳ͍
WebΞϓϦέʔγϣϯʹ͓͚ΔΩϟογϡʁ ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ ߴͳετϨʔδܦ༝Ͱฦ͢ํ HTTPϨΠϠͰͷΩϟογϡ ϨεϙϯεΛฦ͞ͳ͍ํ
WebΞϓϦέʔγϣϯʹ͓͚ΔΩϟογϡʁ ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ ߴͳετϨʔδܦ༝Ͱฦ͢ํ HTTPϨΠϠͰͷΩϟογϡ ϨεϙϯεΛฦ͞ͳ͍ํ
ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ Server Client Primary Storage Heavy Component OR
ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ Server Client Primary Storage i ii iii iv i.
ϦΫΤετ ii. Ұ࣍ετϨʔδ͍߹Θͤ iii. ݁ՌΛฦ͢ iv. Ϩεϙϯε
ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ Server Client Primary Storage i ii iii iv i.
ϦΫΤετ ii. Ұ࣍ετϨʔδ͍߹Θͤ iii. ݁ՌΛฦ͢ iv. Ϩεϙϯε ͕͜͜ωοΫ ͷ߹
ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ Server Client Primary Storage ii iii Cache Storage
ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ Server Client Primary Storage i ii iii iv i.
ϦΫΤετ ii. Ωϟογϡ͍߹Θͤ iii. ݁ՌΛฦ͢ iv. Ϩεϙϯε Cache Storage ii iii
ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ Server Client Primary Storage i ii iii iv i.
ϦΫΤετ ii. Ωϟογϡ͍߹Θͤ iii. ݁ՌΛฦ͢ iv. Ϩεϙϯε Cache Storage ii iii Ұ࣍ετϨʔδΑΓ Ωϟγϡ͕ߴͳΒ ૣ͘ฦͤΔ
ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ Server Client Primary Storage ii iii Ұ࣍ετϨʔδͱ ΩϟογϡετϨʔδ ͳΜΒ͔༰ͷ߹Λ
औΔඞཁ͕͋Δ Cache Storage
WebΞϓϦέʔγϣϯʹ͓͚ΔΩϟογϡʁ ΞϓϦέʔγϣϯϨΠϠͰͷΩϟογϡ ߴͳετϨʔδܦ༝Ͱฦ͢ํ HTTPϨΠϠͰͷΩϟογϡ ϨεϙϯεΛฦ͞ͳ͍ํ
HTTPϨΠϠͰͷΩϟογϡ ΩϟογϡͱɺϦιʔεͷʹج͍ͮͯɺҰऔಘͨ͠Ϧιʔ εΛΫϥΠΞϯτଆͰ͍·Θ͢ํࣜͰ͢ɻ ΩϟογϡͷརɺαʔόͱΫϥΠΞϯτؒͷ௨৴ΛݮΒ͢͜ͱ ͰωοτϫʔΫଳҬͷར༻ॲཧ࣌ؒΛॖখ͠ɺΑΓޮతʹॲཧ Ͱ͖Δ͜ͱͰ͢ɻ ― ࢁຊ ཅฏ ஶ
WebΛࢧ͑Δٕज़ - HTTPɺURIɺHTMLɺͦͯ͠REST (WEB+DB PRESS plus) ❞
HTTPϨΠϠͰͷΩϟογϡ Server Client contents
HTTPϨΠϠͰͷΩϟογϡ Server Client i ii i. ίϯςϯπ͘Εʙ ii. ͍Αʙ contents
HTTPϨΠϠͰͷΩϟογϡ Server Client i ii i. ίϯςϯπ͘Εʙ ii. ͍Αʙ contents
ίϯςϯπ͕ωοτϫʔΫʹΔ (serverͷཪଆͰߋʹॏ͍ॲཧ͕͍ͬͯΔ͔) contents
HTTPϨΠϠͰͷΩϟογϡ Server Client contents contents ΫϥΠΞϯτଆͰίϯςϯπΛอ࣋
HTTPϨΠϠͰͷΩϟογϡ Server Client contents contents i ii i. ίϯςϯπ͘Εʙ ii.
͏࣋ͬͯ·͢Α
HTTPϨΠϠͰͷΩϟογϡ Server Client contents contents i ii i. ίϯςϯπ͘Εʙ ii.
͏࣋ͬͯ·͢Α ίϯςϯπωοτϫʔΫʹΒͳ͍ ʮ͏࣋ͬͯ·͢Αʯͱ͍͏ใ͕Δ
HTTPϨΠϠͰͷΩϟογϡ ͨͩ͠ɺݹ͍ΩϟογϡΛར༻ͯ͠͠·͍ɺใͷ৴པੑ͕Լ͕Δ Մೳੑ͋Γ·͢ɻ ― ࢁຊ ཅฏ ஶ WebΛࢧ͑Δٕज़ - HTTPɺURIɺHTMLɺͦͯ͠REST
(WEB+DB PRESS plus) ❞
ࠓճओʹΞϓϦέʔγϣϯϨΠϠͷ Ωϟογϡͷ͕ଟ͍Ͱ͢ (HTTPϨΠϠͷͰڞ௨͢Δ͋Γ·͢)
ͳͥΩϟογϡΛ͏ͷ͔ʁ
ͳͥΩϟογϡΛ͏ͷ͔ʁ ϦΫΤετΛߴʹฦ٫͢ΔͨΊ Ϣʔβମݧͷ্ ୯Ґ࣌ؒ͋ͨΓͷॲཧΛ૿Ճͤ͞ΔͨΊ ܭࢉػϦιʔεͷར༻ޮ্ঢ ɹɹRequest per secondͷ૿Ճ ಛఆίϯϙʔωϯτ (e.g.
RDBMS) ͷෛՙݮͷͨΊ γεςϜͷ҆ఆӡ༻ (͔͠͠߹ʹґΔ)
ͳͥΩϟογϡΛ͏ͷ͔ʁ ϦΫΤετΛߴʹฦ٫͢ΔͨΊ Ϣʔβମݧͷ্ ୯Ґ࣌ؒ͋ͨΓͷॲཧΛ૿Ճͤ͞ΔͨΊ ܭࢉػϦιʔεͷར༻ޮ্ঢ ɹɹRequest per secondͷ૿Ճ ಛఆίϯϙʔωϯτ (e.g.
RDBMS) ͷෛՙݮͷͨΊ γεςϜͷ҆ఆӡ༻ (͔͠͠߹ʹґΔ)
ϦΫΤετΛߴʹฦ٫͢Δ Server Client Cache Storage ߴʹฦ٫͢Δ͜ͱͰ ετϨε͕গͳ͘ͳΓ ϢʔβʔମݧΞοϓʂ ⚡⚡⚡
ͳͥΩϟογϡΛ͏ͷ͔ʁ ϦΫΤετΛߴʹฦ٫͢ΔͨΊ Ϣʔβମݧͷ্ ୯Ґ࣌ؒ͋ͨΓͷॲཧΛ૿Ճͤ͞ΔͨΊ ܭࢉػϦιʔεͷར༻ޮ্ঢ ɹɹRequest per secondͷ૿Ճ ಛఆίϯϙʔωϯτ (e.g.
RDBMS) ͷෛՙݮͷͨΊ γεςϜͷ҆ఆӡ༻ (͔͠͠߹ʹґΔ)
୯Ґ࣌ؒ͋ͨΓͷॲཧͷ૿Ճ Server Client Cache Storage ୯Ґ࣌ؒ͋ͨΓͷॲཧ ૿ՃʹΑΓҰʹ ͨ͘͞ΜͷϦΫΤετΛ ͚͞Δ Client
Client . . .
ͳͥΩϟογϡΛ͏ͷ͔ʁ ϦΫΤετΛߴʹฦ٫͢ΔͨΊ Ϣʔβମݧͷ্ ୯Ґ࣌ؒ͋ͨΓͷॲཧΛ૿Ճͤ͞ΔͨΊ ܭࢉػϦιʔεͷར༻ޮ্ঢ ɹɹRequest per secondͷ૿Ճ ಛఆίϯϙʔωϯτ (e.g.
RDBMS) ͷෛՙݮͷͨΊ γεςϜͷ҆ఆӡ༻ (͔͠͠߹ʹґΔ)
ಛఆίϯϙʔωϯτͷෛՙܰݮ Server Client Client . . . Storage (৭ʑͳࣄ͕͋Γ) ετϨʔδʹෛՙ͕ूத͍ͯ͠Δʂ
ಛఆίϯϙʔωϯτͷෛՙܰݮ Server Client Client . . . Storage Cache Storage
ಛఆίϯϙʔωϯτͷෛՙܰݮ Server Client Client . . . Storage Cache Storage
Ωϟογϡʹಀ͕ͯ͠ Δ͜ͱͰ աෛՙίϯϙʔωϯτͷ ෛՙΛܰݮ͢Δ
ಛఆίϯϙʔωϯτͷෛՙܰݮ Server Client Client . . . Storage Cache Storage
͔͠͠Ωϟογϡίϯϙʔωϯτ͕ ૿͑Δ͜ͱͰγεςϜͱͯ͠ͷ ނোՄೳੑ૿Ճ͢Δʂ
ͳͥΩϟογϡΛ͏ͷ͔ʁ ϦΫΤετΛߴʹฦ٫͢ΔͨΊ Ϣʔβମݧͷ্ ୯Ґ࣌ؒ͋ͨΓͷॲཧΛ૿Ճͤ͞ΔͨΊ ܭࢉػϦιʔεͷར༻ޮ্ঢ ɹɹRequest per secondͷ૿Ճ ಛఆίϯϙʔωϯτ (e.g.
RDBMS) ͷෛՙݮͷͨΊ γεςϜͷ҆ఆӡ༻ (͔͠͠߹ʹґΔ)
ͳͥΩϟογϡΛ͏ͷ͔ʁ ϦΫΤετΛߴʹฦ٫͢ΔͨΊ Ϣʔβମݧͷ্ ୯Ґ࣌ؒ͋ͨΓͷॲཧΛ૿Ճͤ͞ΔͨΊ ܭࢉػϦιʔεͷར༻ޮ্ঢ ɹɹRequest per secondͷ૿Ճ ಛఆίϯϙʔωϯτ (e.g.
RDBMS) ͷෛՙݮͷͨΊ γεςϜͷ҆ఆӡ༻ (͔͠͠߹ʹґΔ) ͭ·ΓΧωʂʂʂ
ͳͥΩϟογϡΛ͏ͷ͔ʁ ϦΫΤετΛߴʹฦ٫͢ΔͨΊ Ϣʔβମݧͷ্ ୯Ґ࣌ؒ͋ͨΓͷॲཧΛ૿Ճͤ͞ΔͨΊ ܭࢉػϦιʔεͷར༻ޮ্ঢ ɹɹRequest per secondͷ૿Ճ ಛఆίϯϙʔωϯτ (e.g.
RDBMS) ͷෛՙݮͷͨΊ γεςϜͷ҆ఆӡ༻ (͔͠͠߹ʹґΔ) ͭ·ΓΧωʂʂʂ
ͳͥΩϟογϡΛ͏ͷ͔ʁ ϦΫΤετΛߴʹฦ٫͢ΔͨΊ Ϣʔβମݧͷ্ ୯Ґ࣌ؒ͋ͨΓͷॲཧΛ૿Ճͤ͞ΔͨΊ ܭࢉػϦιʔεͷར༻ޮ্ঢ ɹɹRequest per secondͷ૿Ճ ಛఆίϯϙʔωϯτ (e.g.
RDBMS) ͷෛՙݮͷͨΊ γεςϜͷ҆ఆӡ༻ (͔͠͠߹ʹґΔ) ͭ·ΓΧωʂʂʂ Ωϟογϡ͔ʂʁ
͍
ΩϟογϡΛͲͷΑ͏ͳ࣌ʹ͏͔
ΩϟογϡΛͲͷΑ͏ͳ࣌ʹ͏͔ - Ͳ͏ͬͯΫΤϦ͕͍ (৭ʑͳ͜ͱ͕͋Δ) - ৭ʑͳཧ༝ͰৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ - ৭ʑ͋ͬͯ֎෦αʔϏεʹґଘ͍ͯ͠Δ - ͳͲͳͲ
ΩϟογϡΛͲͷΑ͏ͳ࣌ʹ͏͔ - Ͳ͏ͬͯΫΤϦ͕͍ (৭ʑͳ͜ͱ͕͋Δ) - ৭ʑͳཧ༝ͰৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ - ৭ʑ͋ͬͯ֎෦αʔϏεʹґଘ͍ͯ͠Δ - ͳͲͳͲ
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Slow Query
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Slow Query.
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Slow Query..
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Slow Query…
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Slow Query…
͜͜ͰαʔϏε͕٧·Δ (աෛՙͰDB͕μϯ͢Δ͔ʁ)
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Cache
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Cache Ωϟογϡʹಀ͕͢͜ͱͰ
ݱ࣮తͳ࣌ؒͰฦ͢ (ෛՙࢄͤ͞Δ)
ΩϟογϡΛͲͷΑ͏ͳ࣌ʹ͏͔ - Ͳ͏ͬͯΫΤϦ͕͍ (৭ʑͳ͜ͱ͕͋Δ) - ৭ʑͳཧ༝ͰৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ - ৭ʑ͋ͬͯ֎෦αʔϏεʹґଘ͍ͯ͠Δ - ͳͲͳͲ
ৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ Server . . . Storage Not slow request
ৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ Server . . . Storage Not slow request!!!!!!
ৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ Server . . . Storage Not slow request!!!!!! ܾ͍ͯ͠ϦΫΤετͰͳ͍͕
ϦΫΤετ͕ଟ͗ͯ͢ࡹ͖͖Εͳ͍
ৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ Server . . . Storage Cache
ৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ Server . . . Storage Cache ͬͱߴͳετϨʔδͰ ରԠͯ͠ͳΜͱ͔͢Δ (ྗ)
ৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ Server . . . Storage Cache
ৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ Server . . . Storage Cache ͦͦωοτϫʔΫͰ ٧·ΔՄೳੑ͕͋Δ
ৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ Server . . . Storage Cache HTTPϨΠϠͷΩϟογϡΛͬͯ ʮฦ͞ͳ͍ʯඞཁ͕͋Δ͔
ΩϟογϡΛͲͷΑ͏ͳ࣌ʹ͏͔ - Ͳ͏ͬͯΫΤϦ͕͍ (৭ʑͳ͜ͱ͕͋Δ) - ৭ʑͳཧ༝ͰৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ - ৭ʑ͋ͬͯ֎෦αʔϏεʹґଘ͍ͯ͠Δ - ͳͲͳͲ
֎෦αʔϏεʹґଘ͍ͯ͠Δ Server Client Client . . . Outer Service Request
(via HTTP)
֎෦αʔϏεʹґଘ͍ͯ͠Δ Server Client Client . . . Outer Service Request
(via HTTP) ֎෦αʔϏεʹϦΫΤετΛ ඈ͍͍ͯͯ͠
֎෦αʔϏεʹґଘ͍ͯ͠Δ Server Client Client . . . Outer Service Cache
֎෦αʔϏεʹґଘ͍ͯ͠Δ Server Client Client . . . Outer Service Cache
ΩϟογϡΛհ͢Δ͜ͱͰ ߴʹ݁ՌΛಘΔͱͱʹ ෆཁͳϦΫΤετΛݮ͢Δ
ΩϟογϡΛͲͷΑ͏ͳ࣌ʹ͏͔ - Ͳ͏ͬͯΫΤϦ͕͍ (৭ʑͳ͜ͱ͕͋Δ) - ৭ʑͳཧ༝ͰৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ - ৭ʑ͋ͬͯ֎෦αʔϏεʹґଘ͍ͯ͠Δ - ͳͲͳͲ
ΩϟογϡΛͲͷΑ͏ͳ࣌ʹ͏͔ - Ͳ͏ͬͯΫΤϦ͕͍ (৭ʑͳ͜ͱ͕͋Δ) - ৭ʑͳཧ༝ͰৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ - ৭ʑ͋ͬͯ֎෦αʔϏεʹґଘ͍ͯ͠Δ - ͳͲͳͲ
৭ʑͳ͜ͱ͕͋Δɼ৭ʑͳ͜ͱ͕……
ΩϟογϡΛͲͷΑ͏ͳ࣌ʹ͏͔ - Ͳ͏ͬͯΫΤϦ͕͍ (৭ʑͳ͜ͱ͕͋Δ) - ৭ʑͳཧ༝ͰৗيΛҳͨ͠ྔͷΞΫηε͕͋Δ - ৭ʑ͋ͬͯ֎෦αʔϏεʹґଘ͍ͯ͠Δ - ͳͲͳͲ
৭ʑͳ͜ͱ͕͋Δɼ৭ʑͳ͜ͱ͕…… ͔͠͠ຊʹΩϟογϡ͕ඞཁͳͷ͔ख़ߟ͖͢ɽޙड़
ΩϟογϡετϨʔδ
ΩϟογϡετϨʔδ֓؍ - memcached - memcachedϓϩτίϧΛΔؒ - Redis - BerkeleyDB -
mmap (!) - ΞϓϦͷϓϩηεʹ࣋ͭ - ͳͲͳͲ
ͦͷଞͷΩϟογϡϛυϧΣΞ
ΩϟογϡϛυϧΣΞ֓؍ - Squid - Varnish - ͳͲͳͲ
ΩϟογϡϛυϧΣΞ֓؍ - Squid - Varnish - ͳͲͳͲ HTTPϨΠϠͰͷΩϟογϡΛओʹߦ͏ܥ
ϛυϧΣΞબఆͷ ࣌ؒ༨ͬͨΒΓ·͢
Ωϟογϡઓུ
Ωϟογϡઓུ
Ωϟογϡઓུ ͱʹ͔͘ߴʹฦ͢
Ωϟογϡઓུ ͱʹ͔͘ߴʹฦ͢ ߴʹฦ[ͤ͞]ͳ͍Ωϟογϡແҙຯ
Ωϟογϡઓུ ΞϓϦΛյ͞ͳ͍
Ωϟογϡઓུ ΞϓϦΛյ͞ͳ͍ ΞϓϦΛͿͬյ͢Ωϟογϡແҙຯ
Ωϟογϡઓུ - ߴʹฦ͢ - ΞϓϦΛͿͬյ͞ͳ͍ - ґଘίϯϙʔωϯτΛগͳ͘อͭ - লϝϞϦ -
Ωϟογϡ͕ͿͬյΕͯٽ͔ͳ͍ - (ͳΔۚ͘Λ͔͚ͳ͍)
Ωϟογϡઓུ - ߴʹฦ͢ - ΞϓϦΛͿͬյ͞ͳ͍ - ґଘίϯϙʔωϯτΛগͳ͘อͭ - লϝϞϦ -
Ωϟογϡ͕ͿͬյΕͯٽ͔ͳ͍ - (ͳΔۚ͘Λ͔͚ͳ͍)
ґଘίϯϙʔωϯτΛগͳ͘อͭ - ґଘίϯϙʔωϯτ͕૿͑Δ = ো͕૿͑Δ - োগͳ͍ํ͕ྑ͍ - ҆қʹϛυϧΣΞΛ૿͞ͳ͍ -
ʮͬͯΈ͔͔ͨͬͨΒʯΛؾܰʹΔͱ ͲΜͲΜट͕క·Δ
Ωϟογϡઓུ - ߴʹฦ͢ - ΞϓϦΛͿͬյ͞ͳ͍ - ґଘίϯϙʔωϯτΛগͳ͘อͭ - লϝϞϦ -
Ωϟογϡ͕ͿͬյΕͯٽ͔ͳ͍ - (ͳΔۚ͘Λ͔͚ͳ͍)
লϝϞϦ - ϝϞϦΛϞϦϞϦ৯͏ઃܭΛආ͚Δ - ࠷ॳྑ͍͔͠Εͳ͍͕͋Δಥવ ো͕ى͖ͨΓ͢Δ - (ࢹ͠Ζͱ͍͏Ͱ͋Δ͕……) - جຊతʹΩϟογϡ͢ΔΞΠςϜʹ
ExpireΛ͚Δ (= ӬଓతʹσʔλΛ࣋ͨͳ͍)
Ωϟογϡઓུ - ߴʹฦ͢ - ΞϓϦΛͿͬյ͞ͳ͍ - ґଘίϯϙʔωϯτΛগͳ͘อͭ - লϝϞϦ -
Ωϟογϡ͕ͿͬյΕͯٽ͔ͳ͍ - (ͳΔۚ͘Λ͔͚ͳ͍)
Ωϟογϡ͕ͿͬյΕͯٽ͔ͳ͍ - ΩϟογϡյΕΔͷͱͯ͠ӡ༻ͨ͠΄͏͕ͤ - Ωϟογϡ͕ͿͬյΕͨΒ·ͨ࡞Εྑ͍ - Let it crash -
ͨͩɼͿͬյΕͨλΠϛϯάͰٸܹʹෛՙ্͕͕Δ Α͏ͳঢ়گʹ͚ͩͳΒͳ͍Α͏͖͢
Ωϟογϡઓུ - ߴʹฦ͢ - ΞϓϦΛͿͬյ͞ͳ͍ - ґଘίϯϙʔωϯτΛগͳ͘อͭ - লϝϞϦ -
Ωϟογϡ͕ͿͬյΕͯٽ͔ͳ͍ - (ͳΔۚ͘Λ͔͚ͳ͍)
ͳΔۚ͘Λ͔͚ͳ͍ - ͍
Ωϟογϡύλʔϯ
ύλʔϯʁ ʮͦΕͧΕͷύλʔϯզʑͷͷ·ΘΓͰԿճى͖Δɺ͓ ΑͼɺͦΕͧΕͷʹର͢Δղ๏ͷϙΠϯτΛهड़͍ͯ͠Δɻͦ ͜Ͱզʑɺ͜ΕΒͷղ๏ΛԿສճͰ͏͜ͱ͕Ͱ͖Δɻಉ͡ ʹର͢Δಉ͡ղ๏ΛԿԿ࠷ॳ͔Βߟ͑ͣ͞ʹࡁΉͱ͍ ͏Θ͚ͩʯ ― Erich Gamma, Richard
Helm, Ralph Johnson, John Vlissides ஶ, ຊҐా ਅҰ, ٢ాथ ༁ σβΠϯύλʔϯɼվగ൛ ❞
ύλʔϯԽ͢Δརͱ ʮύλʔϯʹ໊લΛ͚Δ͜ͱͰɺઃܭͷ͓͚Δ༻ޠͷޠኮΛ૿ ͢͜ͱʹͳΔɻͦΕʹΑͬͯߴ͍நϨϕϧͰઃܭ͢Δ͜ͱ͕Մೳ ͱͳΔɻύλʔϯʹؔ͢Δޠኮ͕૿͑Εɺಉ྅ͱٞͨ͠Γɺจ ॻʹهͨ͠ΓɺࣗࣗͰߟ͑Λཧ͢Δͷʹཱͭɻઃܭʹ ؔͯ͠ݕ౼ͨ͠Γɺઃܭ্ͷτϨʔυΦϑΛਓʹ͑Δ͜ͱ༰қ ʹͳΔʯ ― Erich Gamma,
Richard Helm, Ralph Johnson, John Vlissides ஶ, ຊҐా ਅҰ, ٢ాथ ༁ σβΠϯύλʔϯɼվగ൛ ❞
ύλʔϯԽ͢Δརͱ ʮҰ໊લΛݺͿ͜ͱ͕Ͱ͖Εɺ͋ͳͨͦΕΛҙࣝ͠ɺͦΕΛ ࢧ͠ɺͦΕΛॴ༗͠ɺͦΕΛίϯτϩʔϧͰ͖ΔΑ͏ʹͳΔͷͰ ͢ʯ ― Robin Williams ஶ, ٢యल ༁ɹ
ϊϯσβΠφʔζɾσβΠϯϒοΫ ❞
Ωϟογϡͷύλʔϯ - Ωϟογϡʹ͍ͭͯͷύλʔϯɼΈ͍ͨͳΛ͋·Γ ฉ͔ͳ͍ - ݁Ռͱͯ͠ʮ✕✕✕͕˓˓˓Ͱ˚˚˚ʹͳΔͭͰ͢ʯ Έ͍ͨͳৄࡉͳจষͰίϛϡχέʔγϣϯ͢Δ͜ͱ ʹͳΔ => ͨΔ͍
Ωϟογϡͷύλʔϯ - ͱ͍͏Θ͚ͰύλʔϯͰ͢ʂʂ - উखʹ໊͚ͨલͳΜͰ͏طʹผͷ໊લ͕͋Δ͔
(ݸਓతʹ) Α͘͏ ύλʔϯΛ͝հʂ
Brokerύλʔϯ - Ωϟογϡʹ͋ͬͨΒΩϟογϡ͔Βฦ͢ - Ωϟογϡʹແ͔ͬͨΒҰ࣍ετϨʔδʹ͍߹Θ ͤͯͦͷ݁ՌΛฦͭͭ͠ΩϟογϡʹೖΕΔ ϦΫΤετͯ͠…… ϦϙδτϦύλʔϯͷѥछͱݴ͑ͦ͏
Server Client Primary Storage ii iii Cache Storage Brokerύλʔϯ i
ii iii iv i. ϦΫΤετ ii. Ωϟογϡ͍߹Θͤ iii. ώοτͨ͠ͷͰ݁ՌΛฦ͢ iv. Ϩεϙϯε
Server Client Primary Storage ii iii Cache Storage Brokerύλʔϯ i
ii iii iv v vi i. ϦΫΤετ ii. Ωϟογϡ͍߹Θͤ iii. Ωϟογϡʹແ͍ͷͰ Ұ࣍ετϨʔδ͍߹Θͤ iv. ݁ՌΛΩϟογϡʹೖΕΔ v. ݁ՌΛฦ͢ vi. Ϩεϙϯε
Brokerύλʔϯ Pros - ΞΫηεසͷߴ͍ίϯςϯπΩϟογϡʹΓ ͍ίϯςϯπΩϟογϡʹΒͳ͍ লϝϞϦ - σʔλͷ߹ੑΛอ͍ͪ͢ (Ωϟογϡ͕৽) Cons
- ࠷ॳʹίϯςϯπʹདྷͨਓ͕ॏ͘ͳΔ - Ωϟογϡʹ͍ͬͯͳ͍࣌ʹେྔʹΞΫηε͕དྷΔͱ ෳͷϦΫΤετ͕Ұ࣍ετϨʔδʹૹΒΕΔ Cache Thundering Herd (ޙड़)
Inventoryύλʔϯ - Ωϟογϡʹ͋ͬͨΒΩϟογϡ͔Βฦ͢ - Ωϟογϡʹແ͔ͬͨΒσϑΥϧτΛฦͭͭ͠ɼ ඇಉظͰҰ࣍ετϨʔδ͔ΒΛऔ͖ͬͯͯ Ωϟογϡ͢ΔΑ͏ʹ͢Δ ϦΫΤετͯ͠……
Inventoryύλʔϯ Server Client Primary Storage ii iii Cache Storage i
ii iii iv i. ϦΫΤετ ii. Ωϟογϡ͍߹Θͤ iii. ώοτͨ͠ͷͰ݁ՌΛฦ͢ iv. Ϩεϙϯε
Inventoryύλʔϯ Server Client Primary Storage ii iii Cache Storage i
ii iii iv i. ϦΫΤετ ii. Ωϟογϡ͍߹Θͤ iii. Ωϟογϡʹແ͍ iv. σϑΥϧτΛฦ͢ (ඇಉظͰ) iv’. Ұ࣍ετϨʔδ͍߹Θͤ v’. ݁ՌΛΩϟογϡ iv’ v’
Inventoryύλʔϯ Pros - Brokerύλʔϯͱ΄΅ಉ͡Pros͕͋Δ - ࠷ॳʹίϯςϯπʹདྷͨਓʹରͯ͠ϨεϙϯελΠϜ͕ѱԽ ͠ͳ͍ Cons - ࠷ॳʹίϯςϯπʹདྷͨਓ͕ਖ਼͍͠ίϯςϯπΛऔΕͳ͍
- σϑΥϧτͷϋϯυϦϯάΛͲ͏͢Δ͔ - Cache Thundering Herd ʹ͍ͭͯղܾ͍ͯ͠ͳ͍
Warmerύλʔϯ - ͦͷίϯςϯπΛΩϟογϡʹͤΔ - ΫϥΠΞϯτͦͷΩϟογϡΛࢀর͢Δ ίϯςϯπੜ࣌ʹ…… ϥϯΩϯάͱ͔ʹ͑Δ
Warmerύλʔϯ Server Client Cache Storage i ii iii iv contents
contents v i. ίϯςϯπੜ࣌ʹ ίϯςϯπΛΩϟογϡ ii. ϦΫΤετ iii. Ωϟογϡ͍߹Θͤ iv. ίϯςϯπฦ͢ v. Ϩεϙϯε
Warmerύλʔϯ Pros - ࠷ॳ͔ΒΩϟογϡܦ༝ͰίϯςϯπΛฦͤΔ - Cache Thundering Herd ͷҰղܾ Cons
- ίϯςϯπ͕ੜ͞ΕΔܥ͡Όͳ͍ͱ͑ͳ͍ - ϥΠϑαΠΫϧͷཧ͕ࡶʹͳΔ (ಉظͱ͔) - ϝϞϦΊͬͪΌ৯͏߹͕͋Δ - Ωϟογϡ͕شൃͨ࣌͠ʹͲ͏͢Δͷ͔ʁ
Pool & Flushύλʔϯ POSTϦΫΤετܥʹ͏ɽ ϦΫΤετ͕དྷͨ࣌ʹΩϟογϡʹͦͷ༰ΛཷΊɼ ͋ΔλΠϛϯάͰӬଓετϨʔδʹॻ͖ग़͢
Pool & Flushύλʔϯ Server Client Primary Storage ii iii Cache
Storage i ii iii i. ϦΫΤετ ii. ΩϟογϡʹཷΊΔ iii. Ϩεϙϯε (͋ΔλΠϛϯάͰ) x. ӬଓετϨʔδʹॻ͖ग़͠ x
Pool & Flushύλʔϯ Pros - ߴʹߋ৽ܥΛॲཧͰ͖Δ Cons - ϓʔϧ͕ͿͬյΕͨ࣌ʹσʔλ͕ফ໓͢Δ -
σʔλͷҰ؏ੑΛอͭ࿑ྗ͕͔͔Δ
ΫϥΠΞϯταΠυΩϟογϡ
HTTP HeaderΛ༻͍ͨΩϟογϡ Server Client i ii i. ϦΫΤετ ii. ϔομ͚ͯฦ͢
- Expires - Cache-Control - Last-Modified - ETag contents
HTTP HeaderΛ༻͍ͨΩϟογϡ Server Client i ii i. ݅ͷϔομ͚ͯ ϦΫΤετ -
If-Modified-Since - If-None-Match ii. ݅ʹैͬͯฦ͢ contents contents
HTTP HeaderΛ༻͍ͨΩϟογϡ Server Client i ii i. ݅ͷϔομ͚ͯ ϦΫΤετ -
If-Modified-Since - If-None-Match ii. ݅ʹैͬͯฦ͢ contents contents ແବʹίϯςϯπΛฦ͢ඞཁ͕ແ͘ͳΔ
ϩʔΧϧͷڥͰ݁ͤ͞Δ - ΩϟογϡͲ͜ΖͰͳ͍ - ྫ: - ӾཡཤྺΛΫϥΠΞϯτͰ࣋ͬͯΒ͏ - λΠϜϥΠϯ࣮ΛΫϥΠΞϯτͷετϨʔδʹ ࣋ͬͯΒ͏
αʔό͔Βฦ͞ͳ͍ͷ͕ ݁ہ͍ͪΜʂʂʂ
Ωϟογϡʹ·ͭΘΔॾ
Cache Thundering Herd ௨ৗɺΩϟογϡʹ֨ೲ͞ΕΔσʔλɺͦΕͧΕ୯Ұͷੜଘ࣌ؒ Λ͍ͬͯ·͢ɻɺසൟʹΞΫηε͞ΕΔΩϟογϡσʔλ ͕ΤΫεύΠΞͨ͠ࡍʹൃੜ͠·͢ɻσʔλ͕ΤΫεύΠϠͨ͠ॠؒ ͔ΒɺฒߦʹΔෳͷΞϓϦέʔγϣϯϩδοΫ͕ϛεώοτΛ ݕ͠ɺ͍ͣΕ͔ͷϓϩηε͕ΩϟογϡσʔλΛ֨ೲ͢Δ·Ͱͷ ؒɺಉҰͷϦΫΤετ͕ଟɺόοΫΤϯυʹඈΜͰ͠·͏ͷͰ͢ɻ ―ΩϟογϡγεςϜͷ
Thundering Herd (Kazuho@Cybozu Labs) http://labs.cybozu.co.jp/blog/kazuho/archives/2007/09/cache_and_thundering_herd.php ❞
Cache Thundering Herd - ΤϯτϦ͝ͱʹExpireͷपظΛόϥ͢ͱ͔ - ಉҰ༰ͷΤϯτϦΛ2ॏʹ༻ҙ͓͍ͯͯ͠ɼ ͲͪΒ͔ҰํΛૣ͘ (͘͘͠) Expireͤ͞Δͱ͔
ͦ͏͍͏ରࡦɾ͕ඞཁͱͳΔ
ಉظ Ωϟογϡͷ༰ͱӬଓετϨʔδͷ༰ͷ ಉظͲ͏͢ΔΜ͡Ό
ಉظ - ΞϓϦέʔγϣϯجຊతʹӬଓετϨʔδʹର ͯ͠ߋ৽ΛՃ͍͑ͯ͘ Ωϟογϡ࣮ݹ͍ίϯςϯπ͔ - ͪΌΜͱ༰Λಉظͤ͞Α͏ͱ͢Δͱେม - Ωϟογϡ͕ਧ͖ඈͿͱӬଓԽ͞Εͳ͍ɼ ͳΜ͍ͯ͏͋Γ͑Δ
ಉظ ORMΛͬͯDBͱΩϟογϡΛಁաతʹѻ͏ͱ͍͏ ख๏͕͋Δʹ͋Δ͕ࠈײ
ಉظ ࣃΛ৯͍ͬͯ͠Δ͔͠ͳ͍ͷ͔……
ෆ۩߹ى͖ͨͱ͖ͷσόοά͕͠ʹ͍͘ ʮ͋Εɼ͜ΕΩϟογϡͨͬͯΔΜͰ͔͢ʯ ʮ͍ɼDB͔Βऔ͖ͬͯͯΔΜ͡Όͳ͍ʯ ʮͳΜ͔͕ͣΕͯΔΜͰ͢ΑͶʯ ʮΤοɼ͜ΕͲ͏ͳͬͯΜͩʁʯ
ෆ۩߹ى͖ͨͱ͖ͷσόοά͕͠ʹ͍͘ ʮ͋Εɼ͜ΕΩϟογϡͨͬͯΔΜͰ͔͢ʯ ʮ͍ɼDB͔Βऔ͖ͬͯͯΔΜ͡Όͳ͍ʯ ʮͳΜ͔͕ͣΕͯΔΜͰ͢ΑͶʯ ʮΤοɼ͜ΕͲ͏ͳͬͯΜͩʁʯ ͋Γ͕ͪʂʂʂʂʂʂ
ෆ۩߹ى͖ͨͱ͖ͷσόοά͕͠ʹ͍͘ ͜Ε͔ͬΓΔ͔͠ͳ͍……
ෆ۩߹ى͖ͨͱ͖ͷσόοά͕͠ʹ͍͘ օ͞ΜͦΕͧΕͷmemcachedͷҝͷπʔϧ RedisͷҝͷπʔϧΛ͍࣋ͬͯΔ͜ͱͰ͠ΐ͏ (͋Δ͍ϓϩτίϧΛΕΔΑ͏ʹਐԽ͢Δ)
ෆ۩߹ى͖ͨͱ͖ͷσόοά͕͠ʹ͍͘ ͋ͱϩάΛϞϦϞϦࠐΉΈ͍ͨͳ ݹࣜΏ͔͍͠ख๏ (ຯ͕ͩޮ͘)
ΩϟογϡϛυϧΣΞ૿͑Δ ΩϟογϡͷҝʹϛυϧΣΞ͕૿͑Δ ୯७ʹোཁҼ͕૿͑Δʂʂʂʂʂ
ΩϟογϡϛυϧΣΞ૿͑Δ γεςϜΛ҆ఆͤ͞ΔͨΊʹಋೖͨ͠ ΩϟογϡϛυϧΣΞ͕ෆ҆ఆͳ͔Γʹ ҎલΑΓՔಇ͕Լ͕ͬͯ͠·͏ͱ͍͏ࠈ
ΩϟογϡϛυϧΣΞ૿͑Δ - ΈͩΓʹϛυϧΣΞΛ૿͞ͳ͍ํͰؤுΔ - طଘͷίϯϙʔωϯτͰ༻͕Ͱ͖Δ͔ʁ
Ͳ͏͍͏࣌ʹΩϟογϡΛΘͳ͍͖͔
σʔλ͕ফ͑Δͱக໋తͳ߹ - σʔλ͕ڏۭʹফ͑ΔͱഛঈʂʂɹΈ͍ͨͳ ͱ͜Ζʹ͏͖Ͱͳ͍ - Ωϟογϡͷσʔλফ͑Δͷͱߟ͑Δ
σʔλ͕ফ͑Δͱக໋తͳ߹ - σʔλ͕ڏۭʹফ͑ΔͱഛঈʂʂɹΈ͍ͨͳ ͱ͜Ζʹ͏͖Ͱͳ͍ - Ωϟογϡͷσʔλফ͑Δͷͱߟ͑Δ ͔͠͠αʔϏεӡ༻্ফ͑ͯྑ͍σʔλ ͳΜͯ΄ͱΜͲͳ͍ͧʂʂʂ
ΩϟογϡΛ࠶ߏஙग़དྷͳ͍߹ - ΩϟογϡͷσʔλͿͬյΕͯ࠶ߏங Ͱ͖Εͳ͍ - όονͰDB͔ΒΩϟογϡ࠶ੜͱ͔Ͱ - ٯʹݴ͏ͱΩϟογϡΛ࠶ߏஙͰ͖ͳ͍߹ ͏͖Ͱͳ͍
ଞʹ৭ʑ͋Δ…… ݁ߏΩϟογϡΛ͏͖Ͱͳ͍Օॴ ۙʹᷓΕ͍ͯΔ
Ωϟογϡຑༀ
Ωϟογϡʹ·ͭΘΔॾΛ͏͚ͯ ΩϟογϡϚδَ
ҰΩϟογϡΛ͏ͱΕͳ͘ͳΔ - ҆қͳؾ࣋ͪͰΩϟογϡΛ͏ͱ ͦͷ෦͕͏͔ͬΓ͘ͳͬͯ͠·͏ - ଞͷ෦Ͱͦͷߴ͞ΛٻΊΒΕΔ ͠ΐ͏͕ͳ͍ͷͰΩϟογϡ͍·͔͢…… - Α͏ͦ͜Ωϟογϡপ
ҰΩϟογϡΛ͏ͱΕͳ͘ͳΔ - Ωϟογϡجຊతʹෳࡶͳػߏ - ೖΕΔͷ؆୯ɼൈ͘ͷ͕͍͠ - ΩϟογϡͱҰੜ͖߹͍֮ͬͯ͘ޛ͕͋Δ͔
Ωϟογϡͷڪාʂʂʂ ʮͳΜ͔͜ͷ෦͍ͬ͢Ͷ͑ʯ ʮDB٧·ͬͯΜ͡ΌΜʁɹΩϟογϡ͠Α͏ͥʯ ʮOKOKʯ
Ωϟογϡͷڪාʂʂʂ ʮͳΜ͔͜ͷ෦͍ͬ͢Ͷ͑ʯ ʮDB٧·ͬͯΜ͡ΌΜʁɹΩϟογϡ͠Α͏ͥʯ ʮOKOKʯ OKͰͳ͍ʂʂʂʂʂ
Ωϟογϡͷڪාʂʂʂ ͍ʂ ෲཱͭʂʂ Ωϟογϡ͢Δʂʂʂ
҆қͳΩϟογϡΛ ΊΖʂʂʂʂ
ͪΌΜͱઃܭΛ͢Δ
ͪΌΜͱઃܭΛ͢Δ - ͪΌΜͱDB (σʔλϞσϧ) ͷઃܭΛ͢Δ - ΠϯσοΫεͱؚ͔Ίͯ - มͳΞʔΩςΫνϟΛΊΔ -
ϘτϧωοΫʹͳΓ͕ͪ - ʮͨΓલͷ͜ͱΛͨΓલʹΔʯ
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Slow Query
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Slow Query
ΫΤϦ (͋Δ͍ςʔϒϧ)Λͤʂʂʂ దʹνϡʔχϯά͞ΕͨΫΤϦʹ ΩϟογϡͳͲෆཁ
Ͳ͏ͬͯΫΤϦ͕͍ Server Client Client . . . RDBMS Slow Query
Slave Slave ΩϟογϡʹཔΒͣ SlaveΛฒΔΑ͠
֎෦αʔϏεʹґଘ͍ͯ͠Δ Server Client Client . . . Outer Service Request
(via HTTP)
֎෦αʔϏεʹґଘ͍ͯ͠Δ Server Client Client . . . Outer Service Request
(via HTTP) ֎෦αʔϏεʹґଘ͠ͳ͍ ํ๏Λߟ͑Δ
ͪΌΜͱଌఆΛ͢Δ
ͪΌΜͱଌఆΛ͢Δ - ΩϟογϡΛ༻͍Δ͜ͱͰຊʹޮ͍͍ͯΔͷ͔ - ෛՙ͕Լ͕͍ͬͯΔʁ - ϨεϙϯελΠϜ͕վળ͍ͯ͠Δʁ - αʔϏεͷՄ༻ੑ্͕ঢ͍ͯ͠Δʁ
ͪΌΜͱଌఆΛ͢Δ - ΩϟογϡΛ༻͍Δ͜ͱͰຊʹޮ͍͍ͯΔͷ͔ - ෛՙ͕Լ͕͍ͬͯΔʁ - ϨεϙϯελΠϜ͕վળ͍ͯ͠Δʁ - αʔϏεͷՄ༻ੑ্͕ঢ͍ͯ͠Δʁ ΩϟογϡΛೖΕ͚ͨͩͰ
تΜͰ͍ͯବ
ͪΌΜͱଌఆΛ͢Δ - ΩϟογϡΛ༻͍Δ͜ͱͰຊʹޮ͍͍ͯΔͷ͔ - େͯ͠ޮ͔͵ΩϟογϡͳΒೖΕΔ͚ͩෛ࠴
Ωϟογϡຑༀ Ωϟογϡ࠷ऴฌث
ຊʹඞཁͳ࣌ʹ͚ͩ ΩϟογϡΛ͍·͠ΐ͏
Θͳͯ͘ࡁΉͷͳΒ ΩϟογϡΛΊΑ͏ʂʂ
Q?
͕࣌ؒ͋Εͷίʔφʔ
VarnishͷΛ͍ͯ͠·ͤΜͶʁ
VarnishͷΛ͍ͯ͠·ͤΜͶʁ - ͢Έ·ͤΜαʔϏεͰͬͨ͜ͱͳ͍ͷͰ ҰΕ·ͤΜ - ༗ӹͳΠϯλʔωοτ্ʹͨ͘͞Μ ࢿྉ͕͋Γ·͢ (YAPC 2011ͷmala͞ΜͷࢿྉͳͲ) -
ΠϯλʔωοτʹͳΜͰ͋Δ
ΩϟογϡετϨʔδબఆ
ΩϟογϡετϨʔδબఆ - ༻్ - ࢄ͢Δඞཁ͕͋Δ͔ - Խ͢Δඞཁ͕͋Δ͔ - ͬͯΔΫϥυϓϥοτϑΥʔϜͰαϙʔτ ͍ͯ͠Δ͔Ͳ͏͔
- ετϨʔδʹৄ͍͠ਓ͕͍Εྑ͍
ΩϟογϡετϨʔδબఆ
ΩϟογϡετϨʔδͷ Խߏʹ͍ͭͯ
Խ - Redisͩͱsentinelͱ͔clusterͱ͔ - memdͷ߹ܥΛෳ༻ҙ͢Δͱ͔ - ࣗͰϧʔςΟϯάΛॻ͘ඞཁ͕͋Δ - ͍҃mcrouterͳͲ…… -
ຊʹԽ͕ඞཁͳͷ͔Ͳ͏͔Λߟ͑Δ ඞཁ͋Δ