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.
OpenAPI and gRPC Side-by-Side
Tim Burks
Google, Inc.
I love APIs.
I’m talking about Networked APIs.
Application Programming Interfaces that operate across a
network of computers. They comm...
The OpenAPI Specification
Industry standard format for describing REST APIs.
Originally designed for documentation, now wi...
OpenAPI is owned by the Linux Foundation
OpenAPI Adoption
gRPC
Open-Source messaging system based on Google’s internal API architecture.
Used for code and documentation generation,...
gRPC is owned by the Cloud Native Computing Foundation
gRPC Adoption
Microservices: in data centres
Streaming telemetry from network devices
Client Server communication/Internal...
What is an API methodology?
What is an API methodology?
A collection of tools and practices for building
and using networked services.
in depth
OpenAPI
API Description Language
JSON/YAML-based description format
● Easy for humans to read and write.
● Easy to import ...
OpenAPI
API Transport Mechanism
HTTP/REST
OpenAPI
Data Representation Format
JSON (and more)
OpenAPI
Code Generation
● swagger-codegen (Open source, Smartbear + community)
○ 70+ targets
○ First commit: July 6, 2011
...
swagger-codegen often isn’t used “out of the box”:
“Generating client libraries involves customizing the provided language...
Monolithic code generators are hard.
● Long build times: changing one target requires rebuilding everything.
● Long test t...
Meet developers where they are.
in depth
gRPC
Transport Mechanism
Client → Server
Server → Client
Initial
Metadata
MsgMsg
End of
Stream
Status & Trailing
Metadata
...
gRPC
Data Representation Format
Protocol Buffers, streams of bytes in a simple format:
[field_number<<3 + wire_type] [leng...
gRPC
API Description Format
package echo;
message EchoRequest {
string text = 1;
}
message EchoResponse {
string text = 1;...
gRPC
Code Generation
$ protoc echo.proto -o echo.out --swift_out=.
$ which protoc-gen-swift
../bin/protoc-gen-swift
$ more...
Why does protoc have a plug-in architecture?
● Fast build times: changing one target only requires rebuilding its plugin.
...
Cross-Language Interoperability
Java
Service
Python
Service
GoLang
Service
C++
Service
gRPC
Service
gRPC
Stub
gRPC
Stub
gR...
Build a gRPC service, get a free REST API!
Highest performance and quality.
Meet developers
where they are.
Highest performance
and quality.
Improve OpenAPI with strongly typed
representations, high-quality code
generation, and commitment to
methodology.
Improve gRPC with dynamic modeling,
lighter-weight infrastructure, and
simpler tooling.
HOW YOU CAN HELP
1. Stop writing interface code by hand.
2. Stop writing interface code by hand.
3. Stop writing interface code by hand.
4. Mind your API methodology.
5. Develop and use API style guides.
6. Use OpenAPI or gRPC.
OpenAPI and gRPC Side by-Side
OpenAPI and gRPC Side by-Side
Upcoming SlideShare
Loading in …5
×

OpenAPI and gRPC Side by-Side

1,898 views

Published on

Spend some time working with OpenAPI and gRPC and you’ll notice that these two technologies have a lot in common. Both are open source efforts, both describe APIs, and both promise better experiences for API producers and consumers. So why do we need both? If we do, what value does each provide? What can each project learn from the other? We’ll bring the two together for a side-by-side comparison and pose answers to these and other questions about two API methodologies that will do much to influence the future of networked APIs.

Published in: Software

OpenAPI and gRPC Side by-Side

  1. 1. OpenAPI and gRPC Side-by-Side Tim Burks Google, Inc.
  2. 2. I love APIs.
  3. 3. I’m talking about Networked APIs. Application Programming Interfaces that operate across a network of computers. They communicate using network protocols including HTTP, and are frequently produced by different organizations than the ones that consume them. Google API Design Guide: Glossary
  4. 4. The OpenAPI Specification Industry standard format for describing REST APIs. Originally designed for documentation, now with many other applications: API authoring, validation, documentation, analysis, search, testing, mocking, management, code generation.
  5. 5. OpenAPI is owned by the Linux Foundation
  6. 6. OpenAPI Adoption
  7. 7. gRPC Open-Source messaging system based on Google’s internal API architecture. Used for code and documentation generation, API management, and support services for APIs and microservices running at very large scale.
  8. 8. gRPC is owned by the Cloud Native Computing Foundation
  9. 9. gRPC Adoption Microservices: in data centres Streaming telemetry from network devices Client Server communication/Internal APIs Mobile Apps
  10. 10. What is an API methodology?
  11. 11. What is an API methodology? A collection of tools and practices for building and using networked services.
  12. 12. in depth
  13. 13. OpenAPI API Description Language JSON/YAML-based description format ● Easy for humans to read and write. ● Easy to import into most programming languages. ● Can be tedious in strongly-typed languages.
  14. 14. OpenAPI API Transport Mechanism HTTP/REST
  15. 15. OpenAPI Data Representation Format JSON (and more)
  16. 16. OpenAPI Code Generation ● swagger-codegen (Open source, Smartbear + community) ○ 70+ targets ○ First commit: July 6, 2011 ○ Used by Lyft and Square to generate SDKs ● AutoRest (Open source, Microsoft) ● oas-nodegen (Open source, Capital One) ● APIMatic (Proprietary, APIMatic) more?
  17. 17. swagger-codegen often isn’t used “out of the box”: “Generating client libraries involves customizing the provided language-specific templates… The amount of modification each template needs varies by language and we’re looking forward to working with the Swagger Codegen community to share our refinements.” Val Polouchkine, Lyft “...Swagger Codegen is a pretty active project. If you don’t check in your templates, things are gonna break unexpectedly because Swagger Codegen just uses the latest and greatest templates that are out there. So if you don’t sort of manually make sure that those things work, you’re gonna have an issue there.” Tristan Sokol, Square
  18. 18. Monolithic code generators are hard. ● Long build times: changing one target requires rebuilding everything. ● Long test times: new builds must be tested for every target language. ● For stability, teams may prefer to archive their own generator builds. ● Forks will abound. ● Quality is uneven. ● Versioning is hard. ● Complexity and potentially unfamiliar build systems deter contributors.
  19. 19. Meet developers where they are.
  20. 20. in depth
  21. 21. gRPC Transport Mechanism Client → Server Server → Client Initial Metadata MsgMsg End of Stream Status & Trailing Metadata Initial Metadata MsgMsg Msg HTTP/2
  22. 22. gRPC Data Representation Format Protocol Buffers, streams of bytes in a simple format: [field_number<<3 + wire_type] [length if necessary] [data]... $ hexdump /tmp/request.bin 0000000 0a 05 68 65 6c 6c 6f 0a is “0000 1010”, so field_number = 1 and wire_type = 2
  23. 23. gRPC API Description Format package echo; message EchoRequest { string text = 1; } message EchoResponse { string text = 1; } service Echo { rpc Get(EchoRequest) returns (EchoResponse) {} rpc Update(stream EchoRequest) returns (stream EchoResponse) {} }
  24. 24. gRPC Code Generation $ protoc echo.proto -o echo.out --swift_out=. $ which protoc-gen-swift ../bin/protoc-gen-swift $ more echo.pb.swift // DO NOT EDIT. // // Generated by the Swift generator plugin... // Source: echo.proto ...
  25. 25. Why does protoc have a plug-in architecture? ● Fast build times: changing one target only requires rebuilding its plugin. ● Fast test times: new builds need only be tested for the affected targets. ● For stability, teams can archive their own protoc and plugin builds. ● New plugins can abound. ● Separately-maintained plugins can offer different maturity levels. ● Separately-maintained plugins can be appropriately versioned. ● Separately-maintained plugins can be in languages that contributors prefer.
  26. 26. Cross-Language Interoperability Java Service Python Service GoLang Service C++ Service gRPC Service gRPC Stub gRPC Stub gRPC Stub gRPC Stub gRPC Service gRPC Service gRPC Service gRPC Stub
  27. 27. Build a gRPC service, get a free REST API!
  28. 28. Highest performance and quality.
  29. 29. Meet developers where they are. Highest performance and quality.
  30. 30. Improve OpenAPI with strongly typed representations, high-quality code generation, and commitment to methodology.
  31. 31. Improve gRPC with dynamic modeling, lighter-weight infrastructure, and simpler tooling.
  32. 32. HOW YOU CAN HELP
  33. 33. 1. Stop writing interface code by hand.
  34. 34. 2. Stop writing interface code by hand.
  35. 35. 3. Stop writing interface code by hand.
  36. 36. 4. Mind your API methodology.
  37. 37. 5. Develop and use API style guides.
  38. 38. 6. Use OpenAPI or gRPC.

×