1 of 15

CMPT 471: Networking II��Remote Procedure Call (RPC)Mohamed Hefeeda

2 of 15

RPC: Motivation

  • Many network and distributed apps use request/reply messages

  • Why cannot we just use UDP or TCP?
    • Apps need much more than just sending bytes
    • E.g., matching replies to requests, handling �message boundaries, different data formats, �addressing processes on servers

  • RPC offers these functionalities
    • RPC is higher level, more abstract, than �basic transport protocols

2

Blocked

Server

Request

Reply

Compute

Client

3 of 15

RPC: Motivation

  • RPC offers the semantics of local procedure call, but on remote servers
    • Methods/functions/procedures can be anywhere (local or remote)
      • Server and client can be running on different architectures and OSes
    • 🡺 This greatly simplifies the design and implementation of distributed systems

  • RPC is also known as RMI (Remote Method Invocation in OO languages)

  • RPC is quite popular

3

4 of 15

RPC: Two Main Components

  • Protocol that manages messages between client and server
    • To handle reliability, process identification, message IDs, …
  • Compiler and programming language support
    • To package arguments into messages on the client and translate these message back to arguments on the server
    • 🡺 Apps do not need to worry about the different architectures and/or OSes of the server and client

    • This is usually called stub compiler or message marshaling

4

5 of 15

RPC: Overview

  • Client and server “stubs” define the structure of messages
  • Client sends a request using client stub
  • RPC delivers request to server
  • Request is unpackaged using server stub
  • Server runs the requested procedure
  • Results are packaged using server stub and sent to client using RPC

5

6 of 15

RPC Protocol

  • RPC can be implemented over TCP and use its reliability functions
  • In many cases, however, RPC implements its own reliability mechanisms
    • To avoid the complexities and overheads of TCP

  • RPC can be
    • Synchronous:
      • sender blocks until reply comes back
      • easier to implement and use in apps
    • Asynchronous:
      • sender does not block until reply comes back, multiple requests can be sent
      • More efficient, but usually harder to design and use in apps

6

7 of 15

Example 1: SunRPC

  • SunRPC
    • Also known as Open Network Computing RPC
    • Widely used, especially with the Network File System (NFS)
    • Built on top of UDP

7

8 of 15

Example 2: DCE RPC

  • DCE RPC
    • Part of the Distributed Computing Environment (DCE)
      • DCE defines Standards to build distributed systems
    • Basis of Microsoft’s DCOM and ActiveX
    • Used in Common Object Request Broker Architecture (CORBA)
      • which is an industry-wide standard for building distributed, object-oriented systems
    • Can be built on either TCP or UDP

8

9 of 15

Example 3: gRPC

  • gRPC
    • Designed by Google, now open source
    • Supports large-scale cloud services
    • Built on top of TLS (Transport Layer Security) which works on top TCP

  • gRPC is quite powerful and being used widely in industry especially for cloud services and data center apps

9

10 of 15

gRPC: Some Details

  • gRPC uses Protocol Buffers to serialize structured data
    • Serialization means converting an object to a stream of bytes (for storage or transmission)
    • Protocol buffers are written as text (.proto) files
    • gRPC has a compiler (protoc) that generates access classes from .proto files
      • Developers start from these classes and write their server and client codes

10

// probeService.proto file

service ProbeService {

rpc GetCapacity(Request) returns (Response) {}

}

message Request {

string name = 1;

uint32 reqID = 2;

}

message Response {

string name = 1;

uint32 capacity = 2;

}

11 of 15

gRPC: Some Details

  • gRPC supports different languages including C++, Java, Python, …
  • Server and clients can be written in different languages

11

12 of 15

gRPC: Some Details

  • To support cloud services, gRPC adds an extra level of indirection, as follows:
  • A cloud service is assigned a unique name/ID
  • Multiple identical instances (typically containers) are created
    • A container (e.g., using Docker) is a process encapsulated in an isolated environment that includes all software packages needed to run the process
  • Clients do not address instances directly, rather they use the service ID

12

13 of 15

gRPC: Some Details

13

  • Requests from clients are forwarded to a load balancer (LB)
  • LB selects an instance of the service for each client request
  • That is, the client indirectly addresses the service 🡺 greatly facilitating managing large-scale services
  • LB can create/terminate instances dynamically

14 of 15

RPC: Summary

  • RPC is useful for many distributed applications
  • RPC has two main components
    • Protocol to manage messages and
    • Compiler support to un/package arguments into messages
  • Common RPC examples
    • SunRPC
      • Widely used, especially for NFS
    • DCE RPC
      • Standard for building distributes systems, used in CROBA and by major companies
    • gRPC
      • Developed by Google
      • Powerful, especially for large-scale cloud services

14

15 of 15

Reading

  • Section 5.3 of [PD19]

15