$30 off During Our Annual Pro Sale. View Details »

GunosyでのMicroservicesの現状とGoの使いどころ

 GunosyでのMicroservicesの現状とGoの使いどころ

Gunosy.go#11での発表資料

y_matsuwitter

March 11, 2015
Tweet

More Decks by y_matsuwitter

Other Decks in Programming

Transcript

  1. GunosyͰͷ Microservisesͷݱঢ়ͱ Goͷ࢖͍Ͳ͜Ζ @y_matsuwitter

  2. ࣗݾ঺հ • ։ൃຊ෦ࣥߦ໾һࡶ༻໾ • iOS, Android, Infrastructure, Web • Golang෍ڭ໾

    • ਖ਼࠲ • ࠷ۙؾʹͳΔ΋ͷ: MQTT
  3. ࠷ۙίʔυॻ͚ͯ·ͤΜ…

  4. ࠓ೔ͷ࿩ • GunosyͰӡ༻͍ͯ͠ΔMicroservicesͷ࿩ • ͦͷதͰGoΛͲ͏࢖͍ͬͯΔ͔

  5. Microservices = খ͞ͳαʔϏεͷ૊Έ߹Θͤ

  6. What is microservices? • <=> Monolithic • ద੾ͳن໛ͷϏδωευϝΠϯ͝ͱʹ಺෦αʔϏεΛ෼ׂ • ΞϓϦέʔγϣϯଆ͔Β֤छAPIΛݺͼग़͢

    • αʔϏεʹ߹Θٕͤͨज़બఆΛ࣮ࢪ • SOAͷম͖௚͠
  7. Why microservices? • Ϗδωεʹ߹ΘͤͨνʔϜͷ෼ׂɾฤ੒ • খ͞ͳαʔϏεʹΑΔଐਓੑͷرബԽ • Ϗδωεཁٻʹର͢ΔॊೈͳରԠ • ͍Βͳ͍΋ͷΛࣺͯΒΕΔ

    ϞϊϦγοΫͳγεςϜͰ͸ɺϏδωε͕੒௕͢Δʹै͍վम ίετ͕૿Ճ͍ͯ͘͠
  8. ࣄྫ: Soundcloud • طଘͷϞϊϦγοΫ͕͋ͬͨ • ϦϑΝΫλϦϯάͷஈ֊ͰαʔϏεΛ෼ੳ • ϏδωευϝΠϯ͝ͱʹMicroserviceΛߏங • FinagleϕʔεͷRPCͰେྔͷJVM্ͷΞϓϦΛ݁߹

    • ͦͷ্Ͱ༷ʑͳݴޠΛӡ༻ ࢀߟ: Building Products at SoundCloud
  9. MicroservicesͷதͰੜ ͖ΔGo

  10. ͳͥGoͳͷ͔ • ֎෦ґଘͷͳ͍όΠφϦ • ܰྔ͔ͭϋΠύϑΥʔϚϯε • ڞ௨ϥΠϒϥϦ੾Γग़ָ͕͠

  11. GunosyͰͷ࿩

  12. None
  13. • άϊγʔͱ͍͏୯ҰͷχϡʔεΞϓϦ • ಺෦͸ϏδωευϝΠϯ͝ͱʹ෼ׂ • Platformߏ૝ʹΑΓ಺෦ͷϏδωευϝΠϯ͸ຖ݄̎ͭ΄Ͳ ૿͍͑ͯΔ

  14. None
  15. ࣾ಺Microserviceͷߏ੒ཁૉ • API༻HTTPαʔό • όονॲཧܥαʔό • ؅ཧը໘ • Πϯϑϥߏ੒ɾ؅ཧπʔϧ

  16. None
  17. APIαʔό • ༻ҙ͞ΕͨσʔλΛద੾ͳυϝΠϯϩδοΫʹͯฦ٫ • େ൒ͷAPI͕Golang੡

  18. APIαʔόɺ࢖͍ͬͯΔ΋ͷ • Kami ... WebFramework • mogi ... SQL stub

    Ϟσϧ૚ͳͲΛڞ༗ύοέʔδʹ੾Γग़͠ɺ࢖͍·Θ͢
  19. ύοέʔδߏ੒ • ϏδωευϝΠϯ͝ͱʹ1ϦϙδτϦ • ಺෦͸ߋʹࡉ͔͘෼͚ͨυϝΠϯ͝ͱʹύοέʔδΛ੾Δ example-service-1 ├── domain-1 ├── domain-2

    ├── main.go └── routes.go common-package ├── domain-1 ├── domain-2 └── main.go
  20. None
  21. όονॲཧ • ࣌ʹେྔͷσʔλΛɺAPIར༻΍KPIूܭͷͨΊʹར༻ • ෳ਺αʔόͰͷฒྻॲཧ͕ඞཁͳ৔໘΋ଟʑ

  22. όονॲཧ w/ Go • Go͸ฐࣾͷόονॲཧʹ͸ࠓͷͱ͜Ζ΄΅ར༻͞Εͣ • େ൒͸Python • ෳ਺αʔόʹ·͕ͨΔ΋ͷ͸Python +

    Celery • APIͱͷڞ௨ॲཧ͕͋Γɺ1ΠϯελϯεͰࡁΉॲཧͷΈGo • ʢCacheσʔλͷੜ੒ͳͲʣ
  23. None
  24. ؅ཧը໘ • σʔλεΩʔϚʹԠͯ͡ॊೈʹϑΥʔϜɾϦετΛੜ੒ɺॲ ཧ • ༷ʑͳόονॲཧΛΩοΫ͢Δ

  25. ؅ཧը໘ w/ Golang • ݴޠͷੑ࣭Ώ͑ɺॊೈͳϑΥʔϜੜ੒ɾӡ༻ʹ޲͍ͨπʔϧ ͸গͳ͍ • ࣾ಺ͷ؅ཧܥ͸Django͔Rails͕ओ • APIܦ༝ͰGoAPIΛؒ઀తʹར༻͢Δ͜ͱ͕ଟ͍

    • νϟοτͷॲཧͳͲ
  26. None
  27. Πϯϑϥ؅ཧܥ • ֤छΞϓϦέʔγϣϯͷσϓϩΠ • ϞχλϦϯά

  28. Πϯϑϥ w/ Go • ؅ཧܥπʔϧͰGo੡ͷ΋ͷ͸ଟ͍ • GoΛॻ͘͜ͱ͸গͳ͍ • શମͷߏ੒؅ཧ͸OpsworksͰ࣮ࢪ

  29. σϓϩΠ w/ Go • go build͠ɺOpsworksʹΑΓඞཁͳϑΝΠϧ܈ΛS3ܦ༝Ͱ ͹Β·͘ • Capistranoͷ΍Γํʹ͍ۙσϓϩΠϑϩʔ /path/to/service

    ├── shared │ ├── logs │ ├── tmp │ └── config ├── 20150306085540 │ ├── bin │ ├── public │ └── etc... ├── 20150306090324 └── current -> /path/to/service/releases/20150306090324
  30. ·ͱΊ • ϏδωευϝΠϯ͝ͱʹҰͭͷαʔϏε܈Λ࡞੒ • GoʹͯύϑΥʔϚϯεΛ֬อͭͭ͠υϝΠϯؒɾϨΠϠʔؒ Ͱ࿈ܞ • ݱঢ়Ͱ͸αʔϏεͷ௥Ճʹ΋༨༟͕ग़ͯ͘Δఔ౓ʹ

  31. Go + MicroservicesͰ αΫαΫαʔϏε֦େ

  32. Future works... • gRPCͷར༻ʹΑΔαʔόؒ݁߹ • ΠϕϯτۦಈܕMicroservices(Reactive Microservices) • ৽͍͠هࣄ͕௥Ճ͞Εͨ =>

    ֤αʔϏε͝ͱʹউखʹඞཁ ͳॲཧ։࢝