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
AI長期記憶システム構築のための LLMマルチエージェントの取り組み / Awarefy-LLM-Multi-Agent
iktakahiro
1
240
コンテンツを支える 若手ゲームクリエイターの アートディレクションの事例紹介 / cagamefi-game
cyberagentdevelopers
PRO
1
140
いろんなものと両立する Kaggleの向き合い方
go5paopao
1
300
AWS reInvent 2024 関西組 事前勉強会
shinyayamada
0
130
コンテナのトラブルシューティング目線から AWS SAW についてしゃべってみる
kazzpapa3
1
120
生成AIとAWS CDKで実現! 自社ブログレビューの効率化
ymae
2
410
AWS CDKでデータリストアの運用、どのように設計する?~Aurora・EFSの実践事例を紹介~/aws-cdk-data-restore-aurora-efs
mhrtech
4
770
「 SharePoint 難しい」ってよく聞くけど、そんなに言うなら8歳の息子に試してもらった
taichinakamura
2
760
Product Engineer Night #6プロダクトエンジニアを育む仕組み・施策
hacomono
PRO
1
510
Commitment vs Harrisonism - Keynote for Scrum Niseko 2024
miholovesq
6
1.4k
DynamoDBの"Replacement"時にデータが消されないようにCustom Resource Provider Frameworkでカスタムリソース作ってみた件
diggymo
0
100
IDOLY PRIDEのバックエンドリーダーになって2年半取り組んできたこと / idoly-pride-knowledge
cyberagentdevelopers
PRO
2
110
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
800
Practical Orchestrator
shlominoach
186
10k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
Measuring & Analyzing Core Web Vitals
bluesmoon
2
51
The Cost Of JavaScript in 2023
addyosmani
45
6.6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
330
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Writing Fast Ruby
sferik
626
61k
Documentation Writing (for coders)
carmenintech
65
4.4k
Become a Pro
speakerdeck
PRO
24
5k
Teambox: Starting and Learning
jrom
132
8.7k
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! ੵۃ࠾༻தͰ͢ʂ • όοΫΤϯυΤϯδχΞ • εϚʔτϑΥϯΤϯδχΞ • ϑϩϯτΤϯυΤϯδχΞ
• ػցֶशΤϯδχΞ • ΈࠐΈΤϯδχΞ