Remote Invocation. To do. Request-reply, RPC, RMI. q Today q. q Next time: Indirect communication

Similar documents
Remote Invocation. Today. Next time. l Indirect communication. l Request-reply, RPC, RMI

Remote Invocation. Today. Next time. l Overlay networks and P2P. l Request-reply, RPC, RMI

03 Remote invoaction. Request-reply RPC. Coulouris 5 Birrel_Nelson_84.pdf RMI

Structured communication (Remote invocation)

CSci Introduction to Distributed Systems. Communication: RPC

Slides for Chapter 5: Remote Invocation

Chapter 5: Remote Invocation. Copyright 2015 Prof. Amr El-Kadi

Lecture 5: Object Interaction: RMI and RPC

RMI: Design & Implementation

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

Lecture 06: Distributed Object

MODELS OF DISTRIBUTED SYSTEMS

MODELS OF DISTRIBUTED SYSTEMS

Chapter 5 Remote Invocation. Gandeva Bayu Satrya, ST., MT. Telematics Labz. Informatics Department Telkom

CHAPTER - 4 REMOTE COMMUNICATION

416 Distributed Systems. RPC Day 2 Jan 12, 2018

Distributed Systems Theory 4. Remote Procedure Call. October 17, 2008

COMMUNICATION IN DISTRIBUTED SYSTEMS

Chapter 4 Communication

Today CSCI Communication. Communication in Distributed Systems. Communication in Distributed Systems. Remote Procedure Calls (RPC)

Distributed Systems 8. Remote Procedure Calls

Outline. EEC-681/781 Distributed Computing Systems. The OSI Network Architecture. Inter-Process Communications (IPC) Lecture 4

Operating Systems. 18. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Spring /20/ Paul Krzyzanowski

416 Distributed Systems. RPC Day 2 Jan 11, 2017

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Remote Procedure Call. Chord: Node Joins and Leaves. Recall? Socket API

Last Class: RPCs. Today:

DISTRIBUTED OBJECTS AND REMOTE INVOCATION

Remote Procedure Calls

Remote Procedure Call

Remote Procedure Call

Distributed Systems. The main method of distributed object communication is with remote method invocation

REMOTE PROCEDURE CALLS EE324

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

DISTRIBUTED COMPUTER SYSTEMS

CSCI-1680 RPC and Data Representation John Jannotti

Communication. Distributed Systems Santa Clara University 2016

Interprocess Communication

