Remote Calls in Distributed Systems

Communication

RPC — Remote Procedure Call

Image for post
Image for post
Communicating with your neighbor to calculate_fib(n)
Image for post
Image for post
Image Source: http://www.quickmeme.com/meme/3547dl

Communication Basics

Image for post
Image for post
Image Reference: George, Coulouris; Distributed Systems Concepts and Design
Image for post
Image for post
Image Reference: George, Coulouris; Distributed Systems Concepts and Design

Welcome, Stubs.

Image for post
Image for post

Let’s implement our Fib!

IDL.x which defines the interface for client server communication
% rpcgen -a -C IDL.x
IDL_client.c  IDL_clnt.c  IDL.h  IDL_server.c  IDL_svc.c  IDL.x  Makefile.IDL
IDL_server.c
IDL_client.c
clnt = clnt_create (host, FIBCALCULATION, FIBCALCULATION_VERSIONONE, "udp");
% sudo ./IDL_server
% sudo ./IDL_client localhost 10
Image for post
Image for post
Client calling the locally hosted server with n = 10. The server sends the response 55.
Image for post
Image for post
Server got called with n = 10.

So, a summary.

Image for post
Image for post
Image source: Distributed Systems Principles Andrew Tanenbaum

Wait! Not yet.

POST /sayHello HTTP/1.1
HOST: api.example.com
Content-Type: application/json
{"name": "John Doe"}
app.post("/sayHello?name='John Doe'", () => {sayHello(req.query.name); }
@PostMapping("/sayHello")
public void sayHello(@RequestParam String name) {
// implementation of the function}
Image for post
Image for post

OK, we’ll stop.

References

Software Engineer @ CodeGen International, CSE Graduate @ University of Moratuwa

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store