REMOTE PROCEDURE CALLS EE324

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

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

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

416 Distributed Systems. RPC Day 2 Jan 12, 2018

Distributed Systems [Fall 2013]

416 Distributed Systems. RPC Day 2 Jan 11, 2017

Distributed Systems. Lec 4: Remote Procedure Calls (RPC)

Remote Procedure Calls

416 Distributed Systems. Networks review; Day 2 of 2 And start of RPC Jan 13, 2016

Distributed Systems 8. Remote Procedure Calls

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

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

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

416 Distributed Systems. Networks review; Day 2 of 2 Fate sharing, e2e principle And start of RPC Jan 10, 2018

CHAPTER - 4 REMOTE COMMUNICATION

Network Communication and Remote Procedure Calls

struct foomsg { u_int32_t len; }

CS 138: Communication II

Remote Procedure Call (RPC) and Transparency

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

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

Distributed Objects and Remote Invocation. Programming Models for Distributed Applications

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

CSci Introduction to Distributed Systems. Communication: RPC

DISTRIBUTED COMPUTER SYSTEMS

Remote Procedure Calls (RPC)

Dr. Robert N. M. Watson

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

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

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

MODELS OF DISTRIBUTED SYSTEMS

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

Lecture 8: February 19

CSCI-1680 RPC and Data Representation. Rodrigo Fonseca

RMI: Design & Implementation

Remote Procedure Call

MODELS OF DISTRIBUTED SYSTEMS

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

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

Last Class: RPCs. Today:

Communication in Distributed Systems

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

COMMUNICATION IN DISTRIBUTED SYSTEMS

Lecture 8: February 17

CSCI-1680 RPC and Data Representation John Jannotti

Remote Invocation Vladimir Vlassov and Johan Montelius

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

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

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

DS 2009: middleware. David Evans

CSCI-1680 RPC and Data Representation. Rodrigo Fonseca

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

Structured communication (Remote invocation)

Communication. Distributed Systems Santa Clara University 2016

3. Remote Procedure Call

CS603: Distributed Systems

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

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

ECE454 Tutorial. June 16, (Material prepared by Evan Jones)

Question. Reliable Transport: The Prequel. Don t parse my words too carefully. Don t be intimidated. Decisions and Their Principles.

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

Chapter 4 Communication

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

RPC. Remote Procedure Calls. Robert Grimm New York University

Lecture 5: Object Interaction: RMI and RPC

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


MTAT Enterprise System Integration. Lecture 2: Middleware & Web Services

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

Last Time. Internet in a Day Day 2 of 1. Today: TCP and Apps

RPC flow. 4.3 Remote procedure calls IDL. RPC components. Procedure. Program. sum (j,k) int j,k; {return j+k;} i = sum (3,7); Local procedure call

Project 2: Part 1: RPC and Locks

How do modules communicate? Enforcing modularity. Modularity: client-server organization. Tradeoffs of enforcing modularity

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

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 21: Network Protocols (and 2 Phase Commit)

Remote Procedure Calls CS 707

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

A short introduction to Web Services

Chapter 5: Distributed objects and remote invocation

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

May Gerd Liefländer System Architecture Group Universität Karlsruhe (TH), Systemarchitektur

Distributed Systems. 5. Remote Method Invocation

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

02 - Distributed Systems

SAI/ST course Distributed Systems

Implementing Remote Procedure Calls*

02 - Distributed Systems

COMMUNICATION PROTOCOLS: REMOTE PROCEDURE CALL (RPC)

Chapter 3: Client-Server Paradigm and Middleware

CS454/654 Midterm Exam Fall 2004

Advanced Distributed Systems

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

Slides for Chapter 5: Remote Invocation

Distributed Systems are Everywhere!" CS162 Operating Systems and Systems Programming Lecture 22 Client-Server" Client-Server" Message Passing"

Interprocess Communication

Internetworking Models The OSI Reference Model

Desarrollo de Aplicaciones en Red. El modelo de comunicación. General concepts. Models of communication. Message Passing

6.033 Lecture Fault Tolerant Computing 3/31/2014

