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
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
220
複雑なState管理からの脱却
sansantech
PRO
1
140
強いチームと開発生産性
onk
PRO
33
11k
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
120
Can We Measure Developer Productivity?
ewolff
1
150
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.6k
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
590
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
120
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
スクラム成熟度セルフチェックツールを作って得た学びとその活用法
coincheck_recruit
1
140
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
459
33k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
How STYLIGHT went responsive
nonsquared
95
5.2k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Designing for Performance
lara
604
68k
Become a Pro
speakerdeck
PRO
25
5k
How to Ace a Technical Interview
jacobian
276
23k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
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
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