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
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
380
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
480
Wvlet: A New Flow-Style Query Language For Functional Data Modeling and Interactive Data Analysis - Trino Summit 2024
xerial
1
120
生成AIのガバナンスの全体像と現実解
fnifni
1
190
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
230
Snykで始めるセキュリティ担当者とSREと開発者が楽になる脆弱性対応 / Getting started with Snyk Vulnerability Response
yamaguchitk333
2
180
サーバレスアプリ開発者向けアップデートをキャッチアップしてきた #AWSreInvent #regrowth_fuk
drumnistnakano
0
190
WACATE2024冬セッション資料(ユーザビリティ)
scarletplover
0
200
DUSt3R, MASt3R, MASt3R-SfM にみる3D基盤モデル
spatial_ai_network
2
110
Wantedly での Datadog 活用事例
bgpat
1
440
DevOps視点でAWS re:invent2024の新サービス・アプデを振り返ってみた
oshanqq
0
180
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
66
4.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Side Projects
sachag
452
42k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The Invisible Side of Design
smashingmag
298
50k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
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! ੵۃ࠾༻தͰ͢ʂ • όοΫΤϯυΤϯδχΞ • εϚʔτϑΥϯΤϯδχΞ • ϑϩϯτΤϯυΤϯδχΞ
• ػցֶशΤϯδχΞ • ΈࠐΈΤϯδχΞ