Introduction gRPC

Cad656ed619672b702191833dc819943?s=47 d-kuro
December 14, 2018

Introduction gRPC

18/12/14 - The World Café - Classmethod, Inc.
Lightning Talks

Cad656ed619672b702191833dc819943?s=128

d-kuro

December 14, 2018
Tweet

Transcript

  1. 5෼࿮ LT ͰΘ͔Δ(Θ͔Βͳ͍) 18/12/14 - The World Café - Classmethod,

    Inc. Dai Kurosawa / @ponde_m
  2. Introduce

  3. What is

  4. What is gRPC ? • Google ͕ެ։ͨ͠ RPC ͷϑϨʔϜϫʔΫ •

    Protocol Buffers ͰαʔϏεͷΠϯλϑΣʔεΛఆ ٛͯ͠ Server, Client ͷίʔυΛࣗಈͰੜ੒Ͱ͖Δ • Protocol Buffers ͸σϑΥϧτͰͦΕҎ֎ͷσʔλϑΥʔϚοτ΋͋Δ • HTTP/2 Λ࢖༻ͯ͠௨৴, stream ͳͲ΋Ͱ͖Δ from: [What is gRPC?](https://grpc.io/docs/guides/index.html)
  5. What is gRPC ? • Google ͕ެ։ͨ͠ RPC ͷϑϨʔϜϫʔΫ •

    Protocol Buffers ͰαʔϏεͷΠϯλϑΣʔεΛఆ ٛͯ͠ Server, Client ͷίʔυΛࣗಈͰੜ੒Ͱ͖Δ • Protocol Buffers ͸σϑΥϧτͰͦΕҎ֎ͷσʔλϑΥʔϚοτ΋͋Δ • HTTP/2 Λ࢖༻ͯ͠௨৴, stream ͳͲ΋Ͱ͖Δ from: [What is gRPC?](https://grpc.io/docs/guides/index.html)
  6. Protocol Buffers ??


  7. (͕࣌ؒͳ͍ͷͰ) ோΊΔ͚ͩͰ ͳΜͱͳ͘Θ͔Δ Protocol Buffers ͷ࢖͍ํ

  8. How to use Protocol Buffers in gRPC from: [Go Quick

    Start](https://grpc.io/docs/quickstart/go.html)
  9. How to use Protocol Buffers in gRPC from: [Go Quick

    Start](https://grpc.io/docs/quickstart/go.html) • protoc ͱ͍͏ίϚϯυͰίϯύΠϧ͢Δͱ֤ݴޠ ͷίʔυΛδΣωϨʔτͰ͖Δ • ରԠݴޠ͸͍ͬͺ͍ • from: [API Reference | Protocol Buffers]
 (https://developers.google.com/protocol-buffers/docs/reference/overview)
  10. How to use Protocol Buffers in gRPC from: [Go Quick

    Start](https://grpc.io/docs/quickstart/go.html)
  11. How to use Protocol Buffers in gRPC from: [Go Quick

    Start](https://grpc.io/docs/quickstart/go.html)
  12. What is gRPC ? from: [What is gRPC?](https://grpc.io/docs/guides/index.html) • ਤʹ͢Δͱ͜Μͳײ͡

  13. ׬શʹཧղͨ͠ ʕ◔ϖ◔ʔ͜͜·Ͱ 2 ෼͘Β͍

  14. Λ࢖͏ͱԿ͕خ͍͠ͷ ?

  15. Advantage of gRPC • Single Source of Truth ͷ࣮ݱ •

    ΠϯλϑΣʔε͸શͯ protobufs ʹఆٛ͢Δ • protobufs = ׬શͳυΩϡϝϯτ • ܕ෇΋͞ΕΔ • ϧʔϧΛकΕ͹લํޓ׵, ޙํޓ׵ʹ΋ରԠͰ͖Δ
 (https://developers.google.com/protocol-buffers/docs/proto3#updating) • ͲͪΒ͔ͱ͍͑͹ protobufs Λ࢖͏͜ͱʹΑΔخ͠͞ • Protobufs ͔ΒίʔυΛδΣωϨʔτͯ͠։ൃΛߦ͏ • υΩϡϝϯτʹهࡌ࿙Ε͕͋ͬͯ…… Έ͍ͨͳͷ͔Βղ์͞ΕΔ • REST API ઃܭ͔Β΋ղ์
  16. Advantage of gRPC • HTTP/2 ͔ΒಘΒΕΔԸܙ • ߴύϑΥʔϚϯε • HTTP/1

    ͷςΩετϓϩτίϧ͔ΒόΠφϦϓϩτίϧʹ • సૹ͢Δσʔλྔ͕খ͘͞ͳΔ • ߴ଎ͳσʔλղੳ • 1ͭͷ TCP ઀ଓʹରͯ͠ଟॏϦΫΤετΛૹΔ͜ͱ͕Ͱ͖Δ • ίωΫγϣϯཱ֬ͷΦʔόϔου͕খ͘͞ͳΔ • ૒ํ޲ετϦʔϛϯά • GCP ͷ API ͱ͔ͩͱ gRPC ͕׆༻͞Ε͍ͯͨΓ͢Δ • [gRPC Λհͨ͠ Cloud Pub/Sub: ֓ཁ]
 (https://cloud.google.com/pubsub/grpc-overview?hl=ja)
  17. Ͱ΋͍͍͜ͱ͹͔ΓͰ͸ ͳ͍ΜͰ͠ΐ͏ʁ

  18. Disadvantage of gRPC • gRPC ͷ API ͸ REST ͷ

    API ͱͯ͠ίʔϧͰ͖ͳ͍ • curl ͢ΒͰ͖ͳ͍ • ϑϩϯτΤϯυ͔ΒݺͿʹ͸……? • gRPC ͸ HTTP/2 ͕લఏ • ϩʔυόϥϯγϯάͳͲΛߟ͑ͳ͍ͱ͍͚ͳ͍ • ALB ͷ಺෦௨৴͸ HTTP/2 ඇରԠ • CLB ͩͱ L4 ϨΠϠͷϩʔυόϥϯγϯάʹͳͬͯ͠·͏
  19. grpc-gateway • HTTP/1.1 ͷ API ΛఏڙͰ͖ΔϦόʔεϓϩΩγ • protobufs ʹ option

    ΛՃ͑Δͱ REST ͱ gPRC ͷΫϥΠΞϯτΛ ஥հ͢Δ Golang ͷίʔυ͕ੜ੒͞ΕΔ • Swagger ΛδΣωϨʔτ͢Δ͜ͱ͕Ͱ͖Δ from: [grpc-ecosystem/grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway)
  20. gRPC-Web • gRPC ͷΫϥΠΞϯτ͕ϒϥ΢βͰಈ͘ • protobufs ͔Β JavaScript ͷΫϥΠΞϯτΛδΣωϨʔτ •

    CNCF ͕ GA Λൃදͯͨ͠ from: [gRPC-Web is going GA](https://www.cncf.io/blog/2018/10/24/grpc-web-is-going-ga/)
  21. gRPC-Web • ͓΍…… ʁ from: [gRPC-Web is going GA](https://www.cncf.io/blog/2018/10/24/grpc-web-is-going-ga/)

  22. service proxy …… ?

  23. gRPC-Web from: [Envoy and gRPC-Web: a fresh new alternative to

    REST]
 (https://blog.envoyproxy.io/envoy-and-grpc-web-a-fresh-new-alternative-to-rest-6504ce7eb880) • ݱ࣮͸͜͏ • Local Proxy ΛࠓޙͷϩʔυϚοϓͱͯ͠ݕ౼தΒ͍͠
  24. gRPC-Web from: [ϑϩϯτΤϯυΤϯδχΞ΋஌͓͖͍ͬͯͨgRPC]
 (https://speakerdeck.com/suusan2go/hurontoendoenziniamozhi-tuteokitaigrpc?slide=25) • ͜ͷੈքʹͳͬͯ΄͍͠

  25. gRPC Load Balancing • HTTP/2 ͸1ͭͷίωΫγϣϯͰෳ਺ͷϦΫΤετΛૹΔ • L4 ϨΠϠͰϩʔυόϥϯγϯάΛߦ͏ͱίωΫγϣϯ͕੾அ͞ΕΔ·Ͱಉ͡αʔό ʹϦΫΤετΛૹͬͯ͠·͏

    • HTTP/2 ʹରԠͨ͠ proxy ͕ඞཁ from: [gRPC Load Balancing on Kubernetes without Tears]
 (https://kubernetes.io/blog/2018/11/07/grpc-load-balancing-on-kubernetes-without-tears/)
  26. gRPC Load Balancing • ϦΫϧʔτ͞Μͷϒϩά͕ΊͬͪΌΑ͔ͬͨ from: [EnvoyͱAmazon ECS Service DiscoveryΛར༻ͨ͠gRPCͷෛՙ෼ࢄ]


    (https://tech.recruit-mp.co.jp/infrastructure/post-17098/)
  27. ·ͱΊ • gPRC ͸͍͍ͧ • Ͱ΋Կ΋ߟ͑ͣʹ࠾༻Ͱ͖Δ΋ͷͰ͸ͳ͘ɺ৭ʑ ߟྀ͠ͳ͚Ε͹ͳΒͳ͍఺͸ଟʑ͋ΔͷͰ͔ͬ͠ Γͱௐࠪ, ݕ౼্ͨ͠Ͱ࠾༻͠Α͏ •

    gRPC ͷࠓޙʹ͝ظ଴͍ͩ͘͞
  28. Enjoy gRPC :)