Nick Dabhi

Nick Dabhi


gRPC Basics: Why, When, and How?

Learn the basics of gRPC and see why it has grown in popularity, when it should be used and how. Ballerina, a network-aware programming language, is used.


In this article, we will take a look at what gRPC is, when we are supposed to use it, and how exactly we can do so. We will also compare and contrast technologies used in similar domains. For code examples, we will be using Ballerina (referred to as Ballerinalang in the article), which is a programming language optimized for network-aware applications.


The main requirement in question is the communication between programs in a network. In a standalone application, our communication is between in-process objects, where we do direct function/method calls. In this way, there is no requirement for communicating with an external program to get any required functionality. But as time moved on, we have started designing our applications to work in a more distributed manner. We would expose part of our business logic as an external service to be used by multiple consumers who are interested in doing so. So now, we need a communication mechanism when accessing these networked-endpoints.

A popular approach for accessing these remote services is using REST (Representational State Transfer). But when we talk about REST services, we tend to use this term loosely, where many of the service implementations do not fully adhere to the definition of a RESTful service. An important constraint of being a REST service is where our navigation through resources should be driven by hypermedia along with the knowledge of specific resource media types.

Persons REST API

Figure 1: Persons REST API

Figure 1 shows an example of a REST API, which is used to expose information related to “persons”. The API starts with a single entry point, and it navigates through its resources to get the required information as needed.

But generally, when we try to design REST APIs, we use direct knowledge of resource locations in the APIs when accessing them. A standard used to define these HTTP resources is OpenAPI. It defines the resource paths and the methods when defining operations of an API.

In a REST API, the resources represent some type of information. So it’s more aligned with representing data entities. This data is accessed and manipulated with CRUD (Create, Retrieve, Update, Delete) operations. Thus, it’s not directly possible to express an action using a resource, but rather, we are only able to emulate them. For example, sending an SMS can be represented by an HTTP POST action to the resource “/sms”. So this is can be seen as adding a new resource to the “/sms” resource collection, which gets mapped internally to the action of sending an SMS to a specific location. So even though it’s possible to model the actions also in the same way, it is not the most natural thing to do. This is where the RPC (Remote Procedure Call) mechanism comes into play.

Admin RPC Service

Figure 2: Admin RPC Service

Figure 2 shows an RPC service that contains several actions. You may have noticed that we have modeled our earlier data entity operations as actions as well, with addPerson() and getPerson(). By following such a specific convention, we can also represent our CRUD operations in an RPC approach.

Many RPC technologies are ranging from XML-RPC to SOAP to gRPC. These technologies have evolved into novel approaches for improving functionality, user-friendliness, and performance. gRPC has become one of the most popular technologies currently used for RPC. It is a binary protocol based on Google’s Protocol Buffers and works on top of the HTTP/2 transport. It promises high performance and features such as schema evolution and bidirectional streaming. If you find yourself modeling your API operations as actions most of the time, then it is a good sign that it should be modeled as an RPC solution. gRPC is supported widely by almost all of the mainstream programming languages, which makes it a popular choice for implementing APIs and their clients. Also, due to the underlying usage of HTTP/2, it follows an efficient network communication approach by multiplexing multiple streams through a single TCP connection. This allows the application to avoid the overhead when creating multiple network connections for separate communication channels. The programming model also supports the use of blocking and non-blocking communication, along with streaming features.

Let’s take a closer look at how gRPC works, and the tools and techniques that are required to implement it. The first aspect is the service definition using Protocol Buffers.

#microservices #rest #ballerina #grpc #developer

What is GEEK

Buddha Community

gRPC Basics: Why, When, and How?
Ryan  Schneider

Ryan Schneider


gRPC: An Introduction With Scala Compiler

Hola, does your application have a client-server architecture or microservices architecture or distributed architecture? Then, you must be using some kind of protocol for inter-application communication or you want to get started with one. So, Let’s start digging.

#grpc #microservices #scala #tech blogs #grpc frameworks #what is grpc

Biju Augustian

Biju Augustian


Learn Python Tutorial from Basic to Advance

Become a Python Programmer and learn one of employer’s most requested skills of 21st century!

This is the most comprehensive, yet straight-forward, course for the Python programming language on Simpliv! Whether you have never programmed before, already know basic syntax, or want to learn about the advanced features of Python, this course is for you! In this course we will teach you Python 3. (Note, we also provide older Python 2 notes in case you need them)

With over 40 lectures and more than 3 hours of video this comprehensive course leaves no stone unturned! This course includes tests, and homework assignments as well as 3 major projects to create a Python project portfolio!

This course will teach you Python in a practical manner, with every lecture comes a full coding screencast and a corresponding code notebook! Learn in whatever manner is best for you!

