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
Go to Cloudflare Workers
Search
Kei Kamikawa
February 09, 2024
8
2k
Go to Cloudflare Workers
Go to Cloudflare Workers 〜移行から 0.5 年以上運用する〜 を YAPC::Hiroshima 2024 で話ました。(20min)
Kei Kamikawa
February 09, 2024
Tweet
Share
More Decks by Kei Kamikawa
See All by Kei Kamikawa
どこでも使える Cloudflare Workers!
codehex
6
670
htmx is fun!
codehex
2
320
すぐ使える Cloudflare Workers!
codehex
15
3.3k
AI Gateway 使っているよ!
codehex
2
1.5k
日時処理の新スタンダード: Synchro によるタイムゾーン安全、楽々開発
codehex
1
2k
Cloudflare Workers は楽しい!
codehex
9
3.2k
gRPC Client on Cloudflare Workers
codehex
2
5.6k
NOT A HOTEL AI コンシェルジュ「Kevin」とキャッシュ
codehex
1
1.6k
NOT A HOTEL AIコンシェルジュ「Kevin」の開発秘話
codehex
8
140k
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Done Done
chrislema
181
16k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
98
BBQ
matthewcrist
85
9.4k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Code Review Best Practice
trishagee
65
17k
Raft: Consensus for Rubyists
vanstee
137
6.7k
How STYLIGHT went responsive
nonsquared
95
5.2k
Transcript
(PUP$MPVE fl BSF8PSLFST :"1$)JSPTIJNB ʙҠߦ͔ΒҎ্ӡ༻͢Δʙ
8)0".* +645461&326*$,
!DPEFIFY !$PEF)FY w 0LJOBXBQNͨ·ʹ։࠵ͯ͠·͢ w /05")05&-ʹͯ$MPVE fl BSF8PSLFSTͰ ΞϓϦ։ൃ͍ͯ͠·͢
w ίϯγΣϧδϡγεςϜ w "*ͷศརπʔϧͳͲͳͲ
None
NOT A HOTELʮੈքΛͬͱָ͘͠ʯΛϏδϣϯʹɺΞϓϦ্Ͱࣗͱϗςϧͷସ͕͑Մೳͳʮ͋ͨΒ͍͠Β ͠ʯΛ࣮ݱ͢ΔձࣾͰ͢ɻιϑτΣΞͱϗςϧӡӦΛ߹ΘͤͨαʔϏεͷ։ൃΛਪਐ͍ͯ͠·͢ɻαʔϏεͷίϯη ϓτʮੈքதʹ͋ͳͨͷՈΛʯɻࠓޙϗςϧٴͼॅൢചͷσδλϧԽΛਪਐ͠ɺຊશࠃʹڌΛ͍͖͛ͯ· ͢ɻ ʮ͋ͨΒ͍͠Β͠ʯΛͭ͘Δ NOT A HOTEL
NOT A HOTELͷ4ͭͷಛ 6
EVENTS&HACKATHON 7
NOT A HOTELͷϫʔΫελΠϧɾ੍ WORK STYLE • ಇ͖ॴɿ͖ͳॴ͔ΒϑϧϦϞʔτ • बۀ࣌ؒɿϑϧϑϨοΫεʢίΞλΠϜͳ͠ʣ •
ฏۉڅ༩ʢཧऩʣɿ1009ສԁ ※233݄ظ࣮ • ίϛϡχέʔγϣϯɿSlackɺςϨϏి • ੍ɿ࠷େͰؒ100ສԁͷཱྀߦิॿ
৽ଔืूࠓ·ͰͰ͢ʂʂ
ίϯγΣϧδϡػೳ Ҏ্ӡ༻͍ͯ͠ΔΞϓϦέʔγϣϯʹ͍ͭͯ
/05")05&-ͷٕज़
/05")05&-ͷٕज़ Β͠ʹඞཁͳػೳ͕ͯ͢ /05")05&-ΞϓϦʹ٧·͍ͬͯ ·͢ɻࡏར༻༧ɺϋεΩʔɺΧ ʔγΣΞͷΩʔɺऩೖͷཧ·Ͱ͢ ͯΞϓϦͰ݁͠·͢ɻ ΦʔϧΠϯΞϓϦɾ ӡӦπʔϧʢ1.4ʣ εϚʔτϗʔϜ
ίϯτϩʔϥʔ ؒ୯Ґ͔Βར༻Ͱ͖Δ ձһݖ5)&.&.#&34)*1ͱ ຖ/05")05&-ͷͲ͔͕॓͜ധ ઌͱׂͯ͠ΓͯΒΕΔ5)&,&:ͷ ̎ͭͷ/'5ɻ͍ͣΕ.BSLFUQMBDF Ͱࣗ༝ʹചങՄೳͰ͢ɻ ͯ͢ͷػثͷૢ࡞ ϗʔϜίϯτϩʔϥʔ͔ΒͰ͖·͢ɻ ௨ৗͷՈిΛ,/9ʹଓ͢Δ͜ͱ ͰɺಠࣗͷΦʔτϝʔγϣϯͱίϯτ ϩʔϧΛՄೳʹ͍ͯ͠·͢ɻ "*ίϯγΣϧδϡ 8&#ٕज़ʹΑΔར༻ݖ "*Λ׆༻ͨ͠νϟοτΞγελϯτ ͕ɺ͓٬͞·ͷཁ࣭ʹճ͠ɺ దʹΞϓϦͷૢ࡞ը໘ͷΦεεϝΛ ͠ɺΒ͠ͷࠔΓ͝ͱΛղܾ͠·͢ɻ
/05")05&-ͷٕज़ Β͠ʹඞཁͳػೳ͕ͯ͢ /05")05&-ΞϓϦʹ٧·͍ͬͯ ·͢ɻࡏར༻༧ɺϋεΩʔɺΧ ʔγΣΞͷΩʔɺऩೖͷཧ·Ͱ͢ ͯΞϓϦͰ݁͠·͢ɻ ΦʔϧΠϯΞϓϦɾ ӡӦπʔϧʢ1.4ʣ εϚʔτϗʔϜ
ίϯτϩʔϥʔ ؒ୯Ґ͔Βར༻Ͱ͖Δ ձһݖ5)&.&.#&34)*1ͱ ຖ/05")05&-ͷͲ͔͕॓͜ധ ઌͱׂͯ͠ΓͯΒΕΔ5)&,&:ͷ ̎ͭͷ/'5ɻ͍ͣΕ.BSLFUQMBDF Ͱࣗ༝ʹചങՄೳͰ͢ɻ ͯ͢ͷػثͷૢ࡞ ϗʔϜίϯτϩʔϥʔ͔ΒͰ͖·͢ɻ ௨ৗͷՈిΛ,/9ʹଓ͢Δ͜ͱ ͰɺಠࣗͷΦʔτϝʔγϣϯͱίϯτ ϩʔϧΛՄೳʹ͍ͯ͠·͢ɻ "*ίϯγΣϧδϡ 8&#ٕज़ʹΑΔར༻ݖ "*Λ׆༻ͨ͠νϟοτΞγελϯτ ͕ɺ͓٬͞·ͷཁ࣭ʹճ͠ɺ దʹΞϓϦͷૢ࡞ը໘ͷΦεεϝΛ ͠ɺΒ͠ͷࠔΓ͝ͱΛղܾ͠·͢ɻ
w "*ΞγελϯτͱΦϖϨʔλʔʢਓʣͱձͰ͖Δ w ΦϖϨʔλʔ;FOEFTLΛར༻ w ࡏલʙࡏޙͷαϙʔτ w 2" w ༧มߋ
w ৯ࣄґཔ w ϨϯλΧʔͷαϙʔτɺͳͲͳͲʂ ίϯγΣϧδϡػೳ
"*Ξγελϯτ
ϓϨεϦϦʔε
Ξοϓσʔτ IUUQTOFXTOPUBIPUFMDPNQBJLFWJOG
w /05")05&-ʹࡏ͢Δ͓٬༷ͱ$4͕ ΓऔΓ͢Δػೳͱͯ͠ͷνϟοτ w ࣌ؒαϙʔτΛࢦ͢ "*͕ରԠͰ͖ͳ͍࣌ɺΦϖϨʔλʔΓସ͑Δ "*Ξγελϯτ
ΞʔΩςΫνϟวྺ ϞϊϦε͔Β$MPVE fl BSF8PSLFST·Ͱ
1IBTF
1IBTF w 4VOTIJOF$POWFSTBUJPOΛͬͯ νϟοτͷΈΛΞϓϦʹಋೖʢ-*/&ͬΆ͍ײ͡ʣ w /05")05&-ͷ༧νϟοτʹϘοτͱ ΦϖϨʔλʔͷΓସ͑Λಋೖ w
·ͩӡ༻Λ։͔࢝ͨ͠ΓͰɺఆͨ͠ϑϩʔͷΈ %JBMPH fl PX$9Ͱߏங w 8FCIPPLࡇΓ🔥
None
1IBTF
1IBTF w 4VQBCBTF -BOH$IBJO (15 🦜 w 4VQBCBTFͷ1PTUHSF42-ʹσʔλΛੵ͠ɺ QHWFDUPS֦ுΛͬͯηϚϯςΟοΫݕࡧ w
%JBMPH fl PX$9ͱͷซ༻
1IBTF શମͰฏۉNJO͔͔ͬͯͨ
1IBTF ࠷ऴ݁Ռʢฏۉ͘Β͍·ͰॖΊͨʣ
IUUQTUJOZVSMDPNTT[[D ࣮ઓೖʹ͍ͭͯͷτʔΫͪ͜Β
ݱࡏʢ1IBTFʣ
ݱࡏʢ1IBTFʣ w $MPVE fl BSF8PSLFSTΛ༻ɺجຊతʹ $MPVE fl BSFελοΫͰ݁ w /05")05&-ͷσʔλϕʔε͔Β
༧ใΛऔಘ͢Δ"1*Λ࡞ PO($1 w -BOH$IBJOΛࣙΊɺ(155VSCPΛ༻த
ͳͥ$MPVE fl BSF8PSLFST ($1͔ΒΓ͑ͨཧ༝
Γ͑ͨཧ༝
w σϓϩΠ͕ૣ͍ɺڥߏஙָ͕ w ϦΫΤετʹ͍ۙʢཧʣͱ͜ΖͰॲཧͰ͖Δ w ͍͔͔ͨͬͨΒ Γ͑ͨཧ༝
w σϓϩΠ͕ૣ͍ɺڥߏஙָ͕ w ϦΫΤετʹ͍ۙʢཧʣͱ͜ΖͰॲཧͰ͖Δ w ͍͔͔ͨͬͨΒ Γ͑ͨཧ༝
σϓϩΠ͕ૣ͍ pnpm -F api deploy 3.99s user 0.73s system 16%
cpu 28.411 total
wrangler deploy --dry-runΛͬͯιʔεϚοϓΛ࡞ 3ιʔεϚοϓΛΞοϓϩʔυ wrangler r2 object
put --file=dist/worker.js.map wrangler deploy σϓϩΠͰͬͯΔ͜ͱ
w ϩάʹ5ZQF4DSJQUͷελοΫτϨʔεΛࡌͤΔͨΊʹ ιʔεϚοϓΛΞοϓϩʔυ͍ͯ͠Δ w ͜ͷΞΠσΞNJ[DIJ͞ΜʹڭΘΓ·ͨ͠ɻ IUUQTEJTDPSEDPNDIBOOFMT σϓϩΠͰͬͯΔ͜ͱ
σϓϩΠͰͬͯΔ͜ͱ
ͳͥσϓϩΠ͕ૣ͍ͱخ͍͠ʁ
w 8FCIPPLΛ༻͍ͨ"1*ͷڍಈΛݕূ͔͔ͬͨ͢͠Β w (PͷΞϓϦέʔγϣϯͩͱσϓϩΠ͢Δ·Ͱ NJOҎ্࣌ؒΛֻ͚͍ͯͯਏ͔ͬͨ w ΠϯςάϨʔγϣϯςετɺίϯςφϏϧυ ͳͥσϓϩΠ͕ૣ͍ͱخ͍͠ʁ
ڥߏஙָ͕
w wrangler devΛͬͯϩʔΧϧαʔόʔΛىಈ w $MPVE fl BSF8PSLFSTελοΫͷϛυϧΣΞΛ ͍ͬͯΕɺಛผͳηοτΞοϓඞཁͳ͠ʂ ڥߏஙָ͕
w σϓϩΠ͕ૣ͍ɺڥߏஙָ͕ w ϦΫΤετʹ͍ۙʢཧʣͱ͜ΖͰॲཧͰ͖Δ w ͍͔͔ͨͬͨΒ Γ͑ͨཧ༝
w ϝΠϯϦΫΤετΦʔετϥϦΞ͔Β w 4VOTIJOF$POWFSTBUJPOͷ8FCIPPL w ࣍ʹ64Ͱຊ w 64δϣϒΩϡʔͰɺຊ"*༻ͷཧը໘ ϦΫΤετͷۙ͘Ͱ࣮ߦ
ϦΫΤετͷۙ͘Ͱ࣮ߦ IUUQTEFWFMPQFSTDMPVE fl BSFDPNXPSLFSTSFGFSFODFIPXXPSLFSTXPSLT
w $%/Λ͏ͷͰɺϦΫΤετݩʹ͍ۙॴͰಈ͘ w ΦʔετϥϦΞͰΩϡʔΛ࡞64ͰσΩϡʔ w 64Ͱ(15ͷϝοηʔδΛੜϝοηʔδϙετ ϦΫΤετͷۙ͘Ͱ࣮ߦ
w σϓϩΠ͕ૣ͍ɺڥߏஙָ͕ w ϦΫΤετʹ͍ۙʢཧʣͱ͜ΖͰॲཧͰ͖Δ w ͍͔͔ͨͬͨΒ Γ͑ͨཧ༝
͍͔͔ͨͬͨΒ
IUUQUJOZVSMDPNZ[Q[BXF ָ͠͞ʹ͍ͭͯͷτʔΫͪ͜Β
ϦΞϧϫʔϧυӡ༻ ͕͜͜େมͩΑʂ$MPVE fl BSF8PSLFSTʂ
ΞϓϦέʔγϣϯͷհ
ΞϓϦέʔγϣϯͷհ w IPOPKTIPOP🔥 w "*ཧը໘IUNYBMQJOFKT fi SFCBTFBVUI w #PUͷϝοηʔδੜ$MPVE5BTLT͕τϦΨʔ w
%Λར༻ɺνϟοτͷαδΣετੜͱͯ͠ %VSBCMF0CKFDUTͷ8FC4PDLFUΛར༻
ΞϓϦέʔγϣϯͷհ w ϓϩδΣΫτNPOPSFQP w QSPKFDUT ʹΞϓϦέʔγϣϯ w QBDLBHFT ʹ֤ʑͰ͍͍ͨίʔυ w
DPEFXPSLTQBDFͰෳͷύεΛ ϓϩδΣΫτͱͯ͠ཧ
ΞϓϦέʔγϣϯͷհ w ϝΠϯϓϩδΣΫτͷத w TDSJQUT%FOPͷίʔυ w TSDʹιʔείʔυ w UFTUTʹςετίʔυ w
EFWWBSTEFWWBSTUFNQMBUF͔Β ੜ͞ΕΔΑ͏ʹͳ͍ͬͯΔ IUUQT[FOOEFWOPUBIPUFMBSUJDMFTFGDCB
ΞϓϦέʔγϣϯͷհ %FOPࢦఆͨ͠σΟϨΫτϦͷதΛείʔϓͰ -BOHVBHF4FSWFS͕ಈ͘👌
ΞϓϦέʔγϣϯͷհ w ιʔείʔυͷஔ w (PͰΑ͘ݟΔ ϑϥοτύοέʔδύλʔϯΛ࠾༻
ΞϓϦέʔγϣϯͷӡ༻🚚
ΞϓϦέʔγϣϯͷӡ༻ w ΞϓϦέʔγϣϯϩά w $MPVE-PHHJOHΫϥΠΞϯτ w ϝτϦΫεࢹɺμογϡϘʔυ w $'.FUSJDT&YQPSUFS w
τϨʔε w !NJDSPMBCTPUFMDGXPSLFST
ΞϓϦέʔγϣϯͷӡ༻ w ΞϓϦέʔγϣϯϩά w $MPVE-PHHJOHΫϥΠΞϯτʢࣗ࡞ʣ w ϝτϦΫεࢹɺμογϡϘʔυ w $'.FUSJDT&YQPSUFSʢࣗ࡞ʣ w
τϨʔε w !NJDSPMBCTPUFMDGXPSLFSTʢվʣ
ΞϓϦέʔγϣϯͷӡ༻ w ΞϓϦέʔγϣϯϩά w $MPVE-PHHJOHΫϥΠΞϯτʢࣗ࡞ʣ w ϝτϦΫεࢹɺμογϡϘʔυ w $'.FUSJDT&YQPSUFSʢࣗ࡞ʣ w
τϨʔε w !NJDSPMBCTPUFMDGXPSLFSTʢվʣ
ΞϓϦέʔγϣϯϩά w ($1ͷΫϥΠΞϯτվH31$ΫϥΠΞϯτ͕ ࠾༻͞ΕͯΔͷͰར༻Ͱ͖ͳ͍ʢ/PEFKTPOMZʣ w 3&45"1*Λ͏Α͏ʹࣗ࡞͢Δ w ϦΫΤετͷ࠷ޙʹϩάͷΩϡʔΛ࡞͢Δ w
8PSLFST2VFVF
ΞϓϦέʔγϣϯϩά DMFBOVQͰΩϡʔΛ࡞
ΞϓϦέʔγϣϯϩά w Ωϡʔͷϋϯυϥ w ϦΫΤετͰൃੜͨ͠ϩάΛ ·ͱΊͯૹΔ IUUQTDMPVEHPPHMFDPNMPHHJOHEPDT SFGFSFODFWSFTUWFOUSJFTXSJUF
ΞϓϦέʔγϣϯϩά ࠷ޙʹग़དྷ্͕Δͷ
ΞϓϦέʔγϣϯͷӡ༻ w ΞϓϦέʔγϣϯϩά w $MPVE-PHHJOHΫϥΠΞϯτʢࣗ࡞ʣ w ϝτϦΫεࢹɺμογϡϘʔυ w $'.FUSJDT&YQPSUFSʢࣗ࡞ʣ w
τϨʔε w !NJDSPMBCTPUFMDGXPSLFSTʢվʣ
ϝτϦΫεࢹɺμογϡϘʔυ w $MPVE fl BSF8PSLFST$SPO5SJHHFSTͰ ຖ࣮ߦͯ͠ϝτϦΫεΛूΊ͍ͯΔ w (SBQI2-"OBMZUJDT"1*͔Βऔಘ͢Δ IUUQTEFWFMPQFSTDMPVE
fl BSFDPNBOBMZUJDTHSBQIRMBQJ w $MPVE.POJUPSJOH"1*݁ՌΛૹΔ IUUQTDMPVEHPPHMFDPNNPOJUPSJOHBQJSFG@WSFTUW QSPKFDUTUJNF4FSJFTDSFBUF
ϝτϦΫεࢹɺμογϡϘʔυ $MPVE.POJUPSJOHͷΫϥΠΞϯτ
ϝτϦΫεࢹɺμογϡϘʔυ w ൚༻ϝτϦΫε࡞ؔͷ ༻ҙ w جຊతʹEBUFUJNF.JOVUFͱ ͦͷ࣌ͷϝτϦΫεͱͯ͠ૹΔ ʢ("6(&ʣ
ϝτϦΫεࢹɺμογϡϘʔυ ϝτϦΫεͷूܭ
ϝτϦΫεࢹɺμογϡϘʔυ ࠷େͣͭ·ͱΊͯૹΔ
ϝτϦΫεࢹɺμογϡϘʔυ ΞϥʔτͷઃఆɺμογϡϘʔυ͕࡞Ͱ͖Δ
ΞϓϦέʔγϣϯͷӡ༻ w ΞϓϦέʔγϣϯϩά w $MPVE-PHHJOHΫϥΠΞϯτʢࣗ࡞ʣ w ϝτϦΫεࢹɺμογϡϘʔυ w $'.FUSJDT&YQPSUFSʢࣗ࡞ʣ w
τϨʔε w !NJDSPMBCTPUFMDGXPSLFSTʢվʣ
τϨʔε w Ͳ͜ʹͲΕ͚͔͔ͩ࣌ؒͬͯΔ͔ௐΒΕΔ w !NJDSPMBCTPUFMDGXPSLFST w $MPVE fl BSF8PSLFSTʹಛԽͨ͠0QFO5FMFNFUSZΛ ָʹѻ͑ΔϥΠϒϥϦ
w ֎෦ͷϦΫΤετ%VSBCMF0CKFDU 8PSLFST2VFVFʹରͯ͠ܭଌͰ͖Δ
τϨʔε
τϨʔε w (PPHMF͕ఏڙ͍ͯ͠Δ&YQPSUFS/PEFKTPOMZ w ͪΖΜࣗ࡞😇 w $MPVE5SBDFͷ"1*݁ՌΛૹΔ IUUQTDMPVEHPPHMFDPNUSBDFEPDTSFGFSFODFWSFTUWQSPKFDUTUSBDFT CBUDI8SJUF
τϨʔε ແݶʹಉ͡ϦΫΤετΛ͛ଓ͚Δ᠘͕ʜ
τϨʔε !NJDSPMBCTPUFMDGXPSLFST͕ܭଌΛऴ͑Δ 5SBDF&YQPSUFS͕($1ܭଌ݁ՌΛૹΔ ϦΫΤετ͢ΔલʹೝূͷͨΊʹ(PPHMF0"VUI ϦΫΤετΛ͛ΒΕΔ
τϨʔε !NJDSPMBCTPUFMDGXPSLFST͕ܭଌΛऴ͑Δ 5SBDF&YQPSUFS͕($1ܭଌ݁ՌΛૹΔ ϦΫΤετ͢ΔલʹೝূͷͨΊʹ(PPHMF0"VUI ϦΫΤετΛ͛ΒΕΔ ͜ΕΒ͕ͣͬͱϧʔϓͯ͠͠·͏ʂʂ
τϨʔε IUUQTHJUIVCDPNFWBOEFSLPPHIPUFMDGXPSLFSTJTTVFT
ϥΠϒϥϦ͕मਖ਼͞ΕΔ·Ͱͭʁ🤔
൱
ՈͷๅQBUDI
τϨʔε ܭଌͷର֎ʹ͢Δ
τϨʔε👏
Ҏ্ӡ༻ͯ͠Έͯʜ
Ҏ্ӡ༻ͯ͠Έͯ w ։ൃମݧ͕ྑ͗ͯ͢ϓϩδΣΫτΛਐΊΔ͜ͱʹ ूதͰ͖ͯྑ͍ʂ
Ҏ্ӡ༻ͯ͠Έͯ w ։ൃମݧ͕ྑ͗ͯ͢ϓϩδΣΫτΛਐΊΔ͜ͱʹ ूதͰ͖ͯྑ͍ʂ w ҰํͰϩάܭଌɺࢹपΓ݁ߏͳύϫʔ͕ඞཁ w ूॴ͕($1͔ͩΒ͔͠Εͳ͍
Ҏ্ӡ༻ͯ͠Έͯ w ։ൃମݧ͕ྑ͗ͯ͢ϓϩδΣΫτΛਐΊΔ͜ͱʹ ूதͰ͖ͯྑ͍ʂ w ҰํͰϩάܭଌɺࢹपΓ݁ߏͳύϫʔ͕ඞཁ w ूॴ͕($1͔ͩΒ͔͠Εͳ͍ w
ຊؾͰӡ༻ʹ͢Δʹɺ·ͩؾܰʹ͑ͳ͍ʜͱࢥ͏
େมͳ෦ଞʹ w 8PSLFST2VFVF%ͨ·ʹτϥϒϧ͕ൃੜ͢Δ w $MPVE fl BSF%JTDPSEΛৗ༻͢Δ w ϔϧϓΛٻΊΔ w
όάΛใࠂ͢Δσόοάʹ͖߹͏
Զͨͪͷӡ༻͜Ε͔Βͩʂ d'JOd