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
RustとWebAssemblyを使って高速な画像処理をWebアプリで実行しよう
rebonire626
0
110
フルカイテン株式会社 採用資料
fullkaiten
0
40k
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
3
270
신뢰할 수 있는 AI 검색 엔진을 만들기 위한 Liner의 여정
huffon
0
540
Postmanの日本市場におけるDevRel (的) 活動 / Postman's DevRelish activities in Japan
yokawasa
1
120
Railsで4GBのデカ動画ファイルのアップロードと配信、どう実現する?
asflash8
1
210
軽量DDDはもういらない! スタイルガイド本で OOPの実装パターンを学ぼう
panda_program
29
11k
AWS⼊社という選択肢、⾒えていますか
iwamot
2
1.1k
TinyGoを使ったVSCode拡張機能実装
askua
2
200
国土交通省 データコンペ参加者向け勉強会
takehikohashimoto
0
400
3次元点群データ「VIRTUAL SHIZUOKA』のオープンデータ化による恩恵と協働の未来/FOSS4G Japan 2024
kazz24s
0
130
20241108_CS_LLMMT
shigashiyama
0
250
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Designing the Hi-DPI Web
ddemaree
280
34k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
Music & Morning Musume
bryan
46
6.2k
Done Done
chrislema
181
16k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Thoughts on Productivity
jonyablonski
67
4.3k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
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! ੵۃ࠾༻தͰ͢ʂ • όοΫΤϯυΤϯδχΞ • εϚʔτϑΥϯΤϯδχΞ • ϑϩϯτΤϯυΤϯδχΞ
• ػցֶशΤϯδχΞ • ΈࠐΈΤϯδχΞ