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をサービス投入して1年ほどの途中経過
Search
Yoshi
May 30, 2018
Programming
2
2.9k
Goをサービス投入して1年ほどの途中経過
Yoshi
May 30, 2018
Tweet
Share
More Decks by Yoshi
See All by Yoshi
Ruby on Railsな会社でGolangを導入した(する)話
yoshi42662
2
2.5k
Other Decks in Programming
See All in Programming
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
400
Jakarta EE meets AI
ivargrimstad
0
290
テストコード書いてみませんか?
onopon
2
230
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
130
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
580
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
130
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
240
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
130
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
EC2からECSへ 念願のコンテナ移行と巨大レガシーPHPアプリケーションの再構築
sumiyae
2
460
Go の GC の不得意な部分を克服したい
taiyow
3
860
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
970
Featured
See All Featured
For a Future-Friendly Web
brad_frost
175
9.4k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.9k
Gamification - CAS2011
davidbonilla
80
5.1k
Faster Mobile Websites
deanohume
305
30k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Why Our Code Smells
bkeepers
PRO
335
57k
Making the Leap to Tech Lead
cromwellryan
133
9k
Code Reviewing Like a Champion
maltzj
521
39k
Building Applications with DynamoDB
mza
91
6.1k
Transcript
1 golang.tokyo #15 Մೳੑʹ GoΛαʔϏεೖͯ͠ 1΄Ͳͷ్தܦա May 30, 2018 Yoshihiro
Takahashi Development Unit Cluex Co.,Ltd.
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 2 ໊લ: ߴڮ Ղ (Takahashi Yoshihiro) Github:
@yoshi42662 Twitter: @yoshi_xxxxxiiii # ॴଐ גࣜձࣾCluex (Ϋϧʔ) ࣗݾհ # TODO Go͖ͳͷʹ࠷ۙ৮Ε͍ͯͳ͍ʂ # FIXME ࣾͰ͋͝ͻ͛ۚͱݺΕΔ
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 3 ࣗݾհ
ࢠҭͯʹΉϚϚୡͷҝͷʮࢠҭͯ૯߹ϝσΟΞʯ ࢠҭͯʹؔ͢ΔΑ͋͘ΔΈ͔Βͪΐͬͱ໘ന͍ࢠҭͯΤϐιʔυɺ ·ͨ࢈්ਓՊݕࡧ·ͰΛൃ৴ɻ ใΛൃ৴͢Δ͚ͩͰͳ͘ɺ࢈්ਓՊখࣇՊΫνίϛɺ ·͓ͨࢠ༷࿈ΕͰར༻͍͓͢͠ళͷใͳͲɺ ͨͩͷϝσΟΞʹཹ·Βͳ͍ɺϚϚ͞Μ͕ʮຊʹཉ͍͠ใʯΛ ൃ৴͢Δࢠҭͯ૯߹ϝσΟΞͰ͢ɻ https://mamanoko.jp 4
ϚϚͷજࡏతͳΈΛղܾ͢ΔʮࢠҭͯΞϓϦʯ · · ͷ ͯ 5
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 6 Application Ruby on Rails 5.1.4 React
/ Redux / Webpack Infrastructure AWS Docker on ECS ٕज़ελοΫ · · ͷ ͯ ࢠҭͯʹΉϚϚୡͷҝͷʮࢠҭͯ૯߹ϝσΟΞʯ ϚϚͷજࡏతͳΈΛղܾ͢ΔʮࢠҭͯΞϓϦʯ iOS Swift Clean Architecture Android Kotlin Clean Architecture Architecture Components API Go / echo / GORM
7 ࣾʹ͓͚ΔGoݴޠͷಋೖࣄྫ 1 ωΠςΟϒΞϓϦ༻API
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 8 ࣾʹGopher͍ͳ͍ Goྺ1िؒఔͰ࣮։࢝ 3ϲ݄΄ͲͰॳϦϦʔε GoͷϥΠϒϥϦબͼ͍͠ ࣾʹ͓͚Δ(Pݴޠͷಋೖࣄྫ ωΠςΟϒΞϓϦ༻
APIΛϑϧεΫϥον Go / echo / gorm MVCΞʔΩςΫνϟ firebase / Postgres / Elasticsearch AWS ECS / Blue-Green Deployment ߏ
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 9 * ϑϧεΫϥονͰ։ൃ → αʔϏεೖͯ͠1ऑ * ػೳՃͱϦϑΝΫλϦϯάΛͻͨ͢Β܁Γฦ͢
* ϓογϡ௨ͷόονʹΰϧʔνϯΛಋೖ * ruby gemΛgoͰॻ͖͠ * ϧʔςΟϯάϨϕϧͰgo-cacheʹΑΔΩϟογϡ ࣾʹ͓͚Δ(Pݴޠͷಋೖࣄྫ ͜Ε·Ͱʹओʹͬͨ͜ͱ ΞϓϦAPIʹٻΊΒΕ͍ͯΔ͜ͱ * jsonΛ͍͔ʹ͘ΫϥΠΞϯτฦ͔͢
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 10 ػೳతཁ݅ * SQL4ճ → ࣌ؒܭࢉ →
jsonม → σʔλྔ͕ଟ͘300~600ms / req. ͔͔Δ * ͕มΘͬͨॠؒʹΩϟογϡΛexpire͢Δඞཁੑ * ࠷খߏͰՄೳͳݶΓͷ্Λࢦ͢ ͬͨ͜ͱ * go-cacheΛಋೖ (·ͩΩϟογϡαʔόʔཱͯͨ͘ͳ͍) * routingϨϕϧͰͷΩϟογϡઃఆ͕Ͱ͖ΔΑ͏ʹͨ͠ * cacheΛอ࣋͢ΔࡍʹɺόΠφϦͰอଘ͢ΔΑ͏ʹมߋ * ฏۉ 30ms / req. ·Ͱվળ ࣾʹ͓͚Δ(Pݴޠͷಋೖࣄྫ
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 11 ݁Ռ * ΫϥΠΞϯταΠυͷΤϯδχΞ͔Β͕ۤ͘Δ → LoadingදࣔΛ࣮ͨ͠ͷʹLoading͕ग़ͳ͍ ࠓޙ
* TickerΛͬͯࣄલʹϨεϙϯεΛΩϟογϡʹͤΔ * singleflightͰಉ࣌ଟൃΞΫηεͷෛՙ؇ ࣾʹ͓͚Δ(Pݴޠͷಋೖࣄྫ
12 ࣾʹ͓͚ΔGoݴޠͷಋೖࣄྫ 2 Go on Rails
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 13 Ruby on RailsͷΞϓϦέʔγϣϯͷߴෛՙϩδοΫ → ruby࣮ʹΑΔtextlint(ຊޠͷจࣈྻॲཧ) →
ཁ্݅ɺΩϟογϡΛ༻Ͱ͖ͳ͍ → appαʔόʔͷworker͕ॲཧதͣͬͱ༗͞ΕΔ → 60 sec. / req. ࣾʹ͓͚Δ(Pݴޠͷಋೖࣄྫ × ϒϥβଆͰॲཧͤ͞Δ × αʔόʔϨε (AWS lambda etc.)
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 14 → ߴෛՙϩδοΫ෦ΛGo࣮ʹϦϓϨΠε → C༻όΠφϦʹมͯ͠Railsଆ͔Βffiܦ༝Ͱcall → 1sec.
/ req. ·Ͱվળ (60ഒͷ্) ࣾʹ͓͚Δ(Pݴޠͷಋೖࣄྫ Go࣮ + ffi (gem) 3VCZPO3BJMT %# #JOBSZ (P࣮ ⒏ ⒏ ˞'PSFJHO'VODUJPO*OUFSGBDFͷུ
$PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 15 8F`SFIJSJOH ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