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
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
生成AIが変えるデータ分析の全体像
ishikawa_satoru
0
170
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
日経電子版のStoreKit2フルリニューアル
shimastripe
1
140
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
Taming you application's environments
salaboy
0
190
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
420
『Firebase Dynamic Links終了に備える』 FlutterアプリでのAdjust導入とDeeplink最適化
techiro
0
130
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
AWS Lambdaと歩んだ“サーバーレス”と今後 #lambda_10years
yoshidashingo
1
180
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
330
Flutterによる 効率的なAndroid・iOS・Webアプリケーション開発の事例
recruitengineers
PRO
0
120
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Code Review Best Practice
trishagee
64
17k
Optimizing for Happiness
mojombo
376
70k
Practical Orchestrator
shlominoach
186
10k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Making Projects Easy
brettharned
115
5.9k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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! ੵۃ࠾༻தͰ͢ʂ • όοΫΤϯυΤϯδχΞ • εϚʔτϑΥϯΤϯδχΞ • ϑϩϯτΤϯυΤϯδχΞ
• ػցֶशΤϯδχΞ • ΈࠐΈΤϯδχΞ