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
FUJIMIのFastly活用事例集
Search
Kono Junya
March 29, 2022
Technology
0
1.5k
FUJIMIのFastly活用事例集
Fastly User Meetup #4 の登壇資料です
https://fastly-community.connpass.com/event/241481
Kono Junya
March 29, 2022
Tweet
Share
More Decks by Kono Junya
See All by Kono Junya
Progressive Release by using Fastly
konojunya
1
450
WinTicketにおけるPWA at PWA Night vol.9
konojunya
4
1.7k
新卒研修を終えて
konojunya
0
550
大規模なWebの開発手法
konojunya
1
2.4k
初めてのReact
konojunya
1
380
Other Decks in Technology
See All in Technology
20241220_S3 tablesの使い方を検証してみた
handy
3
360
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
2
2.2k
コンテナセキュリティのためのLandlock入門
nullpo_head
2
320
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
220
Jetpack Composeで始めるServer Cache State
ogaclejapan
2
170
スタートアップで取り組んでいるAzureとMicrosoft 365のセキュリティ対策/How to Improve Azure and Microsoft 365 Security at Startup
yuj1osm
0
210
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
170
ハイテク休憩
sat
PRO
2
140
祝!Iceberg祭開幕!re:Invent 2024データレイク関連アップデート10分総ざらい
kniino
2
250
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
160
Featured
See All Featured
A Tale of Four Properties
chriscoyier
157
23k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Being A Developer After 40
akosma
87
590k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Building Applications with DynamoDB
mza
91
6.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
4 Signs Your Business is Dying
shpigford
181
21k
Code Reviewing Like a Champion
maltzj
520
39k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Transcript
'6+*.*ͷ'BTUMZ׆༻ࣄྫू
++ -FBE8FCBOE&EHF&OHJOFFS 5XJUUFS!LPOPKVOZB (JU)VC!LPOPKVOZB [FOOEFW!KK ࣗݾհ
#VTJOFTTʷ'6+*.*
'6+*.*ͷ8&#ඒ༰ੳ͔Β ύʔιφϥΠζ͢ΔϏϡʔςΟʔϒϥϯυͰ͢ɻ '6+*.*ͷࣄۀհ ถࠃISNFαϓϦϝϯτΞυόΠβʔࢿ֨Λ࣋ͪɺ ػೳੑදࣔ৯ݕఆڠձͷཧࣄΛΊΔαϓϦϝϯτͷઐՈΛ ΞυόΠβʔͱܴͯ͑͠ɺFUJIMIಠࣗͷඒ༰ੳΛ։ൃɺ࣮ݱɻ 20193݄ͷαϓϦϝϯτϦϦʔεޙɺ40ສਓͷੳใΛͱʹ 20203݄ʹඒ༰ੳΛΞοϓσʔτɻ
'6+*.*ͷ8&#ඒ༰ੳ͔Β ύʔιφϥΠζ͢ΔϏϡʔςΟʔϒϥϯυͰ͢ɻ '6+*.*ͷࣄۀհ
5FDIOPMPHZʷ'6+*.*
1SPHSFTTJWF3FMFBTF -1ͷϦμΠϨΫτXJUI$!& 1SFWJFXڥ "HFOEB
1SPHSFTTJWF3FMFBTF
'BTUMZʷ'6+*.* #SPXTFS
'BTUMZʷ'6+*.* if(req.url.path ~ “^/xxx”) { set req.backend = Origin2; }
YYY ʹର͢ΔϦΫΤετʹରͯ͠$MPVE3VOΛPSJHJOͱ͢Δ
'BTUMZʷ'6+*.* ஈ֊తʹҠߦ͢ΔͨΊʹ7$-Λੜ͢Δ ʷ
'BTUMZʷ'6+*.* #SPXTFS $VTUPN7$- ஈ֊తʹҠߦ
'BTUMZʷ'6+*.* *NBHF0QUJNJ[FS τοϓϖʔδͰݕূ -B[ZMPBE༗Γͷϖʔδ'7ಡΈࠐΈ࣌ͰɺL#ͷݮ -BSHFTU$POUFOUGVM1BJOUTͷύϑΥʔϚϯε্ if(req.url.ext ~ “(?i)^(gif|png|jpe?g)$”) { set
req.url = req.url.path “?auto=webp”; set req.http.Cache-Control = “public, max-age=…”; set req.http.Surrogate-Key = “image”; }
'BTUMZʷ'6+*.* *NBHF0QUJNJ[FS if(req.url.ext ~ “(?i)^(gif|png|jpe?g)$”) { if(req.http.Save-Data) { set req.url
= req.url.path “?quality=440”; } } 'BTUMZ*NBHF0QUJNJ[FSΛ͏ར ($1ͳͲʹରͯ͠BTTFUTΛEFQMPZͤͣʹ͢Ή ্هͷΑ͏ʹIUUQGJFMEͰذΛ͢Δ͜ͱ͕Ͱ͖Δ 4VSSPHBUF,FZʹΑΔDBDIFͷΠϯελϯτύʔδ͕ߦ͑Δ
-1ͷϦμΠϨΫτXJUI$!&
$PNQVUF!&EHFʷ'6+*.* IUUQTQSGVKJNJNFYYY ࠂ༻ͷϥϯσΟϯάϖʔδ GVKJNJNFͰ৴͍ͨ͠ʜ ·͔͢͡🤔 ϦμΠϨΫτͲ͏͠Α͏͔ͳʜ -1ͷϦμΠϨΫτXJUI$!&
$PNQVUF!&EHFʷ'6+*.* -1ͷϦμΠϨΫτXJUI$!& GET /pt101 HTTP/2 Host: pr.fujimi.me HTTP/2 308 Location:
https://fujimi.me/lp/protein 3FRVFTU 3FTQPOTF let path = req.get_path(); let path = match path { path if path.contains(“pt”) => “/protein”, _ => path, }; Ok(Response::from_status(StatusCode::PERMANENT_REDIRECT).with_header( header::LOCATION, format!(“https://fujimi.me/lp{}”, path), )) src/main.rs
1SFWJFXڥ
$PNQVUF!&EHFʷ'6+*.* 1SFWJFXڥ a͜ͷλεΫΑΖͽ aঝʂʂ 1. %FW a֬ೝ͠·͢ʂʂ aͰ͖ͨʂ 1. %FW
8SJLFΛͬͯ λεΫΛνέοτཧ νέοτͱ13͕΄΅
$PNQVUF!&EHFʷ'6+*.* 1SFWJFXڥ a֬ೝ͠·͢ʂʂ aͰ͖ͨʂ 1. %FW 1VMM3FRVFTUΛϚʔδ 1.͕֬ೝ͢ΔͨΊʹ 13ΛNBJOCSBODIʹϚʔδ͠ͳ͍ͱ͍͚ͳ͍ʜ
1.͕ϨϏϡʔͯ͠μϝͩͬͨ߹ɺSFWFSUPSमਖ਼13Λ͋͛ͳ͍ͱ͍͚ͳ͍ ະͳͷΛNBJOCSBODIϚʔδ͠ͳ͚ΕͳΒͳ͍
$PNQVUF!&EHFʷ'6+*.* 1SFWJFXڥ ֤1VMM3FRVFTUʹԠͯ͡αʔόʔ্ཱ͕͕ͪΕ NBJOCSBODIʹϚʔδ͢Δඞཁ͕ͳ͍ʂʂʂ a1SFWJFXڥര
$PNQVUF!&EHFʷ'6+*.* 1SFWJFXڥ QSQSFWJFXFYBNQMFDPN QSEFWYYYDMPVEBSVOBQQ
$PNQVUF!&EHFʷ'6+*.* 1SFWJFXڥ if host == “preview.example.com" { return response_preview_list_app(); }
src/main.rs
$PNQVUF!&EHFʷ'6+*.* 1SFWJFXڥ ҙ 1VSHF63-ଘࡏ͠ͳ͍ QSFYBNQMFDPNͷΑ͏ʹಛఆͷ)PTUࢦఆͰ͖ͳ͍ 4VSSPHBUF,FZΛઃఆͯ͠ύʔδͰ͖ΔΑ͏ʹ͢Δʂ
$BTF4UVEZʹܝࡌ͞Ε·ͨ͠🎉 ࠓͷ͓ͷҰ෦ΛΑΓৄ͓͍ͯ͘͠͠ΔͷΛ $BTF4UVEZʹܝࡌ͍͍ͯͨͩͨ͠ͷͰੋඇΈ͍ͯͩ͘͞ʂ 'BTUMZ *OD"MM3JHIUT3FTFSWFE 'BTUMZ ͷ $%/ͱ$PNQVUF!&EHFͰ '6+*.*ެࣜαΠτΛڧԽ ςϨϏ$.Ͱഒʹ૿͑ͨΞΫηεʹ
ઃఆมߋͳ͠ͰରԠ ඒ༰ੳ͔Βͭ͘Δ͋ͳͨͷͨΊͷύʔιφϥΠζϏϡʔςΟϒϥϯυͰ͋Δ'6+*.*Λ த৺ʹࣄۀΛల։͢ΔτϦίגࣜձࣾïҎԼɺτϦίðɻެࣜαΠτͰ͋ΔGVKJNJNFʹɺ 'BTUMZͷ$%/ɺΠϝʔδΦϓςΟϚΠβʔɺ͓Αͼ$PNQVUF!&EHFΛ࠾༻ɻ ΩϟογϡͷώοτˋҎ্ɺΩϟογϡΧόϨοδˋΛ࣮ݱ͢Δͱͱʹɺ ςϨϏ $.ͷެ։ʹΑΔഒҎ্ͷΞΫηεͷ֦େʹαʔόʔڥͷઃఆΛมߋ͢Δ͜ͱͳ͘ ରԠͰ͖ΔΈΛ࣮ݱͨ͠ɻ 'BTUMZ τϦίגࣜձࣾ $"4&456%: ໊ࣾāτϦίגࣜձࣾ ॅॴā˟ ɹɹɹ ౦ژ৽॓۠৽॓େڮޚԓϏϧ' 63-ɿIUUQTUSJDPUJODDPN ݄ʹઃཱɻඒ༰ੳʹΑΓύʔιφϥΠζ͞Εͨα ϓϦϝϯτɺϓϩςΠϯɺϑΣΠεϚεΫΛఏڙ͢ΔϏϡʔ ςΟϒϥϯυʮ'6+*.*ʯͷࣄۀΛల։ɻ ݄ʹɺ ϧϛω৽॓ళʹॳͷৗઃళΛΦʔϓϯͨ͠ɻ ໊ࣾʹɺ͓٬༷ʹѪ͞ΕΔϓϩμΫτΛΓɺເதʹͳͬ ͯ΄͍͠ͱ͍͏ʮྂʯͱɺ͓٬༷ͷΛͭͻͱͭஸೡʹฤΈ ্͛ɺਓʹدΓఴͬͨϓϩμΫτΛΔͱ͍͏ϑϥϯεޠͷ ʮUSJDPUʢฤΈʣʯ ͷͭͷ͍͕ࠐΊΒΕ͍ͯΔɻ w $%/ ಋೖͱ 3JPUKT ͔Β /FYUKT ͷҠߦͷ ͭΛతʹ 'BTUMZ Λ࠾༻ ɹʮࢲΒ͍͠ඒ͠͞ͰɺࢲΛͬͱ͖ʹͳΔ⼧ͱ͍͏ϛογϣϯʹج͖ͮӡӦ͢Δ '6+*.* GVKJNJNF Ŋʙͷඒ༰ʹؔ͢Δઃʹ͑Δ͜ͱͰɺͦͷੳ ݁Ռ͔ΒύʔιφϥΠζ͞ΕͨΦϦδφϧͷαϓϦϝϯτϑΣΠεϚεΫɺϓ ϩςΠϯΛߪೖͰ͖ΔެࣜαΠτͰ͋Δɻओʹʙͷঁੑʹࢧ࣋͞ΕɺΞΫ ςΟϒϢʔβʔສϢʔβʔҎ্ɻۙΧ݄ͷϖʔδϏϡʔï 17 ðͷฏۉ ɺສ17Λ͍͑ͯΔɻ ɹॳɺGVKJNFNF Ͱίϯςϯπ৴ωοτϫʔΫ $%/ ͕ಋೖ͞Ε͍ͯͳ͔ͬ ͨɻ͔͠͠ɺ݄ʹλϨϯτΛى༻ͨ͠ςϨϏ$. ͷެ։͕ܾ·ͬͨ͜ͱ͔ Βɺ$%/ͳ͠ͷ··ςϨϏ$.Λެ։͢Δ͜ͱɺαʔόʔͷෛՙ૿େʹΑΔγες ϜఀࢭͷϦεΫ͕ߴ͔ͬͨɻ·ͨɺςϨϏ$.ͷެ։લͷ݄ʹ৽Ͱ͋ ΔϓϩςΠϯΛϦϦʔε͍͕ͯͨ͠ɺٕज़తͳ͔Β$%/ͷಋೖ͕ඞཁͩͬͨɻ ɹ-FBE 8FC &OHJOFFS ͷՏ७ࢯɺ⼦αϓϦϝϯτͱϑΣΠεϚεΫͷΞϓϦ έʔγϣϯɺ3JPUKT ͱ͍͏গ͠ݹ͍ +BWB4DSJQU ͷϑϨʔϜϫʔΫͰ࣮͞Ε ͍ͯͨͷͰ͕͢ɺ ॊೈͳઃܭʹͳ͍ͬͯͳ͍ͨΊɺͦ͜ʹϓϩςΠϯͷ৽نϓϥο τϑΥʔϜΛՃ͢Δͷ։ൃମݧ͕Α͘ͳ͍ͱߟ͑·ͨ͠ɻͦ͜Ͱ /FYUKT ͱ 5ZQF4DSJQUʹΑΔΞϓϦέʔγϣϯ։ൃʹҠߦ͍ͨ͠ͱࢥ͍ͬͯ·ͨ͠ʯͱ͢ɻ ɹαϓϦϝϯτͱϑΣΠεϚεΫͷΞϓϦέʔγϣϯΛ 3JPUKT ͔Β /FYUKTʹҰ ؾʹॻ͖͑Δͱ։ൃͱ2" ࣭อূ ʹ͕͔͔ͬͯ͠·͏ɻ ͦ͜Ͱɺผͷαʔ όʔͰϓϩςΠϯͷΞϓϦέʔγϣϯΛ։ൃ͠ͳ͕ΒɺGVKJNJNF͔ΒΞΫηεͰ ͖ΔΑ͏ʹ͢Δ͜ͱ͕ඞཁͩͬͨɻՏࢯɺ ⼦'BTUMZ Ͱ͋Εɺ7$- 7BSOJTI $POpHVSBUJPO -BOHVBHF Λ͏͜ͱͰɺ ͜ΕΛ࣮ݱͰ͖Δͱߟ͑·ͨ͠ʯ ͱ͢ɻ ɹݕ౼ͷ݁Ռɺ݄ʹ 'BTUMZ ͷ࠾༻Λܾఆɻ࠾༻ͷཧ༝ΛՏࢯɺʮલ ৬Ͱ 'BTUMZ Λͬͨ͜ͱ͕͋ΔͷͰ͕͢ɺ'BTUMZ ͷڧΈͰ͋Δ 7$- Λར༻ͨ͠ ॊೈͳઃܭ͕Մೳͳ͜ͱΛධՁ͠·ͨ͠ɻ·ͨɺ৽͍͠ΞϓϦέʔγϣϯΛϦϦʔε ͨ͠ͱ͖ʹɺΩϟογϡΛύʔδ͠ͳ͚ΕͳΒͳ͍ͷͰ͕͢ɺ'BTUMZ Ͱ͋ΕΠ ϯελϯτύʔδͰߴʹΩϟογϡΛύʔδͰ͖Δ͜ͱ࠾༻ΛܾΊͨཧ༝ͷͭ Ͱͨ͠ʯͱ͍ͯ͠Δɻ
8FBSFIJSJOH aશ৬छืूதͰ͢ʂ IUUQTIFSQDBSFFSTWUSJDPU
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