L12: end to end layer

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

Transcription:

REMOTE PROCEDURE CALLS EE324

Administrivia Course feedback Midterm plan Reading material/textbook/slides are updated. Computer Systems: A Programmer's Perspective, by Bryant and O'Hallaron Some reading material (URL) in the slides. (lecture 9)

Building up to today Abstractions for communication Internetworking protocol: IP TCP masks some of the pain of communicating across unreliable IP Abstractions for computation and I/O Process: A resource container for execution on a single machine Thread: pthread and synchronization primitives (sem, mutex, cv) File

Now back to Distributed Systems: remember? 4 A distributed system is: A collection of independent computers that appears to its users as a sin gle coherent system "A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable." Leslie La mport

Distributed Systems 5 The middleware layer extends over multiple machine s, and offers each application the same interface.

What does it do? 6 Hide complexity to programmers/users Hide the fact that its processes and resources are physically distributed across multiple machines. Transparency in a Distributed System

How? 7 The middleware layer extends over multiple machine s, and offers each application the same interface.

Starter for Today Splitting computation across the network What programming abstractions work well to split work among multiple networked computers?

Many ways Request-reply protocols Remote procedure calls (RPC) Remote method invocation (RMI) Recommended reading : Distributed Systems: Concepts and Design 5 th edition, by Coulouris, et al. (CDK5) chapter 5

Request-reply protocols Client Hey, do something Server working { Done/Result

Request-reply protocols eg, your PA1 (binary protocol) struct foomsg { u_int32_t len; } send_foo(char *contents) { int msglen = sizeof(struct foomsg) + strlen(contents); char buf = malloc(msglen); struct foomsg *fm = (struct foomsg *)buf; fm->len = htonl(strlen(contents)); memcpy(buf + sizeof(struct foomsg), contents, strlen(contents)); write(outsock, buf, msglen); } Then wait for response, handle timeout, etc.

Request-reply protocols: text protocol HTTP See the HTTP/1.1 standard: http://www.w3.org/protocols/rfc2616/rfc2616.html Done with your PA2 yet?

Remote Procedure Call (RPC) A type of client/server communication Attempts to make remote procedure calls look like local ones figure from Microsoft MSDN {... foo() } void foo() { invoke_remote_foo() }

RPC Goals Ease of programming Hide complexity Automate a lot of task of implementing Familiar model for programmers (just make a function call) Historical note: Seems obvious in retrospect, but RPC was only invented in the 80s. See Birrell & Nelson, Implementing Remote Procedure Call... or Bruce Nelson, Ph.D. Thesis, Carnegie Mellon University: Remote Procedure Call., 1981 :)

Remote procedure call 15 A remote procedure call makes a call to a remote service look like a l ocal call RPC makes transparent whether server is local or remote RPC allows applications to become distributed transparently RPC makes architecture of remote machine transparent

RPC 16 The interaction between client and server in a traditional RPC.

Passing Value Parameters (1) 17 The steps involved in a doing a remote computation through RPC.

But it s not always simple Calling and called procedures run on different machines, with different address spaces And perhaps different environments.. or operating systems.. Must convert to local representation of data Machines and network can fail

Marshaling and Unmarshaling (From example) hotnl() -- host to network-byte-order, long. network-byte-order (big-endian) standardized to deal with cross-platform variance Note how we arbitrarily decided to send the string by sending its length followed by L bytes of the string? That s marshalling, too. Floating point... Nested structures? (Design question for the RPC system - do you support them?) Complex datastructures? (Some RPC systems let you send lists and maps as firstorder objects)

stubs and IDLs RPC stubs do the work of marshaling and unmarshaling data But how do they know how to do it? Typically: Write a description of the function signature using an IDL -- interface definition language. Lots of these. Some look like C, some look like XML,... details don t matter much.

SunRPC Venerable, widely-used RPC system Defines XDR ( external Data Representation ) -- C-like language for describing functions -- and provides a compiler that creates stubs struct fooargs { string msg<255>; int baz; }

And describes functions program FOOPROG { version VERSION { void FOO(fooargs) = 1; void BAR(barargs) = 2; } = 1; } = 9999;

