Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon

gRPC, a CNCF backed JavaScript library and an alternative to the REST paradigm, is now generally available

Save for later
  • 3 min read
  • 25 Oct 2018

article-image

Yesterday, the Cloud Native Computing Foundation (CNCF) announced the general availability of gRPC-Web, which means that it is stable enough for production use. It is a JavaScript client library that allows web apps to directly communicate with backend gRPC services, without the need for an intermediate HTTP server. This serves as an alternative to the REST paradigm of web development.

What is gRPC?


grpc-a-cncf-backed-javascript-library-and-an-alternative-to-the-rest-paradigm-is-now-generally-available-img-0

Source: gRPC


Initially developed at Google, gRPC is an open source remote procedure call (RPC) framework that can run in any environment. gRPC allows a client application to directly call methods on a server application on a different machine as if it was a local object.

gRPC is based on the idea of defining a service, specifying the methods that can be called remotely with their parameter and return types. To handle the client calls the server then implements this interface and runs a gRPC server. On the client side, the client has a stub that provides the same methods as the server.

One of the advantages of using gRPC is that gRPC clients and servers can be written in any of the languages supported by gRPC. So, for instance, you can easily create a gRPC server in Java with clients in Go, Python, or Ruby.

How gRPC-Web works?


With gRPC-Web, you can define a service “contract” between client web applications and backend gRPC servers using .proto definitions and auto-generate client JavaScript.

Here is how gRPC-Web works:

  1. Define the gRPC service: The first step is to define the gRPC service. Similar to other gRPC services, gRPC-Web uses protocol buffers to define its RPC methods and their message request and response types.
  2. Run the server and proxy: You need to have a gRPC server that implements the service interface and a gateway proxy that allows the client to connect to the server.
  3. Writing the JavaScript client: After the server and gateway are up and running, you can start making gRPC calls from the browser.

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime

What are the advantages of using gRPC-Web?


Using gRPC-Web eliminates some of the tasks from the development process:

  • Creating custom JSON serialization and deserialization logic
  • Wrangling HTTP status codes
  • Content type negotiation


The following are its advantages:

End-to-end gRPC


gRPC-Web allows you to officially remove the REST component from your stack and replace it with pure gRPC. Replacing REST with gRPC will help in scenarios where a client request goes to an HTTP server, which interacts with five backend gRPC services.

Tighter coordination between frontend and backend teams


As the entire RPC pipeline is defined using Protocol Buffers, you no longer need to have your “microservices teams” alongside your “client team.” The interaction between the client and the backend is just one more gRPC layer amongst others.

Generate client libraries easily


With gRPC-Web, the server that interacts with the “outside” world is now a gRPC server instead of an HTTP server. This means that all of your service’s client libraries can be gRPC libraries. If you need client libraries for Ruby, Python, Java, and 4 other languages, you no longer have to write HTTP clients for all of them.

You can read CNCF’s official announcement on its website.

CNCF accepts Cloud Native Buildpacks to the Cloud Native Sandbox

Cortex, an open source, horizontally scalable, multi-tenant Prometheus-as-a-service becomes a CNCF Sandbox project

Google Cloud hands over Kubernetes project operations to CNCF, grants $9M in GCP credits