Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Lightning Fast,
Self-Documenting
APIs
An overview of HTTP/2, gRPC and its advantages
Presented by: Mohammed Ali
○ What is HTTP/2?
○ Advantages of HTTP/2
○ What is gRPC?
○ Advantages of gRPC
○ Types of gRPC
○ Building a gRPC service
○ ...
HTTP/2
Source: http://www.http2demo.io/
What is HTTP/2? ● New version of HTTP.
● Derived from SPDY.
● Primarily focused on performance.
● Same core semantics as H...
Advantages of HTTP/2
Fully multiplexed Binary
Header Compression Server Push
Bidirectional Streaming
gRPC Remote
Procedure Calls
gRPC
gRPC Remote Procedure Calls
Uses HTTP/2
Based on protocol
buffers
Fast & Efficient
What is a Remote Procedure Call?
○ invo...
Advantages of gRPC
Multi Language and cross platform Protocol Buffers
Smaller and Faster Great support
DevX + Easy Setup
Types of RPC
Unary RPC
1. Login request.
2. Getting details of a single resource, education details for employeeNumber = 1...
Types of RPC
Client Streaming RPC
1. Streaming analytics data.
2. Syncing GPS data.
2
iOS Client
Python
Server
Stream of m...
Types of RPC
Server Streaming RPC
1. Fetching a list of items that need to displayed on the client
2. Propagation of new d...
Types of RPC
Bidirectional Streaming RPC
1. Syncing events between services.
2. Chat application
4
Go Client
Java
Server
S...
Building a gRPC service 101
Defining a .proto file
message Movie {
int64 id = 1;
string movie_name = 2;
string genre = 3;
...
Building a gRPC service 101
Design APIs2
a. Designing and writing your protocol buffer is one of the most important tasks ...
Building a gRPC service 101
Generate server and client stubs using protocol buffer compiler3
./gradlew build
python -m grp...
Building a gRPC service 101
Extend and implement the interfaces created in this .proto in the
server class
public class Mo...
gRPC in a polyglot micro-service architecture
Java
Client
NodeJS
Client
Python
Client
Java
Server
○ HTTP/2 and its advantages.
○ gRPC, its types and advantages.
○ Building a gRPC service
○ gRPC in a polyglot architecture...
Prochain SlideShare
Chargement dans…5
×

APIdays Helsinki 2019 - gRPC: Lightning Fast, Self-Documenting APIs with Mohammed Ali Chherawalla, Ninja Van

94 vues

Publié le

gRPC: Lightning Fast, Self-Documenting APIs, Mohammed Ali Chherawalla, Senior Software Engineer at Ninja Van

Publié dans : Technologie
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

APIdays Helsinki 2019 - gRPC: Lightning Fast, Self-Documenting APIs with Mohammed Ali Chherawalla, Ninja Van

  1. 1. Lightning Fast, Self-Documenting APIs An overview of HTTP/2, gRPC and its advantages Presented by: Mohammed Ali
  2. 2. ○ What is HTTP/2? ○ Advantages of HTTP/2 ○ What is gRPC? ○ Advantages of gRPC ○ Types of gRPC ○ Building a gRPC service ○ Demo of gRPC in a polyglot microservice architecture ○ Overview Contents
  3. 3. HTTP/2 Source: http://www.http2demo.io/
  4. 4. What is HTTP/2? ● New version of HTTP. ● Derived from SPDY. ● Primarily focused on performance. ● Same core semantics as HTTP/1.1. ● Results in better UX and faster client applications.
  5. 5. Advantages of HTTP/2 Fully multiplexed Binary Header Compression Server Push Bidirectional Streaming
  6. 6. gRPC Remote Procedure Calls gRPC
  7. 7. gRPC Remote Procedure Calls Uses HTTP/2 Based on protocol buffers Fast & Efficient What is a Remote Procedure Call? ○ invocation of a procedure / method from the client to perform an action on the server What is gRPC? ○ an open source RPC framework developed by google, that uses protobufs
  8. 8. Advantages of gRPC Multi Language and cross platform Protocol Buffers Smaller and Faster Great support DevX + Easy Setup
  9. 9. Types of RPC Unary RPC 1. Login request. 2. Getting details of a single resource, education details for employeeNumber = 10 1 Android Client Go Server Client makes a single request Server responds with a single message
  10. 10. Types of RPC Client Streaming RPC 1. Streaming analytics data. 2. Syncing GPS data. 2 iOS Client Python Server Stream of messages from client Single Message from server after all messages from the client are done
  11. 11. Types of RPC Server Streaming RPC 1. Fetching a list of items that need to displayed on the client 2. Propagation of new data 3 iOS Client Node.js Server Single message from client Streams of messages from server
  12. 12. Types of RPC Bidirectional Streaming RPC 1. Syncing events between services. 2. Chat application 4 Go Client Java Server Streams of messages from client Streams of messages from server
  13. 13. Building a gRPC service 101 Defining a .proto file message Movie { int64 id = 1; string movie_name = 2; string genre = 3; string client_id = 4; } a. Define the type of message that you want to send. b. Tags should not be overridden when writing new features 1
  14. 14. Building a gRPC service 101 Design APIs2 a. Designing and writing your protocol buffer is one of the most important tasks in gRPC b. For designing your API right, your protocol buffer needs to be written very well. service MovieLibrary { // Bidirectional streaming rpc to allow user to get and add movies to collection rpc getAndUpdateMovieLibrary (stream Movie) returns (stream Movie) {} // Client side streaming rpc to allow user to fetch movies from the server rpc listMovies (ListMoviesRequest) returns (stream Movie) {} }
  15. 15. Building a gRPC service 101 Generate server and client stubs using protocol buffer compiler3 ./gradlew build python -m grpc_tools.protoc -I=src/main/proto/ --python_out=clients/python-client/ --grpc_python_out=clients/python-client/ src/main/proto/movie.proto
  16. 16. Building a gRPC service 101 Extend and implement the interfaces created in this .proto in the server class public class MovieService extends MovieLibraryGrpc.MovieLibraryImplBase { @Override public StreamObserver<Movie> getAndUpdateMovieLibrary(StreamObserver<Movie> responseObserver) { // handle returning new stream and updating movie library here } @Override public void listMovies(ListMoviesRequest request, StreamObserver<Movie> responseObserver) { // handle returning new stream here } } 4
  17. 17. gRPC in a polyglot micro-service architecture Java Client NodeJS Client Python Client Java Server
  18. 18. ○ HTTP/2 and its advantages. ○ gRPC, its types and advantages. ○ Building a gRPC service ○ gRPC in a polyglot architecture Key Takeaways The code for the demo can be found at: https://github.com/alichherawalla/grpc-movie-client-server

×