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とNature ~ Nature Remoの裏側 / Nature Bath vol6
Search
Songmu
December 02, 2020
Technology
0
6.6k
GoとNature ~ Nature Remoの裏側 / Nature Bath vol6
Songmu
December 02, 2020
Tweet
Share
More Decks by Songmu
See All by Songmu
現役エンジニア兼採用担当から見たエンジニア採用アンチパターン / Engineer Recruitment Anti-Patterns
songmu
20
15k
20万超のIoTデバイス同時接続を支えるNature RemoのシステムとAWS / IoT AWS Loft Nature Remo 2021
songmu
0
1.2k
Nature Remoの裏側 ~ AWSとWeb技術をIoTの世界でフル活用する / Inside Nature Remo
songmu
11
15k
Other Decks in Technology
See All in Technology
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
950
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
2
230
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
飲食店データの分析事例とそれを支えるデータ基盤
kimujun
0
190
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
200
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
680
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
130
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
200
Storybook との上手な向き合い方を考える
re_taro
2
330
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.7k
Featured
See All Featured
Become a Pro
speakerdeck
PRO
25
5k
Docker and Python
trallard
40
3.1k
Building an army of robots
kneath
302
43k
Teambox: Starting and Learning
jrom
133
8.8k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
What's in a price? How to price your products and services
michaelherold
243
12k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
A Tale of Four Properties
chriscoyier
156
23k
Designing Experiences People Love
moore
138
23k
4 Signs Your Business is Dying
shpigford
180
21k
Transcript
ݫൿɿຊࢿྉͷҰ෦·ͨશ෦ΛɺNatureגࣜձࣾͷڐՄͳ͠ʹɺෳɺసࡌ͢Δ͜ͱΛې͡·͢ɻ Introduce about September 3, 2019 Natureגࣜձࣾ Go ͱ Nature
Bath vol.6 ʮGo։ൃɾӡ༻ͷݱʯ 19th November, 2020 ~ Nature Remoͷཪଆ
2 Me • দ խ (id:Songmu) • Nature גࣜձࣾ औకCTO
• https://songmu.jp/riji • https://github.com/Songmu • ͖ͳݴޠGoͱPerlͱதࠃޠ • 3 Times ISUCON Winner • ஶॻʹʮΈΜͳͷGoݴޠʯ • झຯOSS׆ಈͰ͢
3 Created Miscellaneous Go Tools • maltmill • πʔϧΛ؆୯ʹhomebrewͰ͢ΔͨΊͷπʔϧ •
horenso • όονδϣϒͷͨΊͷϥούʔ • peep • ϓϩηεͷऴྃ௨Λͯ͘͠ΕΔ܅ • gocredits • Goͷπʔϧ࣌ʹґଘϥΠϒϥϦͷLICENSEΛಉࠝ • etc. • ref. ʮGoͰπʔϧΛྔ࢈͢Δͷํ๏ʯ • https://junkyard.song.mu/slides/gocon2019-fukuoka/#0
4 Maintaining major Go tools • ghq (github.com/x-motemen/ghq) • ιʔείʔυϦϙδτϦཧπʔϧ
• ghq handbook • https://leanpub.com/ghq-handbook • ghr (github.com/tcnksm/ghr) • GitHubͷόΠφϦϦϦʔε༻πʔϧ
5 Recent Works • Let's Encryptͷϧʔτূ໌ॻมߋ • Android7.1ҎલͰLet's Encryptূ໌ॻͷαΠτ͕ݟΒ Εͳ͘ͳΔ
• https://songmu.jp/riji/entry/2020-09-22-letsencrypt.html • Let's Encryptͷূ໌ॻସपΓͦͷޙ • https://songmu.jp/riji/entry/2020-09-22-letsencrypt.html
6 Recent Works • GoͷΫϥΠΞϯτͷରԠ • ͝ར༻͍ͩ͘͞
7 ৽࡞ • github.com/Songmu/gotesplit • github.com/Songmu/ecschedule • ޙͰղઆ͠·͢
8 We are Hiring • GoΤϯδχΞઈࢍืूதͰ͢ʂ • ݱࡏ3໊ • ιϑτΣΞΤϯδχΞ7໊
ࠓ͢͜ͱ Agenda 9
10 Agenda • ܰ͘Nature Remoͷհ • Nature RemoͱGo • ʑͷGo׆༻OSS׆ಈͳͲ
ձࣾͱ Company and Product 11
Mission 12 Mission ⾃然との共⽣を テクノロジーでドライブする
Product
֎ग़ઌ͔ΒεϚϗͰΤΞίϯΛON εϚʔτεϐʔΧʔͱ࿈ܞͯ͠ͰՈిΛૢ࡞ 14 Features
How It Works
Traction 20ສಥഁ ೝˍγΣΞۀքNo.1 ʢ20202݄࣮ࢪɺࣗࣾௐʣ
Nature RemoͱGo Nature Remo and Go 17
API Stream Worker Amazon ECS Subscribe Publish WS WS Pub/Sub
System Diagram
Nature Remoͷཪଆ • αʔόʔαΠυ΄΅શͯGo • ׂ࣮ͱී௨ͷWebٕज़Λ࣮ͬͯݱ͍ͯ͠Δ • WebSocketͷଓཧपΓ͕νϟϨϯδϯά • αʔϏεٸத
Components • API • εϚϗΞϓϦεϚʔτεϐʔΧʔͱͷ௨৴ • Stream • Nature RemoͱͷWebSocket௨৴
• Worker • ϧʔϧͷ࣮ߦ ͯ͢GoͰAmazon ECS্Ͱಈ͔͍ͯ͠Δ
Remarkable Points • ૉͳGoͷWebΞϓϦέʔγϣϯ • Redis Pub/SubΛ༻͍ͨɺAPI - StreamؒͷΓͱΓ •
Nature RemoALBΛܦ༝ͯ͠streamαʔόʔʹ WebSocketଓ͍ͯ͠Δ • AlexaͷΧελϜεΩϧAWS Lambdaܦ༝Λ࣮ͬͯߦ ͞ΕΔ
Simple Web Applications with Go • ී௨ͷWebΞϓϦέʔγϣϯ • ͱͱherokuͰϗετ໊͍ͯͨ͠ •
ϑϨʔϜϫʔΫ • github.com/nbio/hitch • Gorilla web toolkitΛ෦తʹར༻ • MySQL/Redis • gorp/redigo • guregu/dynamo
Utilize Redis Pub/Sub • Redis Pub/SubΛ׆༻͍ͯ͠Δ • API͔ΒRedisʹPublish • StreamRedisΛSubscribe
• ૬ޓ௨৴͠ͳ͍ૄ݁߹Λ࣮ݱ͍ͯ͠Δ • Streamଆ͋͘·ͰWebSocketͱRedis͔ΒͷSubscribeͰ ड໋͚͚ͨྩͷ࣮ߦ͔͓͜͠ͳΘͣঢ়ଶΛ࣋ͨͳ͍
WebSocket connection via ALB • Nature RemoALBΛܦ༝ͯ͠streamαʔϏεʹ WebSocketଓ͍ͯ͠Δ • ҰͭͷGoΞϓϦͷίϯςφͰສଓ͚͞Δʂ
• Goͷ͓खܰͳྑ͞Λ࣮ײ • GoखܰʹͦΕͳΓͷύϑΥʔϚϯε͕ग़ͤΔͷ͕͔ͳΓ ྑ͍
ʑͷ։ൃɾӡ༻ Go Topics 25
ʑͷۀ • GitHub্Ͱ։ൃ • CircleCI্ͰCI/CD • developϒϥϯν͔ΒfeatureϒϥϯνΛΔ • ϨϏϡʔͯ͠Ϛʔδ •
renovateʹΑΔϥΠϒϥϦࣗಈΞοϓσʔτ • developϒϥϯν͔Βmasterϒϥϯνͷpull request • git-pr-releaseʹΑͬͯࣗಈ࡞ • Ϛʔδ͞ΕͨΒࣗಈͰຊ൪deploy
CI/CD Pipelines git-pr-release git push go test go build docker
build docker push ecspresso deploy 1 2 3 4
ECSͷdeployʹecspressoಋೖ • github.com/kayac/ecspresso • ecs-deploy͔ΒΓ͑ • Γ͑ઌͱͯͪ͠ΐ͏ͲΑ͔ͬͨ • طଘͷTask DefinitionΛར༻ͯͦ͠ͷ··γʔϜϨεʹ
ҠߦՄೳ • CircleCI͔Βdeploy͍ͯ͠Δ • ଞʹ kayac/go-katsubushi ͳͲkayac OSSΛ׆༻
ECS Task Definition͕reviewableʹ • TaskͷαΠυΧʔՃύϥϝʔλʔมߋ͕reviewable ʹͳͬͨͷྑ͔ͬͨ
github.com/Songmu/flextime • ςετͰ࣌ࠁܥΛࠩ͠ସ͑ΔͨΊͷϥΠϒϥϦ • timeύοέʔδͱಉ༷ͷΠϯλʔϑΣʔεΛඋ͑Δ
github.com/Songmu/smartcache • ϓϦϑΣον͢ΔΠϯϝϞϦΩϟογϡ • Ωϟογϡߋ৽ॲཧ͕ • ॏෳ͠ͳ͍Α͏ʹɾϒϩοΫ͠ͳ͍Α͏ʹ
ECS Scheduled TaskཧͷͨΊͷπʔϧecschedule • github.com/Songmu/ecschedule • όονྨɺECSͷScheduled TaskΛར༻͍ͯ͠Δ͕ͦΕ Λόʔδϣϯཧ͍ͨ͠ͱ͍͏ಈػ
খωλ: όονྨͷಈ͔͠ํ • APIͱworkerͱόονಉ͡GoόΠφϦɺಉ͡ίϯςφ • Task Definitionҧ͏ͷ • αϒίϚϯυͰॲཧΛ͚Δ •
nature server: APIαʔόʔͷىಈ • nature squadrons: ϫʔΧʔͷىಈ • nature batch hoge ... : όονྨͷىಈ
34 ςετߴԽͷͨΊͷgotesplit • github.com/Songmu/gotesplit • CIڥͰͷςετฒྻ࣮ߦΛ؆୯ʹ࣮ݱ • CircleCI / GitHub
Actions • ࣾͷςετ͕࣌ؒ15->5ʹ • ͔ͳΓศརͳͷͰͥͻ͝ར༻͍ͩ͘͞
35 @soh335࡞ͷOSS • github.com/soh335/go-test-redisserver • github.com/soh335/shukujitsu (new!) • github.com/schemalex/schemalex •
← ͜Ε·ͩಋೖग़དྷ͍ͯͳ͍
36 github.com/soh335/shukujitsu • ࡢ൩ੜ • ҎԼͷσʔλΛͱʹຊͷॕఆ • https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv • ͜ΕtypoͰ͋Γ·ͤΜ
• σʔλϑΥʔϚοτឯ༨ۂં͋ͬͨΑ͏͕ͩࠓׂͱ·ͱ
37 ࣗ࡞OSSΛຊ൪ʹಋೖ͢Δ • ͱΓ͋͑ͣOSSͰ࡞ͬͯΈΔ • ࢼ͠ʹຊ൪ೖͯ͠͠·͏
OSSͷpull request 38
39 nbio/hitch#11
40 nbio/hitch#12
41 kayac/go-katsubushi#40
42 blang/semver#56
43 pressly/goose#180
44 pressly/goose#181
45 kayac/ecspresso#37
46 kayac/ecspresso#38
47 kayac/ecspresso#161
48 guregu/dynamo#106
49 goccy/go-yaml#23
50 goccy/go-yaml#36
51 go-gorp/gorp#411
52 manifoldco/promptui#132
53 shogo82148/go-sql-proxy#42
54 OSSͷpull request • ʮڠௐʯͰ͖Δ͔Λॏࢹ • pull requestΛૹͬͯΈͯ୳ΓΛೖΕΔ • ࢥ͕Ϛον͍ͯͦ͠͏͔
• ϝϯςφϯε͕ΞΫςΟϒ͔ • ϝϯςφϯε͕ࢭ·ͬͯΔͱࢥ͍͖͙͢ʹ ରԠͯ͘͠ΕΔ͜ͱ • 1ܦ͔ͬͯΒϚʔδ͞ΕΔ͜ͱ
·ͱΊ 55
Natureͷ։ൃ • αʔόʔαΠυ΄΅શ෦Go • 10ສ͑ͷIoTσόΠεΛϋϯυϦϯά͢ΔWebSocketίϯςφ܈ • αʔόʔଆͷ੍ޚ͕݁ߏϔϏʔͰ໘ന͍ • ΈࠐΈAppͱͷ࿈ܞͷ໘ന͞ •
OSSΛͪΌΜͱ׆༻͍ͨ͠ • ڠௐͰ͖ΔOSSΛબΜͰߩݙ͍ͯ͘͠ • OSSʹͰ͖Δͷͯ͠͠·͏
We are Hiring! ੵۃ࠾༻தͰ͢ʂ • όοΫΤϯυΤϯδχΞ • εϚʔτϑΥϯΤϯδχΞ • ϑϩϯτΤϯυΤϯδχΞ
• ػցֶशΤϯδχΞ • ΈࠐΈΤϯδχΞ