This presentation is all about gRPC. gRPC is a modern open-source high-performance RPC framework that can run in any environment. It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking and authentication. With gRPC, we can define our service once in a .proto file and implement clients and servers in any of the gRPC’s supported languages. gRPC is roughly 7 times faster than REST when receiving data. It is 10 times faster than REST when sending data for this specific payload.
Unlocking the Future of AI Agents with Large Language Models
Building API Using GRPC And Scala
1. Presented By: Shivraj Singh
Software Consultant
Knoldus Inc.
Building API using
GRPC and Scala
2. 1. History.
2. gRPC: Introduction.
3. gRPC: Workflow.
4. Why gRPC.
5. Scenarios.
6. Core Features
7. Using an HTTP/1.1 transport and its limitations.
8. Difference b/w gRPC and REST.
9. gPRC helps Microservices.
10.gRPC: Powered by.
11.Why not jut use XML.
Our Agenda
3. History
● Google has been using a RPC infrastructure called Stubby to
connect the large number of microservices running within and
across their data centers for over a decade.
● RPC backbone behind every Google service that we use today.
4. gRPC: Introduction
● gRPC is a modern open source high performance RPC
framework that can run in any environment.
● It can efficiently connect services in and across data centers
with pluggable support for load balancing, tracing, health
checking and authentication.
● It is also applicable in last mile of distributed computing to
connect devices, mobile applications and browsers to backend
services.
5.
6. Why gRPC?
● With gRPC we can define our service once in a .proto file and
implement clients and servers in any of gRPC’s supported
languages.
● gRPC is roughly 7 times faster than REST when receiving data
● It is 10 times faster than REST when sending data for this
specific payload.
7. Scenarios
● Efficiently connecting polyglot services in microservices style
architecture
● Connecting mobile devices, browser clients to backend services.
● Low latency(process a very high volume of data messages with
minimal delay).
● Highly scalable(it can handle a large increase in users, workload
or transactions without undue strain)
8. Core Features
● Idiomatic client libraries in 10 languages
● Highly efficient on wire and simple service definition framework
● Bi-directional streaming with http/2 based transport
● Pluggable auth(Use:Secure Socket Layer), tracing(opentracing),
load balancing and health checking(package grpc.health.v1;)
10. Using HTTP/1.1 Limitations
● Request-Response protocol
○ Each connection supports pipelining... but not parallelism
(in-order only)
○ Content may be compressed... but headers are text format.
● Naturally supports single-direction streaming ... but not
bidirectional
11. HTTP/2 Advantages
● For HTTP/1.1 and HTTP/2 protocol with a slight difference.
Imagine that waiters are TCP connections and you want to order
your meal and a bottle of water. For HTTP/1.1 that would mean
that you ask one waiter for your meal and another one for
water, hence you would allocate two TCP connections.
● Request → Stream
○ Streams are multiplexed using framing
● Header compression
● Directly supports bidirectional streaming
15. gRPC Help Microservices
● Distributed logging, tracing
● Ready to honor backward and forward compatibility, even
if you're the same person consuming this service on the
other side
● Provide Quality of service(QoS) - request deadline even if
it's propagated to many different services
● Provide request propagations/cancellations - stop
cascading failures
16. Use of Protocol Buffers
Protocol buffer data is structured as messages, where each
message is a small logical record of information containing a series
of name-value pairs called fields.
For example:
syntax = “proto3”;
message Person {
string name = 1;
int32 id = 2;
string email = 3;
}
17. Example of XML and Protobuf
In XML:
<person>
<name>John Doe</name>
<email>jdoe@example.com</email>
</person>
In Protobuf:
person {
name: "John Doe"
email: "jdoe@example.com"
}
18. Why not just use XML
Protocol buffers have many advantages over XML for serializing
structured data. Protocol buffers:
● are simpler
● are 3 to 10 times smaller
● are 20 to 100 times faster
● are less ambiguous
● generate data access classes that are easier to use
programmatically