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

Introduction gRPC

d-kuro
December 14, 2018

Introduction gRPC

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

d-kuro

December 14, 2018
Tweet

More Decks by d-kuro

Other Decks in Programming

Transcript

  1. 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)
  2. 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)
  3. How to use Protocol Buffers in gRPC from: [Go Quick

    Start](https://grpc.io/docs/quickstart/go.html)
  4. 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)
  5. How to use Protocol Buffers in gRPC from: [Go Quick

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

    Start](https://grpc.io/docs/quickstart/go.html)
  7. Advantage of gRPC • Single Source of Truth ͷ࣮ݱ •

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

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

    ΛՃ͑Δͱ REST ͱ gPRC ͷΫϥΠΞϯτΛ ஥հ͢Δ Golang ͷίʔυ͕ੜ੒͞ΕΔ • Swagger ΛδΣωϨʔτ͢Δ͜ͱ͕Ͱ͖Δ from: [grpc-ecosystem/grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway)
  11. 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/)
  12. 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 ΛࠓޙͷϩʔυϚοϓͱͯ͠ݕ౼தΒ͍͠
  13. 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/)