Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
フルCDNアーキテクチャでサービス設計した話
Search
Atsushi Takayama
September 22, 2018
Technology
4.2k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
フルCDNアーキテクチャでサービス設計した話
FUKUOKA Engineers Day 2018 ~Autumn~ で話した内容です。
Atsushi Takayama
September 22, 2018
More Decks by Atsushi Takayama
See All by Atsushi Takayama
最高の開発者体験の追求が開発生産性を改善し続ける文化を生み出した話
edvakf
3
2.1k
NeurIPS 2021 論文読み会: How Modular should Neural Module Networks Be for Systematic Generalization?
edvakf
0
240
8年物のJavaのシステムをKotlinに変えていく選択に至るまで
edvakf
2
1.1k
ピクシブ社内のImageFlux利用事例紹介
edvakf
2
3.2k
学びの文化を育む社内読書会のススメ
edvakf
0
330
Goでバイナリを読む+α
edvakf
1
1k
お前はこれまでに作ったAPIの数を覚えているのか?
edvakf
0
2.8k
「ふつうのRailsアプリケーション」についての考え方
edvakf
2
960
ggplot.galleryというお遊びウェブアプリケーションを作った話
edvakf
0
450
Other Decks in Technology
See All in Technology
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
1k
アウトプット初心者、半年間のふりかえり
4o1sobblue
0
440
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
1.7k
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
5
1.1k
今さら理解するウェブフォントver.2026
takanorip
3
890
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
310
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
190
Optunaの最新リリースv5.0について
pfn
PRO
0
120
10年後、Engineering 行為を剥奪されるとして、わたしたちは、どう、何を創ればいいだろうか。 / If Engineering Is Taken Away in 10 Years, How and What Should We Create?
bitkey
PRO
1
200
『SAR衛星データ解析入門』のご紹介とその応用
syuchimu
0
120
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
730
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
120
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
520
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
HDC tutorial
michielstock
2
960
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
Designing Experiences People Love
moore
143
24k
The Cult of Friendly URLs
andyhume
79
7k
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
Into the Great Unknown - MozCon
thekraken
41
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ฒͷεϐʔ υʹͳΔ • ؆୯ʹݟ͑Δ͕ɺҰͭҰͭ৻ॏʹΒͳ͍ͱࣄނΔ
Ωϟογϯάͷ͝ར༻ܭըతʹ̇