More requirements Provide reliable transmission (or indicate failure) May have a runtime that handles this Authentication, encryption, etc. Nice when you can add encryption to your system by changing a few lines in your IDL file (it s never really that simple, of course -- identity/key management)

RPC vs. LPC 24 Memory access Partial failures Latency

But it s not always simple Properties of distributed computing that make achieving transparency difficult: Calling and called procedures run on different machines, with different address spaces Machines and network can fail Latency

Passing Reference Parameters 26 Replace with pass by copy/restore Need to know size of data to copy Difficult in some programming languages Solves the problem only partially What about data structures containing pointers? Access to memory in general?

Partial failures 27 In local computing: if machine fails, application fails In distributed computing: if a machine fails, part of application fails one cannot tell the difference between a machine failure and network failure How to make partial failures transparent to client?

RPC failures Request from cli -> srv lost Reply from srv -> cli lost Server crashes after receiving request Client crashes after sending request

Strawman solution 29 Make remote behavior identical to local behavior: Every partial failure results in complete failure You abort and reboot the whole system You wait patiently until system is repaired Problems with this solution: Many catastrophic failures Clients block for long periods System might not be able to recover

Real solution: break transparency 30 Possible semantics for RPC: Exactly-once Impossible in practice At least once: Only for idempotent operations At most once Zero, don t know, or once Zero or once Transactional semantics At-most-once most practical But different from LPC

RPC semantics: Exactly-Once? Sorry - no can do in general. Imagine that message triggers an external physical thing (say, a robot fires a missle) The robot could crash immediately before or after firing and lose its state. Don t know which one happened. Can, however, make this window very small.

RPC semantics At-least-once semantics Keep retrying... At-most-once Use a sequence # to ensure idempotency against network retransmissions and remember it at the server

Implementing at-most-once At-least-once: Just keep retrying on client side until you get a response. Server just processes requests as normal, doesn t remember anything. Simple! At-most-once: Server might get same request twice... Must re-send previous reply and not process request (implies: keep cache of handled requests/responses) Must be able to identify requests Strawman: remember all RPC IDs handled. -> Ugh! Requires infinite memory. Real: Keep sliding window of valid RPC IDs, have client number them sequentially.

Summary: 34 expose remoteness to client Expose RPC properties to client, since you cannot hide them Application writers have to decide how to deal with partial failures Consider: E-commerce application vs. game

35 RPC implementation issues

RPC implementation 36 Stub compiler Generates stubs for client and server Language dependent Compile into machine-independent format E.g., XDR Format describes types and values RPC protocol RPC transport

Writing a Client and a Server (1) 37 The steps in writing a client and a server in DCE RPC.

Writing a Client and a Server (2) 38 Three files output by the IDL compiler: A header file (e.g., interface.h, in C terms). The client stub. The server stub.

RPC protocol 39 Guarantee at-most-once semantics by tagging requests and response wit h a nonce RPC request header: Request nonce Service Identifier Call identifier Protocol: Client resends after time out Server maintains table of nonces and replies

RPC transport 40 Use reliable transport layer Flow control Congestion control Reliable message transfer Combine RPC and transport protocol Reduce number of messages RPC response can also function as acknowledgement for message transport protocol

Performance As a general library, performance is often a big concern for RPC systems Major source of overhead: copies and marshaling/unmarshaling overhead Zero-copy tricks: Representation: Send on the wire in native format and indicate that format with a bit/byte beforehand. What does this do? Think about sending uint32 between two little-endian machines Scatter-gather writes (writev() and friends)

Complex / Pointer Data Structures Very few low-level RPC systems support C is messy about things like that -- can t always understand the structure and know where to stop chasing Java RMI (and many other higher-level languages) allows sending objects as part of an RPC But be careful - don t want to send megabytes of data across network to ask simple question!

Important Lessons 43 Procedure calls Simple way to pass control and data Elegant transparent way to distribute application Not only way Hard to provide true transparency Failures Performance Memory access Etc. How to deal with hard problem give up and let programmer deal with it Worse is better