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
フルCDNアーキテクチャでサービス設計した話
Search
Atsushi Takayama
September 22, 2018
Technology
4.1k
5
Share
フルCDNアーキテクチャでサービス設計した話
FUKUOKA Engineers Day 2018 ~Autumn~ で話した内容です。
Atsushi Takayama
September 22, 2018
More Decks by Atsushi Takayama
See All by Atsushi Takayama
最高の開発者体験の追求が開発生産性を改善し続ける文化を生み出した話
edvakf
3
1.6k
NeurIPS 2021 論文読み会: How Modular should Neural Module Networks Be for Systematic Generalization?
edvakf
0
220
8年物のJavaのシステムをKotlinに変えていく選択に至るまで
edvakf
2
1.1k
ピクシブ社内のImageFlux利用事例紹介
edvakf
2
3k
学びの文化を育む社内読書会のススメ
edvakf
0
320
Goでバイナリを読む+α
edvakf
1
1k
お前はこれまでに作ったAPIの数を覚えているのか?
edvakf
0
2.7k
「ふつうのRailsアプリケーション」についての考え方
edvakf
2
940
ggplot.galleryというお遊びウェブアプリケーションを作った話
edvakf
0
430
Other Decks in Technology
See All in Technology
AI飲み会幹事エージェントを作っただけなのに
ykimi
0
240
AsyncStreamでマルチブロードキャストを実装する
1mash0
1
170
なぜ、IAMロールのプリンシパルに*による部分マッチングが使えないのか? / 20260518-ssmjp-iam-role-principal
opelab
2
140
AI-Assisted Contributions and Maintainer Load - PyCon US 2026
pauloxnet
1
180
【関西製造業祭り2026春】現場を変える技術はここまで来た〜世界最大の製造業見本市から持って帰ってきたもの〜
tanakaseiya
0
190
Cortex(Code) を ML モデルの 精度改善サイクルに組み込む.pdf
oimo23
0
230
LookerとADKで作る社内AIエージェント
chanyou0311
0
270
GitHub Copilot CLI で考える複数エージェント設計
tomokusaba
0
130
Loadbalancing exporter internals
ymotongpoo
1
110
2026-05-14 要件定義からソース管理まで!IBM Bob基礎ハンズオン
yutanonaka
0
170
TypeScriptはどのようにどこまで推論できるのか ─ とにかく as は禁止で
ypresto
0
180
React Compiler導入から21ヶ月、いま始めるならこうやる
astatsuya
2
270
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
530
How to train your dragon (web standard)
notwaldorf
97
6.6k
BBQ
matthewcrist
89
10k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
New Earth Scene 8
popppiees
3
2.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
560
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
420
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Transcript
ϑϧCDNΞʔΩςΫνϟͰ αʔϏεઃܭͨ͠ Fukuoka Engineers Day pixiv.inc Atsushi
Takayama
• ߴࢁ / @edvakf • ϐΫγϒגࣜձࣾCTO ݉ ԬΦϑΟεϚωʔδϟʔ
• JavaScript, Ruby, Go, Scala
ʮϑϧCDNΞʔΩςΫνϟʯ
ʮϑϧCDNΞʔΩςΫνϟʯ
͜Ε͕2016
― 1ޙ ―
dev.to͕ʹ
• Service Worker • CDN
• Service Worker • CDN
ࠓճͷߏ
• iOS: Swift • Web (PWA): Ionic 3,
TypeScript, Firebase • API: Rails, Heroku, CloudFront
chatstory.pixiv.net
• ϑϩϯτΤϯυFirebaseʹϗετ͍ͯ͠ΔͷͰɺ FirebaseʹσϑΥϧτͰ͍͍ͭͯΔCDNΛ׆༻ • firebase.jsonͰCache-ControlLinkϔομʔΛઃఆ
ͯͯ͞͞
ΩϟογϡΛߟ͑Δ্Ͱେࣄͳ͜ͱ
• ͦͦΩϟογϡ͢Δඞཁ͕͋Δͷ͔ • Ωϟογϡͷ༗ޮظݶ • Ωϟογϡͷআ • Ωϟογϡ͍͚ͯ͠ͳ͍ͷΛΩϟογϡ͠ͳ͍
• ͦͦΩϟογϡ͢Δඞཁ͕͋Δͷ͔ • Ωϟογϡͷ༗ޮظݶ • Ωϟογϡͷআ • Ωϟογϡ͍͚ͯ͠ͳ͍ͷΛΩϟογϡ͠ͳ͍
• ΩϟογϡҰೖΕͨΒ֎͢ͷ͔ͳΓ͍͠ • Ωϟογϡ͢Δͱ͍͏͜ͱෳࡶ͞Λ૿͢͜ͱ • →ύϑΥʔϚϯε͕ʹͳΔՕॴ͚ͩΩϟογϡ
HerokuΛCDNͰΩϟογϡ
• Heroku͕ԕ͗͢Δ • ϥϯυτϦοϓ͚ͩͰ100ms • ϖʔδͷදࣔʹΫϦςΟΧϧͳϦΫΤετ CDNͰϢʔβʔͷۙ͘ʹΩϟογϡ͍ͨ͠
• ͦͦΩϟογϡ͢Δඞཁ͕͋Δͷ͔ • Ωϟογϡͷ༗ޮظݶ • Ωϟογϡͷআ • Ωϟογϡ͍͚ͯ͠ͳ͍ͷΛΩϟογϡ͠ͳ͍
CDNΩϟογϡͷ༗ޮظݶ
Cache-Control: public, max-age=0, s-maxage=3600 public => CDNͰΩϟογϡͯ͠ྑ͍ max-age
=> ΫϥΠΞϯτʢϒϥβʣͰΩϟογϡͯ͠ྑ͍ظؒ s-maxage => ϓϩΩγʢCDNʣͰΩϟογϡͯ͠ྑ͍ظؒ Cache-Controlϔομʔ
• ͦͦΩϟογϡ͢Δඞཁ͕͋Δͷ͔ • Ωϟογϡͷ༗ޮظݶ • Ωϟογϡͷআ • Ωϟογϡ͍͚ͯ͠ͳ͍ͷΛΩϟογϡ͠ͳ͍
CloudFrontͷΩϟογϡআ
• API͕͋ΔʢͪΖΜʣ • URLલํҰகͰࢦఆ • ैདྷ10ʙ15͔͔͍ͬͯͨͦ͏͕ͩɺ 2017͔Βશମͷ90%ʹ5ඵɺ࠷େͰ1 •
Fastlyͩͱ150msʢʂʣ
• ߋ৽ܥͷΞΫγϣϯͰΩϟογϡΛআ • ࠣࡉͳߋ৽͑ͯແࢹ
• ͦͦΩϟογϡ͢Δඞཁ͕͋Δͷ͔ • Ωϟογϡͷ༗ޮظݶ • Ωϟογϡͷআ • Ωϟογϡ͍͚ͯ͠ͳ͍ͷΛΩϟογϡ͠ͳ͍
Ωϟογϡࣄނࢭ
• CookieUser-AgentIPΞυϨεɺݸผͷϦΫΤε τʹґଘ͢ΔσʔλΩϟογϡ͠ͳ͍ • ͜͜ΛޡΔࣄނҙ֎ͱଟ্͍ʹɺϓϥΠόγʔ໘ ͰେʹͳΔ͜ͱ͕͋Δ • ཧతʹΩϟογϡΑΓޙΖͰrequestΦϒ
δΣΫτʹ৮Εͳ͘͢Δ ʢݱ࣮తʹ͜ΕͰμϝͳέʔε͋Δʣ
• ࠓճɺcurrent_userΛ͑ΔΞΫγϣϯΛ੍ݶͨ͠ • Ωϟογϡ͢ΔͳΒcurrent_userΛ͏ͳ • current_userΛ͏ͳΒΩϟογϡ͢Δͳ • →ϔϧύʔϝιουԽͯ͠ɺকདྷʹΔࣄނࢭʹ
• Ωϟογϡͯ͠ྑ͍APIͱΩϟογϡ͍͚ͯ͠ͳ͍ APIΛઃܭஈ֊͔Βશʹ • ྫɿϢʔβʔAPIΩϟογϡ͍ͨ͠ͷͰɺʮ͕ࣗ ͜ͷϢʔβʔΛϑΥϩʔ͍ͯ͠Δ͔ʯผAPIʹ͢Δ • ͜ΕʹΑͬͯϦΫΤετ͕૿͑Δͷڐ༰͢Δ
Ͳ͏ͯ͠ذ͍ͨ͠߹
Vary: Accept, Origin AcceptϔομʔͱOriginϔομʔʢϦΫΤετϔομʔʣ͝ͱʹผͷ Ωϟογϡʹ͢Δ ʢUser-AgentͳͲͱॻ͍ͯ͠·͏ͱΩϟογϡώοτ͕Լ͕Γ͗͢Δ ͷͰҙʣ Varyϔομʔ
͕ɺCloudFrontVaryΛແࢹ͢Δ
ࠓճͷॴ
PreflightϦΫΤετ
Cross Origin Resource Sharing (CORS) ʹ͓͍ͯɺ ΧελϜϔο μʔ͚ͭͯϦΫΤετ͍ͨ͠߹
ϒϥβ͕PreflightϦΫΤε τΛૹΓɺαʔόʔ͕Ԡ͢Ε ຊͷϦΫΤετΛૹΔ ʢࡉׂ͔͍༷Ѫʣ
PreflightΩϟογϡ༻CloudFrontઃఆ
͜ΕͰരʂʂ
·ͱΊ
• HerokuͰCDNͰΩϟογϡ͢Εdev.toฒͷεϐʔ υʹͳΔ • ؆୯ʹݟ͑Δ͕ɺҰͭҰͭ৻ॏʹΒͳ͍ͱࣄނΔ
Ωϟογϯάͷ͝ར༻ܭըతʹ̇