Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Goをサービス投入して1年ほどの途中経過

Yoshi
May 30, 2018

 Goをサービス投入して1年ほどの途中経過

Yoshi

May 30, 2018
Tweet

More Decks by Yoshi

Other Decks in Programming

Transcript

  1. $PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 2 ໊લ: ߴڮ Ղ໻ (Takahashi Yoshihiro) Github:

    @yoshi42662 Twitter: @yoshi_xxxxxiiii # ॴଐ גࣜձࣾCluex (Ϋϧʔ) ࣗݾ঺հ # TODO Go޷͖ͳͷʹ࠷ۙ৮Ε͍ͯͳ͍ʂ # FIXME ࣾ಺Ͱ͋͝ͻ͛ۚ൅ͱݺ͹ΕΔ
  2. $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
  3. $PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 9 * ϑϧεΫϥονͰ։ൃ → αʔϏε౤ೖͯ͠1೥ऑ * ػೳ௥ՃͱϦϑΝΫλϦϯάΛͻͨ͢Β܁Γฦ͢

    * ϓογϡ௨஌ͷόονʹΰϧʔνϯΛಋೖ * ruby gemΛgoͰॻ͖௚͠ * ϧʔςΟϯάϨϕϧͰgo-cacheʹΑΔΩϟογϡ ࣾ಺ʹ͓͚Δ(Pݴޠͷಋೖࣄྫ ͜Ε·Ͱʹओʹ΍ͬͨ͜ͱ ΞϓϦAPIʹٻΊΒΕ͍ͯΔ͜ͱ * jsonΛ͍͔ʹ଎͘ΫϥΠΞϯτ΁ฦ͔͢
  4. $PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 10 ػೳతཁ݅ * SQL4ճ → ࣌ؒܭࢉ →

    json΁ม׵ → σʔλྔ͕ଟ͘300~600ms / req. ͔͔Δ * ೔෇͕มΘͬͨॠؒʹΩϟογϡΛexpire͢Δඞཁੑ * ࠷খߏ੒ͰՄೳͳݶΓͷ଎౓޲্Λ໨ࢦ͢ ΍ͬͨ͜ͱ * go-cacheΛಋೖ (·ͩΩϟογϡαʔόʔཱͯͨ͘ͳ͍) * routingϨϕϧͰͷΩϟογϡઃఆ͕Ͱ͖ΔΑ͏ʹͨ͠ * cacheΛอ࣋͢ΔࡍʹɺόΠφϦͰอଘ͢ΔΑ͏ʹมߋ * ฏۉ 30ms / req. ·Ͱվળ ࣾ಺ʹ͓͚Δ(Pݴޠͷಋೖࣄྫ
  5. $PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 11 ݁Ռ * ΫϥΠΞϯταΠυͷΤϯδχΞ͔Βۤ৘͕͘Δ → LoadingදࣔΛ࣮૷ͨ͠ͷʹLoading͕ग़ͳ͍ ࠓޙ

    * TickerΛ࢖ͬͯࣄલʹϨεϙϯεΛΩϟογϡʹ৐ͤΔ * singleflightͰಉ࣌ଟൃΞΫηεͷෛՙ؇࿨ ࣾ಺ʹ͓͚Δ(Pݴޠͷಋೖࣄྫ
  6. $PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 13 Ruby on RailsͷΞϓϦέʔγϣϯͷߴෛՙϩδοΫ → ruby࣮૷ʹΑΔtextlint(೔ຊޠͷจࣈྻॲཧ) →

    ཁ্݅ɺΩϟογϡΛ࢖༻Ͱ͖ͳ͍ → appαʔόʔͷworker͕ॲཧதͣͬͱ઎༗͞ΕΔ → 60 sec. / req. ࣾ಺ʹ͓͚Δ(Pݴޠͷಋೖࣄྫ × ϒϥ΢βଆͰॲཧͤ͞Δ × αʔόʔϨε (AWS lambda etc.)
  7. $PQZSJHIU© $MVFY$P -UE"MM3JHIUT3FTFSWFE 14 → ߴෛՙϩδοΫ෦෼ΛGo࣮૷ʹϦϓϨΠε → C༻όΠφϦʹม׵ͯ͠Railsଆ͔Βffiܦ༝Ͱcall → 1sec.

    / req. ·Ͱվળ (60ഒͷ଎౓޲্) ࣾ಺ʹ͓͚Δ(Pݴޠͷಋೖࣄྫ Go࣮૷ + ffi (gem) 3VCZPO3BJMT %# #JOBSZ (P࣮૷ ⒏ ⒏ ˞'PSFJHO'VODUJPO*OUFSGBDFͷུ