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

マイクロサービスバックエンドAPIのためのRESTとgRPC

660946c5788429ad71546d35e74a709b?s=47 disc99
March 27, 2017

 マイクロサービスバックエンドAPIのためのRESTとgRPC

660946c5788429ad71546d35e74a709b?s=128

disc99

March 27, 2017
Tweet

Transcript

  1. ϚΠΫϩαʔϏε όοΫΤϯυAPIͷͨΊͷ RESTͱgRPC #ShinjukuLT @disc99

  2. ΋͘͡ • ϚΠΫϩαʔϏε • RESTful APIʹΑΔઃܭ • gRPCʹΑΔઃܭ • ·ͱΊ

  3. ϚΠΫϩαʔϏε? • > ThoughtWorksࣾͷϚʔνϯɾϑΝ΢ ϥʔͱδΣʔϜεɾϧΠε͕࠷ॳʹఏএ ͨ͠ιϑτ΢ΣΞΞʔΩςΫνϟͰ͢ɻ
 ϞϊϦγοΫʢҰຕؠʣͳΞʔΩςΫ νϟΛɺϏδωεػೳʹԊͬͯෳ਺ͷখ ͍͞ʮϚΠΫϩαʔϏεʯʹ෼ׂ͠ɺͦ ΕΒΛ࿈ܞͤ͞ΔΞʔΩςΫνϟʹ͢Δ

    ͜ͱͰɺਝ଎ͳσϓϩΠɺ༏Εͨճ෮ੑ ΍εέʔϥϏϦςΟͱ͍ͬͨར఺Λ࣮ݱ ͠Α͏ͱ͢Δ΋ͷͰ͢ɻ ϚΠΫϩαʔϏεΞʔΩςΫνϟ(O'Reilly)
  4. ࠓճͷ࿩ Α͋͘ΔϚΠΫϩαʔϏε

  5. ࠓճͷ࿩ ͜ͷลΓ

  6. ࠓճͷ࿩ ͋Δ͍͸͜ͷลΓ

  7. ϚΠΫϩαʔϏεͷ࿈ܞ > In short, the microservice architectural style is an

    approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. => HTTPϦιʔεΛ࢖༻ͨܰ͠ྔAPIͰ௨৴ Microservices @Martin Fowler, @James Lewis https://martinfowler.com/articles/microservices.html
  8. RESTful API > RESTful APIͱ͸ɺWebγεςϜΛ֎෦͔Βར༻͢ΔͨΊͷϓϩάϥϜͷ ݺͼग़͠ن໿(API)ͷछྨͷҰͭͰɺRESTͱݺ͹ΕΔઃܭݪଇʹैͬͯࡦఆ ͞Εͨ΋ͷɻRESTͦͷ΋ͷ͸ద༻ൣғͷ޿͍ந৅తͳϞσϧ͕ͩɺҰൠత ʹ͸RESTͷߟ͑ํΛWeb APIʹద༻ͨ͠΋ͷΛRESTful APIͱݺΜͰ͍Δ

    
 > URL/URIͰ͢΂ͯͷϦιʔεΛҰҙʹࣝผ͠ɺηογϣϯ؅ཧ΍ঢ়ଶ؅ཧ ͳͲΛߦΘͳ͍(εςʔτϨε)ɻ 
 > Ϧιʔεͷૢ࡞͸HTTPϝιουʹΑͬͯࢦఆ͞Εɺ݁Ռ͸XML΍HTMLɺ JSONͳͲͰฦ͞ΕΔɻ·ͨɺॲཧ݁Ռ͸HTTPεςʔλείʔυͰ௨஌͢ Δͱ͍͏ݪଇؚ͕·ΕΔ͜ͱ΋͋Δɻ e-Words http://e-words.jp/w/RESTful_API.html * Ҏ߱͸লུͷͨΊRESTful APIΛREST APIͱهࡌ͠·͢
  9. ϙΠϯτ • Web APIͱͯ͠Α͘࢖ΘΕΔ • ϦιʔεΛURL/URIͰҰҙࣝผ • ૢ࡞: HTTPϝιου •

    ݁Ռ: XMLɺHTMLɺJSON + HTTPεςʔλείʔυ • ઃܭݪଇ:̋ ࢓༷:✕
  10. ✋APIΫΠζ

  11. Q1. όʔδϣχϯάઃܭ Q. APIͷόʔδϣχϯά͸Ͳ͏ߦ͏ʁ 1. URLʹຒΊࠐΉ 2. ύϥϝʔλͱͯ͠౉͢ 3. HTTP

    HeaderΛ࢖༻͢Δ 4. ͦͷଞ
  12. Q2. ߋ৽APIઃܭ Q. Ϣʔβͷ৘ใߋ৽Λߦ͏APIͷHTTPϝιου͸? 1. ߋ৽ܥ͸ੲͳ͕ΒͷPOSTҰے 2. REST APIͰߋ৽ͱݴ͑͹PUT 3.

    ࣌୅͸PATCH 4. ͦͷଞ
  13. Q3. ΤϥʔAPIઃܭ • Q. σʔλߋ৽࣌ʹDBͷഉଞϩοΫΤϥʔ͕ൃੜͨ࣌͠ͷεςʔλε ίʔυ͸? 1. DBΤϥʔͳͷͰɺγεςϜΤϥʔͱͯ͠500 2. γεςϜతʹ͸໰୊ແ͍ঢ়ଶͰൃੜ͢ΔͷͰϢʔβʹϦτϥΠ͠

    ͯ΋Β͏ͨΊ400+ϝοηʔδ 3. ϝοηʔδͰ͸ϓϩάϥϜతʹϋϯυϦϯά͠ʹ͍ͷͰ409ͳͲ 4. ͦͷଞ
  14. Q4. ϖʔδϯάAPIઃܭ • Q. ݕࡧ݁ՌͷϖʔδϯάΛͲ͏ߦ͏? 1. Ұ౓ʹશσʔλΛฦ͢ 2. ϖʔδ൪߸΍݅਺ͳͲΛϦΫΤετɺϨεϙϯε ʹؚΊΔ

    3. ϋΠύʔϝσΟΞ 4. ͦͷଞ
  15. A. ਖ਼ղ͸ͳ͍

  16. ͳͥ?

  17. ઃܭͱ૊৫ • ίϯ΢ΣΠͷ๏ଇ > γεςϜΛઃܭ͢Δ૊৫͸ɺͦͷ৘ใ఻ୡͷ ߏ଄Λ·ͶͨઃܭΛੜΈग़ͯ͠͠·͏
 ͨͱ͑͹ɺίϯύΠϥΛ̐νʔϜฤ੒Ͱ࡞Ε͹ɺ ̐ύεͷίϯύΠϥ͕࡞੒͞Δ => ઃܭ͸૊৫ʹΑͬͯࠨӈ͞ΕΔ

  18. ઃܭ͸ܳज़ > ϓϩάϥϚʔ͕2ਓ͍ͯɺ2ਓͱ ΋ઃܭʹ͍ͭͯڞ௨ͷߟ͑Λ࣋ͬ ͍ͯͨͱͯ͠΋ɺಉ͡໰୊Λղ͘ ࣌ʹղܾࡦͷίʔυ·Ͱಉ͡ʹͳ Δͱ͜͸·ͣ͋Γ·ͤΜɻ
 ࢤΛಉͨ͛ܳ͘͡͠ज़Ո͕ͨͪಛ ผͳΞϓϦέʔγϣϯΛ࡞Γ্͛ Δ࢓ࣄ৔Ͱ͢ɻ

    => ݸਓʹΑͬͯ΋ࠨӈ͞ΕΔ ΦϒδΣΫτࢦ޲ઃܭ࣮ફΨΠυ(ٕज़ධ࿦ࣾ)
  19. RESTfulͳઃܭͷҙຯ • Web APIʹ͓͍ͯҰఆͷઃܭݪଇΛఏڙ ɹ=> ݪଇ͚ͩͰ͸දݱ͖͠Εͳ͍৔߹΋͋Δ
 ɹ=> σʔλͱϦιʔεͷม׵͸Πϯϐʔμϯε ϛεϚονΛղফ͢ΔΑ͏ͳ࡞ۀ *1

    RESTͷΠϯϐʔμϯεϛεϚον https://togetter.com/li/14062
  20. ઃܭ͢ΔͨΊʹ͸ • REST APIΛ஌Δ • ཧղ౓͕௿͍ͱ֦ுੑɺอकੑ͕ѱ͍ • ؔ܎ऀͷίϯςΩετΛҰகͤ͞Δ • ίϯςΩετ͕ͣΕ͍ͯΔͱٞ࿦͕ൃࢄͯ͠ਐ·

    ͳ͍ • ΫϥΠΞϯτ͕֤API͝ͱʹ࢓༷ཧղ͕ඞཁʹͳΔ
  21. ࠷௿ݶͷ஌ࣝᶃ • جຊ஌ࣝɺΨΠυϥΠϯ • WebΛࢧ͑Δٕज़(ٕज़ධ࿦ࣾ) • RESTful WebαʔϏε(O'Reilly) • Web

    API: The Good Parts(O'Reilly) • Microsoft REST API Guidelines • https://github.com/Microsoft/api-guidelines/blob/master/ Guidelines.md • Google API Design Guide • https://cloud.google.com/apis/design/
  22. ࠷௿ݶͷ஌ࣝᶄ • ͦͷଞ࣌୅ͷྲྀΕ • GoogleɺMicrosoftɺAmazonɺTwitterɺFacebookɺ NetflixͳͲେखاۀͷAPIߏ੒ • Dropbox͸RESTΛ΍ΊɺAWSͷҰ෦API͸RESTΛ࠾༻͠ ͍ͯͳ͍ •

    https://medium.com/@voluntas/http-api-ͷઃܭํ ޲-7ccaca671d9d
  23. ͦͷ্Ͱ

  24. ઃܭͷϙΠϯτ • URLɺύϥϝʔλɺΤϥʔͳͲͷઃܭ • جຊతͳઃܭཧ࿦ɺ࣌୅ͷಈ޲ɺٕज़ελοΫɺ૊৫ؒͷؔ܎ੑ • ֤ݴޠ͝ͱͷม׵ϥΠϒϥϦɺαʔόɺΫϥΠΞϯτͷબఆɺઃܭɺӡ༻ݕ౼ • όϦσʔγϣϯ •

    ͢Δ or ͠ͳ͍͔: ͢ΔͳΒ֤ݴޠͷػೳൺֱɺϥΠϒϥϦɺӡ༻ݕ౼ • υΩϡϝϯτɺπʔϧ܈ • SwaggerɺAPI BlueprintɺRAMLɺJSON (Hyper)SchemeɺಠࣗܗࣜͳͲͷػೳൺֱɺ ϥΠϒϥϦɺӡ༻ݕ౼ • ೝূɺೝՄ • ࠷ۙͷಈ޲ɺ֤ݴޠͷػೳൺֱɺϥΠϒϥϦɺӡ༻ݕ౼ • ςετ • ϢχοτςετɺΠϯςάϨʔγϣϯςετɺE2EɺϞοΫɺConsumer-Driven Contracts • ΠϯϑϥɺωοτϫʔΫɺAPIήʔτ΢ΣΠɺ؂ࢹɺϩΪϯάɺτϨʔγϯά…
  25. ݁Ռ

  26. Α͘ݟΔޫܠ • ܁Γฦ͞ΕΔௐࠪɺݕ౼ɺٞ࿦ • ఆ·Βͳ͍ํ਑ • Ұ؏ੑͷͳ͍ΠϯλʔϑΣΠε • ௥͍͚ͭͳ͍࣌୅ͷมԽ (͍͍ҙຯͰಠࡋऀ͕͍Δ৔߹͸…)

  27. ୭΋͕௨Δಓ RESTful Web ΞϓϦͷઃܭϨϏϡʔͷ࿩ @t_wada https://www.slideshare.net/t_wada/restful-web-design-review

  28. ໨తͱखஈ • RESTʹΑΔઃܭ΍ཧ࿦͸खஈͰɺ໨తͰ͸ͳ͍ • ֎෦ެ։͢Δϑϩϯτ͸ผͱͯ͠ɺόοΫΤϯυ·Ͱ༏ΕͨRESTઃܭ ཧ࿦ʹൃల͕ͪ͠ • REST͸ҰఆͷݪଇΛ΋ͨΒ͢΋ͷͷɺͦΕͳΓͷࣗ༝౓͸࢒ΔͨΊɺ ຊ࣭Ͱ͸ͳ͍෦෼ʹ͕͔͔࣌ؒͬͯ͠·͏ •

    ඞવతʹؔ࿈͢ΔπʔϧνΣΠϯɺΤίγεςϜ਺ͱ඼࣭֨ࠩɺݕূ ࡞ۀ͕૿͑Δ • ઃܭ΍ࢥ૝ʹ౴͑͸ͳ͍ɺଞʹߟ͑ͳ͍ͱ͍͚ͳ͍͜ͱ͸ࢁ΄Ͳ͋Δ
  29. ຊ౰ʹඞཁͩͬͨ΋ͷ • αʔϏεͷΠϯλʔϑΣΠεఆٛ • ࣮ࡍͷREST APIͷఆٛ * REST API༏Εͨ΋ͷͰؒҧ͍ͬͯΔ༁Ͱ͸͋Γ·ͤΜ

  30. ຊ౰ʹඞཁͩͬͨ΋ͷ • αʔϏεͷΠϯλʔϑΣΠεఆٛ • ࣮ࡍͷREST APIͷఆٛ * REST API༏Εͨ΋ͷͰؒҧ͍ͬͯΔ༁Ͱ͸͋Γ·ͤΜ ຊདྷ͸ͪ͜Β͕͋Ε͹͍͍͸ͣ

  31. ͳͥREST APIͩͬͨͷ͔ • ϑϩϯτΤϯυͰ࢖ΘΕΔٕज़Λͦͷ··࢖͑Δ • ϒϥ΢β΍πʔϧ͔Β؆୯ʹѻ͑Δ • HTTPϝιουΛ࢖༻͢Δ͜ͱͰɺҰ؏ੑͷ͋Δૢ࡞Λߦ ͏͜ͱ͕Ͱ͖Δ •

    APIʹΑ͘࢖ΘΕΔJSON͸JavaScript͔Βѻ͍΍͍͢ => ϓϩάϥϜಉ࢜ͷ௨৴ͱͳΔόοΫΤϯυAPIͰ͸ඞਢ ཁ݅Ͱ͸ͳ͍
  32. ຊ౰ʹ REST API ͕ඞཁ?

  33. Web APIσβΠϯͷమଇ >Web APIͷΞʔΩςΫνϟελΠϧʹ ͸RESTɺRPCɺSOAPͳͲ͕͋Δ > RPCελΠϧͷಛ௃: 
 Remote Procedure

    Callͷ໊લͷ௨Γɺ ϦϞʔτϗετͷؔ਺Λݺͼग़͢Α͏ͳ ελΠϧɻҰൠతͳϓϩάϥϛϯάͷߟ ͑ํΛͦͷ··Ԡ༻͠΍͍͢ɻ > RPC͕޲͍͍ͯΔ৔߹: 
 ΫϥΠΞϯτ͕ࣾ಺ʹݶఆ͞Ε͍ͯͨΓɺ SDKͷΑ͏ͳܗͰඞͣϥοϓ͞Ε͍ͯΔ ৔߹
  34. Web APIσβΠϯͷమଇ >Web APIͷΞʔΩςΫνϟελΠϧʹ ͸RESTɺRPCɺSOAPͳͲ͕͋Δ > RPCελΠϧͷಛ௃: 
 Remote Procedure

    Callͷ໊લͷ௨Γɺ ϦϞʔτϗετͷؔ਺Λݺͼग़͢Α͏ͳ ελΠϧɻҰൠతͳϓϩάϥϛϯάͷߟ ͑ํΛͦͷ··Ԡ༻͠΍͍͢ɻ > RPC͕޲͍͍ͯΔ৔߹: 
 ΫϥΠΞϯτ͕ࣾ಺ʹݶఆ͞Ε͍ͯͨ ΓɺSDKͷΑ͏ͳܗͰඞͣϥοϓ͞Εͯ ͍Δ৔߹ ຊ౰ʹඞཁͩͬͨ΋ͷ ϚΠΫϩαʔϏεͷΑ͏ͳ؀ڥ
  35. Web APIσβΠϯͷమଇ >Web APIͷΞʔΩςΫνϟελΠϧʹ ͸RESTɺRPCɺSOAPͳͲ͕͋Δ > RPCελΠϧͷಛ௃: 
 Remote Procedure

    Callͷ໊લͷ௨Γɺ ϦϞʔτϗετͷؔ਺Λݺͼग़͢Α͏ͳ ελΠϧɻҰൠతͳϓϩάϥϛϯάͷߟ ͑ํΛͦͷ··Ԡ༻͠΍͍͢ɻ > RPC͕޲͍͍ͯΔ৔߹: 
 ΫϥΠΞϯτ͕ࣾ಺ʹݶఆ͞Ε͍ͯͨΓɺ SDKͷΑ͏ͳܗͰඞͣϥοϓ͞Ε͍ͯΔ ৔߹ gRPC (ޙड़)
  36. PRC? > ϓϩάϥϜ͔ΒผͷΞυϨε ۭؒʢ௨ৗɺڞ༗ωοτϫʔΫ ্ͷผͷίϯϐϡʔλ্ʣʹ͋ Δαϒϧʔνϯ΍खଓ͖Λ࣮ߦ ͢Δ͜ͱΛՄೳʹ͢Δٕज़
 > ϓϩάϥϚ͸ϩʔΧϧͳαϒ ϧʔνϯݺͼग़͠ͱجຊతʹಉ

    ͡ίʔυΛϦϞʔτݺͼग़͠ʹ ͍ͭͯ΋ߦ͏ Wikipedia https://ja.wikipedia.org/wiki/RPC
  37. ୅දతͳRPC • Java RMI • XML-RPC • JSON-RPC • Apache

    Thrift • gRPC
  38. ୅දతͳRPC • Java RMI • XML-RPC • JSON-RPC • Apache

    Thrift • gRPC ࠓճͷ࿩
  39. gRPCͱ͸ • Google͕ެ։ͨ͠RPCϑϨʔϜϫʔΫ • Google͕ࣾ಺Ͱ࢖༻͍ͯͨ͠RPCϑϨʔϜϫʔΫͷOSS൛ • Protocol Buffers *1ʹΑΓαʔϏεͷΠϯλʔϑΣΠεఆٛ •

    αʔόɺΫϥΠΞϯτࣗಈੜ੒ • ௨৴ϓϩτίϧ͕HTTP/2 • ߴ଎ • ैདྷܕͷϦΫΤετ/ϨεϙϯεܗࣜҎ֎ʹ୯ํ޲ɺ૒ํ޲ Streaming΋Մೳ *1. gRPCͷγϦΞϥΠβ͸ଞͷϑΥʔϚοτ΋αϙʔτ͍ͯ͠·͕͢ɺ͜ͷࢿྉͰ͸Protocol BuffersΛ࢖༻͢Δલఏ
  40. Protocol Buffers? • ߏ଄Խ͞ΕͨσʔλΛγϦΞϥΠζ ͢ΔͨΊͷݴޠඇґଘͳϓϥοτ ϑΥʔϜ • IDL(ΠϯλʔϑΣΠεఆٛݴޠ) ʹΑΓهड़ •

    ओཁͳݴޠ΁ͷιʔείʔυੜ੒ • ߴ଎ɺܰྔ • ޙํޓ׵ੑͷ͋ΔγϦΞϥΠζϑΥʔ Ϛοτ • IDLʹΑΔߏ଄ఆٛ • γϦΞϥΠζ • σγϦΞϥΠζ
  41. ઌਓʹֶͿ • Googleͷதͷσʔλ͸શͯProtocol Buffersʹ ͳ͍ͬͯΔ • ϩάɺDBʹೖΕΔσʔλɺBigDataͷύΠϓϥ Πϯʹ΋Protocol Buffers rebuild.fm#169

    @omo https://rebuild.fm/169/
  42. gRPC࠾༻ࣄྫ • ւ֎ • Google • Square • Netflix •

    CoreOS • Docker • Cisco • ࠃ಺ • ϝϧΧϦ • GRPCͷ࣮ફͱݱঢ়Ͱͷར఺ܽ఺ *1 • AbeamTV • AbeamTVʹ͓͚ΔMicroservices *2 • υϫϯΰ • Protocol Buffers *3 *1. https://speakerdeck.com/kazegusuri/go-conference-2016-spring *2. http://www.slideshare.net/RyotaNishio/abematvmicroservices-architecture *3. http://tayama0324.github.io/slides/20161127-kbkz-tech.html#/
  43. جຊతͳ։ൃͷྲྀΕ 1. αʔϏεؒͷΠϯλʔϑΣΠεఆٛ(IDL) 2. IDL͔ΒπʔϧͰ֤ݴޠͷιʔείʔυੜ੒(αʔόɺε λϒɺΠϯλʔϑΣΠεͳͲ) 3. ੜ੒͞ΕͨίʔυΛ࢖༻͠αʔόΛ࣮૷ 4. ੜ੒͞ΕͨίʔυΛ࢖༻͠ΫϥΠΞϯτΛ࣮૷

    5. ىಈ
  44. ΋͏গ͠ৄ͘͠

  45. gRPCʹΑΔAPIઃܭ • URLɺύϥϝʔλɺΤϥʔͳͲͷઃܭ • ΠϯλʔϑΣΠε৘ใͷυΩϡϝϯτɺπʔϧ܈ • ֤ݴޠ͝ͱͷύʔαϥΠϒϥϦɺαʔόɺΫϥΠΞϯτͷબ ఆɺઃܭ • όϦσʔγϣϯ

    • ೝূɺೝՄ • ςετ
  46. URLɾύϥϝʔλɾΤϥʔઃܭ • IDLΛ࢖༻͠ɺҰൠతͳϓϩάϥϛϯάͷΑ͏ʹ هड़ • ఆٛࡁΈߏ଄ • جຊܕ • repeatɺmapɺenum

    • messageɺstreamɺserviceɺnestͳͲ • Τϥʔ • ࢓༷ͱͯ͠ఆٛ *1 • ϥΠϒϥϦ૊ΈࠐΈ *2 *1. http://www.grpc.io/docs/guides/error.html *2. ex:Java) http://www.grpc.io/grpc-java/javadoc/io/grpc/Status.html
  47. αʔόɾΫϥΠΞϯτ • ֤ݴޠ͝ͱʹιʔείʔ υࣗಈੜ੒ • αʔό • ΫϥΠΞϯτ༻ελϒ • ϦΫΤετɺϨεϙϯ

    ε༻σʔλߏ଄
  48. υΩϡϝϯτ؅ཧɺπʔϧ • IDL͕ͦͷ··ΠϯλʔϑΣΠευΩϡϝϯτ • ؔ࿈ΤίγεςϜ • protoc-gen-doc: IDL͔ΒMarkdown, HTMLͳͲͷυΩϡϝϯτੜ੒*1 •

    grpc-gateway: gRPCαʔό͔ΒJSONϨεϙϯεΛฦͨ͢ΊͷϦόʔεϓϩ Ωγ*2 • polyglot: grpcͷCLIΫϥΠΞϯτ*3 => IDL͔Β։ൃ͢ΔελΠϧ͕֬ఆ͍ͯ͠ΔͨΊɺͦΕΛϕʔεͱͯ͠Τίγες Ϝ͕ߏங͠΍͍͢ => ۀ຿ݻ༗ͷπʔϧͳͲͰ΋ੜ੒͢ΔίʔυͷݴޠΛબ୒Ͱ͖ΔͨΊѻ͍΍͍͢ • *1. https://github.com/estan/protoc-gen-doc • *2. https://github.com/grpc-ecosystem/grpc-gateway • *3. https://github.com/grpc-ecosystem
  49. όϦσʔγϣϯ • ެࣜʹ͸ͳ͠(Protocol Buffers) • IDLͰఆٛͰ͖ΔόϦσʔγϣϯʹ͸ݶք͕͋Δ • ૬ؔόϦσʔγϣϯͳͲͷϩδοΫΛؚΉόϦσʔγϣϯʹ͸ධՁ͢Δ ͨΊͷॲཧܥ͕ඞཁ •

    ೖྗνΣοΫ/ϏδωεϩδοΫͷڥք൑அ͕೉͍͠ • ֤ݴޠɺαʔϏεؒΛލ͍ͩҰݩ؅ཧ͸࣮૷ϨϕϧͰ୼ͼ͕ੜ·Ε΍͢ ͍ • ϑϩϯτΤϯυͱҧͬͯɺ1จࣈೖྗ୯Ґͷଈ࣌௨஌ͳͲ͸ͳͯ͘΋Α͍ => ݱ࣌఺Ͱ͸IDLʹίϝϯτϕʔεͰهड़͢Δͷ͕ݱ࣮త?
  50. ೝূɾೝՄ • લఏͱͯ͠γϦΞϥΠζ͞Ε͍ͯΔͨΊ.proto ͕ͳ͍ͱσγϦΞϥΠζ͕ࠔ೉ • ެࣜͰSSL/TLSɺGoogle APIೝূରԠ • ಠࣗೝূ༻ͷ֦ுػߏ΋͋Γ

  51. ςετ • ੜ੒͞ΕΔίʔυΛ׆༻ʢ࣮૷ݴޠґଘ͋Γʣ • ΫϥΠΞϯτ • αʔό • ΠϯλʔϑΣΠε •

    ϞοΫ => ιʔείʔυੜ੒Λߦ͏ͨΊɺ࣮ࡍʹ࢖༻͢Δίʔυϕʔεͷςετ͕Մೳ • ςετʹϞοΫ͸ඞཁ͔ʁ • https://github.com/grpc/grpc-java/issues/ 1469#issuecomment-230852433
  52. Other Pros • ܰྔɺߴ଎ͳγϦΞϥΠζ௨৴ • σʔλߏ଄΍ݴޠɺ؀ڥʹ΋ґଘ͢Δ΋ͷͷɺଟ͘ͷ৔߹XML΍JSONΑ Γߴ଎ • ετϦʔϛϯάαϙʔτ •

    αʔόϓογϡ΍େ༰ྔͷ௨৴ͳͲ΋Մೳ • Protocol BuffersҎ֎ͷγϦΞϥΠζϑΥʔϚοτʹ΋ରԠ(JSONɺXMLͳͲ) • ΫϥΠΞϯτϩʔυόϥϯγϯά • ϔϧενΣοΫ
  53. Cons • ֶशίετ • RESTful APIઃܭɺӡ༻Λ໢ཏతʹཧղ͢Δͷʹൺ΂গͳ͍͕ɺ࢓༷ʹͦΕͳΓͷϘ ϦϡʔϜ => ॳظ౤ࢿ͸͋΋ͷͷɺͦΕΛ௒͑Ε͹RESTΑΓΑ͍ (ϝϧΧϦɺAbemaTV)

    • γϦΞϥΠζ͞Ε͍ͯΔͨΊJSONͷΑ͏ʹؾܰʹݺͼग़͠ɺσόοάͰ͖ͳ͍ => grpc-gatewayɺpolyglotͳͲͷ׆༻ => ֤ΞϓϦέʔγϣϯ಺ͰΠϯλʔηϓλʔΛ࢖͏ • ϒϥ΢β͔Β࢖͑ͳ͍ => ϚΠΫϩαʔϏεόοΫΤϯυͰ͸໰୊ͳ͍ => ࠓ͙͢ඞཁͰ͋Ε͹grpc-gatewayɺকདྷతʹ͸ϒϥ΢βରԠ*1ʹظ଴ • HTTP/2पΓͷΠϯϑϥߏங => Ϋϥ΢υ΍KubernetesͳͲϚωʔδυͳػೳͷ؀ڥ׆༻ *1. https://github.com/grpc/grpc-experiments/issues/159
  54. Note • gRPC͕ϕετͱ͸ݶΒͳ͍ɺࣺͯΔ֮ޛ΋ඞཁ • gRPCʹݶΒͣίΞϩδοΫ͔Βɺ֎෦ґଘΛऔΓআ͘ • DDDϨΠϠʔԽΞʔΩςΫνϟ + DIPɺϔΩαΰφ ϧɺΫϦʔϯΞʔΩςΫνϟͳͲ

    • ϑϩϯτΤϯυAPI(ϒϥ΢β޲͚)͸όοΫΤϯυͱ͸ผ ʹߟ͑Δ
  55. REST APIઃܭͱͷҧ͍ • جຊతʹαʔϏεؒͷΠϯλʔϑΣΠεఆٛ(IDL)Λ࠷ॳʹ࣮ࢪ
 => ݴޠʹඇґଘͰαʔϏεؒͷΠϯλʔϑΣΠε߹ҙΛߦ͏ελΠϧ
 => RESTͷݪଇɺΠϯϐʔμϯεϛεϚονղফͷͨΊͷཧ࿦ͳͲ͸ඞཁͳ͘ɺ௨ৗͷϓϩάϥϛϯά Ϟσϧʹ͍ۙ
 =>

    ܗࣜͷ౷Ұ͞ΕͨυΩϡϝϯτͱͯ͠΋׆༻Ͱ͖Δ • αʔόɺΫϥΠΞϯτࣗಈੜ੒͕جຊ
 => ݴޠ͝ͱͷϥΠϒϥϦબఆͳͲ͕ෆཁ
 => ௨৴෦෼ͷ࣮૷΋ෆཁ • Google͕։ൃͨ͠ͷ΋͋ΓɺϚΠΫϩαʔϏεʹඞཁͳػೳ͕ఆٛɺ૊ΈࠐΈͰ༻ҙ͞Ε͍ͯΔ • ΤϥʔɺೝূɺೝՄɺετϦʔϛϯάɺϩʔυόϥϯγϯάɺϔϧενΣοΫ… => αʔϏεؒ࿈ܞʹඞཁͳ࢓૊Έɺػೳͷଟ͕͘ఏڙ͞ΕΔɹɹ ɹ=> ػೳ࣮૷ʹूத͠΍͍͢
  56. ·ͱΊ • ϚΠΫϩαʔϏεͰ͸ैདྷͷγεςϜ಺ͷؔ਺ݺͼग़ͩͬͨ͠ॲཧ͕ɺωο τϫʔΫΛܦ༝ • ௨৴ʹ͸HTTPΛ༻͍ͨAPI͕Α͘࢖ΘΕΔ • RESTful API •

    े෼ͳφϨοδɺΤίγεςϜ • ϑϩϯτΤϯυͱͷ਌࿨ੑ • Ұఆͷݪଇͷఏڙ • gRPC • ϚΠΫϩαʔϏεʹٻΊΒΕΔ௨৴࢓༷ͷఏڙ • αʔϏεؒ࿈ܞʹඞཁͳ࣮૷ͷੜ੒ • େखاۀʹࢧ͑ΒΕͨ࠾༻࣮੷
  57. ։ൃʹඞཁͳͷ͸ ΠϯλʔϑΣΠεઃܭ ͚ͩͰ͸ͳ͍

  58. ࣌ؒ͸ݕ౼΍ٞ࿦Ͱ͸ͳ͘ υϝΠϯ࣮ݱͨΊʹ