Lecture 008

Abstraction

Client-Server model: request, reply

Pear-to-pear: not-client server model

Remote Procedure Calls (RPC)

RPC: abstract away the network

Flavors of Transparency

Flavors of Transparency

Stack Layout

Stack Layout

RPC Package in Golang: (assume you have Golang on both side)

Server Side

Server Side

Client Side

Client Side

RPC Steps

RPC Steps

RPC Steps:

Stubs

Serialization, pickle, marshals: transform structure data to bytes

Client stub:

Server stub:

It is like ABI (Application binary interface)-Encoded Constructor Arguments

Example RPC: klzzwxh:0005 means "host to network byte order, long" (big-endian is standardized to deal with cross-platform variance)

Example RPC: htonl() means "host to network byte order, long" (big-endian is standardized to deal with cross-platform variance)

runtime: a process that runs in the background to provide service to other service

Interface Definition Language (IDL): a language to describe interface.

Abstractly, it replaces the stack of client machine by data sent from server. But then we need to know the exact size of returning data to copy.

Abstractly, it replaces the stack of client machine by data sent from server. But then we need to know the exact size of returning data to copy.

With RPC, though. You can't pass everything. Pointers are problematic to pass to server. So pure functions are good in RPC.

Shallow integration:

Deep integration:

Challenges of RPC

It is sometimes impossible to distinguish machine failure from communication failures. It is a decision to and not to break transparency and make failure visible.

There are choices to tolerate network failure: (semantics)

You might also want to design a RPC in distributed filesystem or on distributed shared memory?

Synchronization

Synchronous Call

Synchronous Call

Asynchronous Call where no data need to be sent

Asynchronous Call where no data need to be sent

Asynchronous Call where you need data

Asynchronous Call where you need data

gRPC

gRPC

gRPC

In reality, you either use RPC, or RESTful, or GraphQL. You typically decide on using gRPC or http.

gRPC: Google's RPC that is also language agnostic.

Example: a Android application request product info from a Golang server. A compiler will generate a stub for a function for different programming language, both server and client side.

Example: a Android application request product info from a Golang server. A compiler will generate a stub for a function for different programming language, both server and client side.

The underlying gRPC framework handles all the complexities that are normally associated with making RPCs, enforcing strict service contracts:

gRPC also pulls features:

Why not RESTful:

Table of Content