Distributed Systems Lecture 2 1. External Data Representation and Marshalling (Sec. 4.3) Request reply protocol (failure modes) (Sec. 4.

Distributed Systems. 03. Remote Procedure Calls. Paul Krzyzanowski. Rutgers University. Fall 2017

Communication Paradigms

Module 3 - Distributed Objects & Remote Invocation

Remote Invocation Vladimir Vlassov and Johan Montelius

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Remote Invocation. 1. Introduction 2. Remote Method Invocation (RMI) 3. RMI Invocation Semantics

CS 417 9/18/17. Paul Krzyzanowski 1. Socket-based communication. Distributed Systems 03. Remote Procedure Calls. Sample SMTP Interaction

CSCI-1680 RPC and Data Representation. Rodrigo Fonseca

Distributed Systems. Chapter 02

Overview. Communication types and role of Middleware Remote Procedure Call (RPC) Message Oriented Communication Multicasting 2/36

Distributed Systems. Client-Server Communication: Exercises

RPC. Remote Procedure Calls. Robert Grimm New York University

Distributed Systems. How do regular procedure calls work in programming languages? Problems with sockets RPC. Regular procedure calls

KTH ROYAL INSTITUTE OF TECHNOLOGY. Remote Invocation. Vladimir Vlassov and Johan Montelius

CSCI-1680 RPC and Data Representation. Rodrigo Fonseca

Distributed Systems Exam 1 Review Paul Krzyzanowski. Rutgers University. Fall 2016

Distributed Information Systems

IPC. Communication. Layered Protocols. Layered Protocols (1) Data Link Layer. Layered Protocols (2)

Building up to today. Remote Procedure Calls. Reminder about last time. Threads - impl

02 - Distributed Systems

Operating System Support

Networks and Operating Systems Chapter 3: Remote Procedure Call (RPC)

Distributed Systems. 5. Remote Method Invocation

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 22: Remote Procedure Call (RPC)

DS 2009: middleware. David Evans

02 - Distributed Systems

Advanced Distributed Systems

A Report on RMI and RPC Submitted by Sudharshan Reddy B

Distributed Systems Principles and Paradigms. Chapter 04: Communication

Two Phase Commit Protocol. Distributed Systems. Remote Procedure Calls (RPC) Network & Distributed Operating Systems. Network OS.

Communication in Distributed Systems

Chapter 5: Distributed objects and remote invocation

Communication. Overview

Distributed Systems Principles and Paradigms. Chapter 04: Communication

Distributed Systems. Lecture 06 Remote Procedure Calls Thursday, September 13 th, 2018

Networked Systems and Services, Fall 2018 Chapter 4. Jussi Kangasharju Markku Kojo Lea Kutvonen

Chapter 4: Inter-process Communications

Distributed Systems Inter-Process Communication (IPC) in distributed systems

Object Interaction. Object Interaction. Introduction. Object Interaction vs. RPCs (2)

Middleware. Adapted from Alonso, Casati, Kuno, Machiraju Web Services Springer 2004

Lecture 5: RMI etc. Servant. Java Remote Method Invocation Invocation Semantics Distributed Events CDK: Chapter 5 TVS: Section 8.3

Administrivia. Remote Procedure Calls. Reminder about last time. Building up to today

Remote Procedure Calls (RPC)

Interprocess Communication Tanenbaum, van Steen: Ch2 (Ch3) CoDoKi: Ch2, Ch3, Ch5

RMI & RPC. CS 475, Spring 2019 Concurrent & Distributed Systems

Outline. Interprocess Communication. Interprocess Communication. Communication Models: Message Passing and shared Memory.

Lecture 8: February 19

Chapter 5 Distributed Objects and Remote Invocation

Q.1. (a) [4 marks] List and briefly explain four reasons why resource sharing is beneficial.

CS603: Distributed Systems

Communication. Communication. Distributed Systems. Networks and protocols Sockets Remote Invocation Messages Streams. Fall /10/2001 DoCS

Today: Distributed Objects. Distributed Objects

SAI/ST course Distributed Systems

Remote Procedure Calls CS 707

Distributed Systems. Definitions. Why Build Distributed Systems? Operating Systems - Overview. Operating Systems - Overview

a. Under overload, whole network collapsed iii. How do you make an efficient high-level communication mechanism? 1. Similar to using compiler instead

Chapter IV INTERPROCESS COMMUNICATION. Jehan-François Pâris

Communication. Layered Protocols. Topics to be covered. Layered Protocols. Introduction

Lecture 15: Network File Systems

xkcd.com End To End Protocols End to End Protocols This section is about Process to Process communications.

Announcements. me your survey: See the Announcements page. Today. Reading. Take a break around 10:15am. Ack: Some figures are from Coulouris

RPC Paradigm. Lenuta Alboaie Andrei Panu

Transcription:

Remote Invocation To do q Today q Request-reply, RPC, RMI q Next time: Indirect communication

Beyond message passing In DS, all IPC is based on low-level msg passing A bit too low level Modern distributed systems can have 10 3-10 6 processes scattered around 2

Beyond message passing Send/receive exposes communication Any programmer-friendlier models? Today Request-reply patterns in msg passing with little support for request/reply interactions Remote procedure calls extending procedure calls Remote method invocation to remote objects Client Server Do something There you go Working 3

Request-reply (RR) protocols We can describe RR based on three primitives dooperation used by client to invoke an operation Parameters specify remote server and arguments After sending it, client issues a receive to get the reply getrequest used by server to get request sendreply used by server to send reply When received by client, original dooperation is unblocked dooperation (wait) (continuation) Request message Reply message getrequest Select operation Execute operation sendreply 4

Request-reply protocols Normally, synchronous and reliable Asynchronous is also possible Synchronous and asynchronous Synchronous the sender blocks until request has been accepted Points of synchronization: (1) at request submission, (2) at request delivery or (3) after processing With asynchronous the sender continues instead of blocking Reliability, two concerns Reliability msg arrives despite some packet drops Integrity msg arrives uncorrupted and without duplication 5

Request-reply protocols For reliability or for request-reply communication Messages need a request and a process identifier Failures partially depend on transport TCP or UDP Over UDP, omission and out-of-order issues Process may also fail (crash failures) To handle omission failures timers For duplicate messages, msg id (keep a history) or idempotent operations doing the same operation one or multiple times gives the same result messagetype: int (req/reply) requestid: int remotereference operationid: int arguments: byte[] 6

Request-reply protocols Exchange styles different behavior in front of failures Request (R) When client doesn t need confirmation, asynchronous (typically over UDP) Request-reply (RR) Useful for most client-server exchanges No need for special ack, server reply is an implicit ack Request-reply-acknowledge (RRA) Server can clean history Name Client Server Client R Request RR Request Reply RRA Request Reply Ack reply 7

Using TCP or UDP to implement RR Client-server exchange can be built on UDP or TCP (or any other transport) To avoid implementing multi-packet protocols, TCP TCP reliability means no need for retransmissions, duplicate filtering or history No problem with large transmissions, flow-control handles it If multiple exchanges, connection overhead applies once If you can live without all this, maybe a more efficient protocol over UDP Sun NFS (Network File Systems) transmits fixed-size blocks between client/server All operations are idempotent, so no need for history 8

Data representation and marshaling Processes keep information in data structures records, arrays, strings, trees But IPC is in messages, strings of bytes TCP/UDP gives the mechanisms to send sequences of bytes Processes need a protocol to make the exchange meaningful To serialise data into a stream of bytes and deserialise it to read it 9

Data representation and marshaling Marshaling/unmarshaling Assembling/disassembling process data for transmission Client and server may have different data representations Both need to properly interpret a msg to transform it into machine-dependent representation Agree on encoding How are basic data values represented (integers, floats, ) How are complex data values represented (arrays, unions) Intermediate language or source s representation Multiple external representation alternatives Sun s XDR, Corba, XML, Google s protocol buffer, JSON, Gob (Go specific) 10

A gob example package main import ( "bytes" "encoding/gob" "fmt" "log" ) type P struct { X, Y, Z int Name string } type Q struct { X, Y *int32 Name string } Part of the same file; formatted to fit the slide) func main() { // Initialize the encoder and decoder. Normally enc and dec would be // bound to network connections and the encoder and decoder would // run in different processes. var network bytes.buffer // Stand-in for a network connection enc := gob.newencoder(&network) // Will write to network. dec := gob.newdecoder(&network) // Will read from network. // Encode (send) the value. err := enc.encode(p{3, 4, 5, "Pythagoras"}) if err!= nil { log.fatal("encode error:", err) } // Decode (receive) the value. var q Q err = dec.decode(&q) if err!= nil { log.fatal("decode error:", err) } fmt.printf("%q: {%d,%d}\n", q.name, *q.x, *q.y) } 11

HTTP as an example HyperText Transfer Protocol, on top of TCP Specifies msgs exchanged, formats, methods, arguments and results, representation for marshaling Content negotiation clients state format they can accept Password-style authentication A fixed set of methods, some well-known ones GET Requests resource or run program pointed to by URL HEAD Same as GET but returns only metadata POST Provides data, depending on function supported by the program specified by the URL (e.g., posting a msg) PUT Requests to store data with the given URL as ID Others: DELETE, OPTIONS, TRACE 12

HTTP as an example Clients invoke methods to be applied to resources at the server (given by the URL) Msgs marshalled into ASCII text strings Connections Client interaction in version 1.0 Client request a connection at default (or given) port sends request msg to server Server sends reply Connection is closed Setting/closing a connection per request is costly HTTP 1.1 uses persistent connections Can be close by client, server or after being idle for a while 13

HTTP as an example $ telnet www.golang.org 80 Trying 64.233.191.141... Connected to golang.org. Escape character is '^]'. GET /index.htm HTTP/1.1 host: www.golang.org HTTP/1.1 302 Found Location: http://golang.org/index.htm package main Date: Thu, 09 Apr 2015 14:21:32 GMT Content-Type: text/html; charset=utf-8 import ( Server: Google Frontend "net/http Content-Length: 224 Alternate-Protocol: 80:quic,p=0.5 func main(){ Using telnet Using go <HTML><HEAD><meta http-equiv="content-type" if len(os.args)!= 2 { content="text/html;charset=utf-8"> <TITLE>302 Moved</TITLE></HEAD><BODY> <H1>302 Moved</H1> The document has moved } <A HREF="http://golang.org/index.htm">here</A>. </BODY></HTML> } fmt.fprintf(os.stderr, "Usage: %s URL\n", os.args[0]) os.exit(1) response, err := http.get(os.args[1]) if err!= nil { log.fatal(err) } else { defer response.body.close() _, err := io.copy(os.stdout, response.body) if err!= nil { log.fatal(err) } } 14

Back in 5 RPC and RMI 15

Remote Procedure Call (RPC) Earliest and best known example of a more programmer friendly model [Birrell and Nelson 84] Some observations Developers are familiar with simple procedure model Well engineered procedures operate in isolation No fundamental reason not to execute procedures on a separate machine Can hide sender/receiver comm. using proc calls? Client Call remote procedure Request Wait for result Reply Return from call Server Call local procedure and return result Time 16

RPC details RPC promote programming with interfaces Better abstractions & maintainability, language independence Interface specification with lang independence Interface Definition Languages (e.g., XDR, Corba IDL) RPC, local procedure calls and transparency Parameter passing and global variables Copy in/copy out semantics while procedure is being executed, nothing can be assumed about parameter values All data to be worked on is passed by parameters; no ref to globals How about pointers? Copy/restore, no call-by-reference Remote reference for more complex structures Failures and latency 17

RPC details RPC call semantics Depending on fault tolerance measures: Retransmit request until getting a reply or decide server failed Duplicate filtering at the server Re-execute procedure or retransmit reply, keeping history of results at the server Call semantics Fault tolerance measures Retransmit request Duplicate filtering Re-execute/retransmit Maybe No NA NA At-least-once Yes No Re-exec At-most-once Yes Yes Retransmit reply What are the semantics of local procedure calls? 18

Basic RPC implementation and operation Client machine Server machine (1) Client calls stub (2) Stub builds msg, calls OS Client stub (3) OS sends msg to remote OS Client process k= add(i,j) proc: add int: val(i) int: val(j) Client OS (10) Unpacks results and return proc: add int: val(i) int: val(j) Server stub Server process Implementation of add k= add(i,j) proc: add int: val(i) int: val(j) Server OS (6) Server returns result to stub (7) Packs and calls OS (5) Stub unpacks args and calls server (4) Remote OS gives msg to stub (8) OS sends msg back (9) Client OS gives msg to stub 19

RPC details Runtime is given RPCRuntime was part of Cedar in the original RPC system Programmers writes client and server Client and server-stub are user generated Based on the interface specification By Lupine in the original A binder for clients to find where to connect Binder runs on a well-known-port Manage table of references/ports for each service 20

Asynchronous RPCs Synchronous Client Call remote procedure Wait for result Return from call Request Reply Server Call local procedure and return result Time Get rid of the strict request-reply behavior, but let the client continue w/o waiting for server s answer Asynchronous Client Call remote procedure Wait for acceptance Return from call Request Reply Server Call local procedure and return result Time 21

Deferred synchronous RPCs Combining two asynchronous RPC is sometimes also referred to as deferred synchronous RPC Call remote procedure Wait for acceptance Return from call Interrupt client Client Request Accept request Return results Ack Server Call local procedure and return result Time Call client with one-way RPC A variation Client can also do a (non)blocking poll at the server to see whether results are available 22

Sun RPC Defined in RFC 1831 Designed for client-server communication in the Sun Network File System Run over UDP or TCP, using at-least-once semantics Sun XDR as external data representation and IDL Interfaces are identified by program and version number Binder (port mapper) for clients to find where to connect Authentication through fields in the request/reply msgs 23

Remote Method Invocation RMI extends RPC into the world of distributed objects As RPC, programming with interfaces also built on top of request-reply, offers similar call semantics and similar level of transparency But Programmer can use OO programming features (objects, classes, inheritance ) All objects have an object reference; refs can be passed on as parameters (first class values) Not just parameter passing by value, good for complex parameters For distributed objects, remote object refs and remote interfaces 24

RPC examples XML/RPC Over http, huge XML parsing overhead, txt transfer SOAP Designed for web services via HTTP, same XML overhead CORBA Quite comprehensive and very complex COM Mostly for Windows client software Protocol Buffers Lightweight, developed by Google Thrift Lightweight, more fancy types (lists, maps, ), developed by FB GOB Go-specific, lightweight, using reflection, efficient wire-format 25

Remote Method Invocation With OO, state partition among processes as objects If using a client-server model, Objects managed by servers, invoked by clients through RMI Objects could also be replicated and/or migrated for reliability, availability or performance Implementing RMI Similar to RPC, a proxy object, two communication modules and a dispatcher & skeleton With distributed objects, distributed garbage collection 26

Distributed garbage collection One way to implement it cooperating local collectors Server keeps list of processes holding remote refs to its objects When a client first receive a remote ref. to a remote object, adds itself as holder at server (extra invocation) and creates a proxy Server adds clients to holders When client garbage collects proxies for remote object, removes itself from holders at server (extra invocation) then deletes proxy Server removes client from holders Java s approach Keeping resources at servers and leases What to do if clients go away? Set up leases granting the use of resources for a fixed period of time 27

Summary Powerful primitives can makes (distributed) programming them a lot easier Procedure calls Simple way to pass control and data Elegant and transparent way to distribute applications Not the only way Hard to provide true transparency Failures, performance, memory access, How to deal with hard problems let the programmer do it worse is better (Richard Gabriel s) 28