Slide 1

Slide 1 text

gRPC or REST

Slide 2

Slide 2 text

Agenda ❖ API, Types and Specifications. ❖ What is REST? ❖ Disadvantages of REST. ❖ What is gRPC? ❖ Advantages of gRPC.

Slide 3

Slide 3 text

What is an API?

Slide 4

Slide 4 text

Whats is an API? ❖ API stands for Application Programming Interface. ❖ Acts as a communication bridge between two systems. ❖ Enables software components to interact seamlessly. ➢ Example: Mobile app requesting weather data from a server.

Slide 5

Slide 5 text

Types of APIs ❖ Web APIs: Interact over the internet (e.g., REST, gRPC). ❖ Library APIs: Access pre-built code libraries. ❖ OS APIs: Enable interaction with OS features. ❖ Hardware APIs: Interface with physical devices. ➢ Example: Mobile app requesting weather data from a server.

Slide 6

Slide 6 text

API Specification ❖ Definition: A document that describes how to interact with an API. ❖ Includes: ■ Endpoints. ■ Methods (GET, POST, etc.). ■ Data formats (JSON, XML, Protobuf). ■ Authentication and error handling. ❖ Ensures consistency and predictable integration. ➢ Popular API specification formats: RESTful APIs, GraphQL, SOAP, gRPC

Slide 7

Slide 7 text

REST || gRPC

Slide 8

Slide 8 text

REST ❖ Representational State Transfer ❖ Not a protocol but a Design Pattern ❖ Uses HTTP protocol ❖ Objects that are send or saved are called resources ❖ Operations are described by HTTP verbs ❖ Transfer data as XML or JSON

Slide 9

Slide 9 text

❖ A RESTful API can be - XML + HTTP JSON + HTTP

Slide 10

Slide 10 text

What does a RESTful API call look like?

Slide 11

Slide 11 text

Disadvantage of REST ❖ The data being transferred is heavily bloated.

Slide 12

Slide 12 text

Bloated Data

Slide 13

Slide 13 text

Disadvantage of REST ❖ The data being transferred is heavily bloated. ❖ There is no formal contract to communicate. ❖ HTTP verb don’t always describe your API. ❖ Streaming is difficult.

Slide 14

Slide 14 text

What if not REST?

Slide 15

Slide 15 text

gRPC ❖ gRPC Remote Procedure Call ❖ Modern open-source RPC framework by Google ❖ High Performance RPC framework ❖ Uses HTTP/2 for efficient data transmission. ❖ Uses Protocol Buffers for message interchange and for the fast binary serialization.

Slide 16

Slide 16 text

Writing a gRPC Service (3 Steps)

Slide 17

Slide 17 text

Let's make a calculator service:

Slide 18

Slide 18 text

❖ Interface Definition Language (IDL) ❖ Message Interchange format ❖ Platform neutral mechanism for serializing structured data. Protocol Buffers

Slide 19

Slide 19 text

Let's make a calculator Services:

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

❖ Generated code in 10 language ❖ Strict contract between client and server ❖ Performant and efficient on the wire Small binary message Faster serialization and deserialization ❖ In addition to traditional unary APIs, we get: Client Streaming APIs Server Streaming APIs Bi-Directional Streaming APIs Why gRPC? What do I get?

Slide 25

Slide 25 text

❖ High-Performance Systems: Ideal for APIs and microservices requiring speed and efficiency, thanks to HTTP/2 and Protocol Buffers. ❖ Distributed Systems: Advanced features like authentication, bidirectional streaming, and flow control make it powerful for distributed architectures. ❖ Polyglot Environments: Supports multiple languages, enabling APIs for diverse client ecosystems. ❖ Mobile Apps: Efficient network usage and bidirectional streaming make it suitable for mobile API consumption. When to use gRPC?

Slide 26

Slide 26 text

★ https://grpc.io/ ★ https://github.com/grpc ★ https://grpc.io/docs/ More about gRPC

Slide 27

Slide 27 text

Thank you!!