Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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

9,196 views

Published on

REST and gRPC for microservices backend API

Published in: Technology
  • Hello! Get Your Professional Job-Winning Resume Here - Check our website! https://vk.cc/818RFv
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

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

  1. 1. API REST gRPC #ShinjukuLT @disc99
  2. 2. • • RESTful API • gRPC •
  3. 3. ? • > ThoughtWorks 
 (O'Reilly)
  4. 4. > 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
  5. 5. 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
  6. 6. • Web API • URL/URI • : HTTP • : XML HTML JSON + HTTP • : :✕
  7. 7. ✋API
  8. 8. Q1. Q. API 1. URL 2. 3. HTTP Header 4.
  9. 9. Q2. API Q. API HTTP ? 1. POST 2. REST API PUT 3. PATCH 4.
  10. 10. Q3. API • Q. DB ? 1. DB 500 2. 400+ 3. 409 4.
  11. 11. Q4. API • Q. ? 1. 2. 3. 4.
  12. 12. A.
  13. 13. ?
  14. 14. • > 
 =>
  15. 15. > 2 2 
 => ( )
  16. 16. RESTful • Web API => 
 => *1 REST https://togetter.com/li/14062
  17. 17. • REST API • • • • API
  18. 18. • • 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/
  19. 19. • • Google Microsoft Amazon Twitter Facebook Netflix API • Dropbox REST AWS API REST • https://medium.com/@voluntas/http-api- -7ccaca671d9d
  20. 20. • URL • • • • or : • • Swagger API Blueprint RAML JSON (Hyper)Scheme • • • • E2E Consumer-Driven Contracts • API …
  21. 21. • • • • ( …)
  22. 22. RESTful Web @t_wada https://www.slideshare.net/t_wada/restful-web-design-review
  23. 23. • REST • REST • REST • •
  24. 24. • • REST API * REST API
  25. 25. • • REST API * REST API
  26. 26. REST API • • • HTTP • API JSON JavaScript => API
  27. 27. REST API ?
  28. 28. Web API >Web API REST RPC SOAP > RPC : 
 Remote Procedure Call > RPC : 
 SDK
  29. 29. Web API >Web API REST RPC SOAP > RPC : 
 Remote Procedure Call > RPC : 
 SDK
  30. 30. Web API >Web API REST RPC SOAP > RPC : 
 Remote Procedure Call > RPC : 
 SDK gRPC ( )
  31. 31. PRC? > 
 > Wikipedia https://ja.wikipedia.org/wiki/RPC
  32. 32. RPC • Java RMI • XML-RPC • JSON-RPC • Apache Thrift • gRPC
  33. 33. RPC • Java RMI • XML-RPC • JSON-RPC • Apache Thrift • gRPC
  34. 34. gRPC • Google RPC • Google RPC OSS • Protocol Buffers *1 • • HTTP/2 • • / Streaming *1. gRPC Protocol Buffers
  35. 35. Protocol Buffers? • • IDL( ) • • • • IDL • •
  36. 36. • Google Protocol Buffers • DB BigData Protocol Buffers rebuild.fm#169 @omo https://rebuild.fm/169/
  37. 37. 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#/
  38. 38. 1. (IDL) 2. IDL ( ) 3. 4. 5.
  39. 39. gRPC API • URL • • • • •
  40. 40. 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
  41. 41. • • • •
  42. 42. • 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
  43. 43. • (Protocol Buffers) • IDL • • / • • 1 => IDL ?
  44. 44. • .proto • SSL/TLS Google API •
  45. 45. • • • • • => • • https://github.com/grpc/grpc-java/issues/ 1469#issuecomment-230852433
  46. 46. Other Pros • • XML JSON • • • Protocol Buffers (JSON XML ) • •
  47. 47. Cons • • RESTful API => REST ( AbemaTV) • JSON => grpc-gateway polyglot => • => => grpc-gateway *1 • HTTP/2 => Kubernetes *1. https://github.com/grpc/grpc-experiments/issues/159
  48. 48. Note • gRPC • gRPC • DDD + DIP • API( )
  49. 49. REST API • (IDL) 
 => 
 => REST 
 => • 
 => 
 => • Google • … => =>
  50. 50. • • HTTP API • RESTful API • • • • gRPC • • •

×