We will start by helping you get Python installed on your computer, regardless of your operating system, whether its Linux, MacOS, or Windows, we’ve got you covered!

We cover a wide variety of topics, including:

Command Line Basics
Installing Python
Running Python Code
Number Data Types
Print Formatting
Built-in Functions
Debugging and Error Handling
External Modules
Object Oriented Programming
File I/O
Web scrapping
Database Connection
Email sending
and much more!
Project that we will complete:

Guess the number
Guess the word using speech recognition
Love Calculator
google search in python
Image download from a link
Click and save image using openCV
Ludo game dice simulator
open wikipedia on command prompt
Password generator
QR code reader and generator
You will get lifetime access to over 40 lectures.

So what are you waiting for? Learn Python in a way that will advance your career and increase your knowledge, all in a fun and practical way!

Basic knowledge
Basic programming concept in any language will help but not require to attend this tutorial
What will you learn
Learn to use Python professionally, learning both Python 2 and Python 3!
Create games with Python, like Tic Tac Toe and Blackjack!
Learn advanced Python features, like the collections module and how to work with timestamps!
Learn to use Object Oriented Programming with classes!
Understand complex topics, like decorators.
Understand how to use both the pycharm and create .py files
Get an understanding of how to create GUIs in the pycharm!
Build a complete understanding of Python from the ground up!

#Learn Python #Learn Python from Basic #Python from Basic to Advance #Python from Basic to Advance with Projects #Learn Python from Basic to Advance with Projects in a day

Ken  Mueller

Ken Mueller


Building API with gRPC using ProtoBuf – Part 3

In order to build the client or server-side API, we need to follow some steps:
Step 1: Let’s Define the protobuf for our small application.
Step 2: Now simply compile you code.
Step 3: Define the Client side code in Scala.
Step 4: Now let’s see how can we define the Server-side code:

#grpc #microservices #scala #grpc #protocol buffers #scala

Milan  Reilly

Milan Reilly


gRPC & ASP.NET Core 5: Add a gRPC service reference


A while ago, I published a post that explained how to expose proto files within an ASP.NET Core gRPC app using Route-To-Code that you can find here: Exposing proto files in a gRPC service over a frameworkless and lightweight API – Anthony Giretti’s .NET blog

I only explained how to expose them and access them from a browser. But I haven’t explained how to download them from “Services References” menu in Visual Studio 2019, and I should have because there is a trick.

gRPC works only with HTTP/2

And that’s the trick! Kestrel in a gRPC service template, will ONLY expose endpoints on HTTP/2 because gRPC works only on HTTP/2. If you take the following endpoint that I use to expose a proto file: https://localhost:5001/protos/v2/country.proto it will work in a browser but not in Visual Studio 2019.

#grpc #grpc client #visual studio 2019 #aspdotnet core #aspdotnet core 5

Ken  Mueller

Ken Mueller


gRPC Basics

As part of our protocol evaluation in the last blog, we evaluated Apache AVRO. In continuation let’s try to evaluate protocol buffer (protobuf). The easiest and simplest way to evaluate protobuf is through gRPC. Let’s try to understand what is protobuf and gRPC.

What is protobuf?

Let’s take it from official website. **“**Protocol buffers are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data – think JSON, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages."z

There are two versions :

We are going to demonstrate proto3, as this is the latest. Syntax-wise there is considerable amount of difference between proto2 and proto3 but the underlying rpc concept remains the same. For extensive information about proto3 refer language guide here.

What is gRPC?

gRPC is RPC (Remote Procedure Call) framework that can run in any environment and supports multiple programming language. It uses protocol buffers as both its Interface Definition Language (IDL) and as its underlying message interchange format. Many cool feature of gRPC is bidirectional streaming and multiplexing of requests using HTTP/2. You can get more info about gRPC here.


Following are some reasons you should choose gRPC over Rest:

  1. gRPC transfer binary data as payload rather then text which makes communication much faster and compact.

  2. gRPC use HTTP/2 with long-lived connections so overhead of making connection per request can be avoided.

  3. gRPC is type-safe so if you are expecting an integer then nobody can send it as a string.

  4. gRPC is few millisecond faster then REST. So if millisecond matter for you then gRPC can be good choice.

  5. gRPC supports streaming so if you are looking for distributed streaming support gRPC can be pretty useful in this case.

Different gRPC Communication Mechanism:

  1. Unary

Unary communication

  1. Client Streaming

Client streaming

3) Server Streaming

Server streaming

  1. Bi-directional Streaming

Bi-directional streaming

#apache #microservice #grpc #rpc #message exchange #protocol buffer