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

gRPC vs REST | Rasna | Gurzu

Avatar for Gurzu Gurzu
December 05, 2024

gRPC vs REST | Rasna | Gurzu

Rasna compares gRPC and REST, exploring their explored their key differences.

Avatar for Gurzu

Gurzu

December 05, 2024
Tweet

More Decks by Gurzu

Other Decks in Programming

Transcript

  1. Agenda ❖ API, Types and Specifications. ❖ What is REST?

    ❖ Disadvantages of REST. ❖ What is gRPC? ❖ Advantages of gRPC.
  2. 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.
  3. 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.
  4. 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
  5. 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
  6. 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.
  7. 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.
  8. ❖ Interface Definition Language (IDL) ❖ Message Interchange format ❖

    Platform neutral mechanism for serializing structured data. Protocol Buffers
  9. ❖ 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?
  10. ❖ 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?