Remote Procedure Calls. 2 Announcements Prelim II coming up in one week: –Thursday, April 26 th, 7:30—9:00pm, 1½ hour exam –101 Phillips –Closed book,

Slides:



Advertisements
Similar presentations
RPC Robert Grimm New York University Remote Procedure Calls.
Advertisements

Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
Tam Vu Remote Procedure Call CISC 879 – Spring 03 Tam Vu March 06, 03.
Remote Procedure CallCS-4513, D-Term Remote Procedure Call CS-4513 Distributed Computing Systems (Slides include materials from Operating System.
G Robert Grimm New York University Lightweight RPC.
Tutorials 2 A programmer can use two approaches when designing a distributed application. Describe what are they? Communication-Oriented Design Begin with.
Distributed File Systems: RPC, NFS, and AFS
Implementing Remote Procedure Calls Authors: Andrew D. Birrell and Bruce Jay Nelson Xerox Palo Alto Research Center Presenter: Jim Santmyer Thanks to:
CS490T Advanced Tablet Platform Applications Network Programming Evolution.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: Distributed Objects.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Remote Procedure Call November 20, 2006 Prof. John Kubiatowicz.
© 2007 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.1 Computer Networks and Internets with Internet Applications, 4e By Douglas.
490dp Prelude: Design Report Remote Invocation Robert Grimm (borrowing some from Hank Levy)
Communication in Distributed Systems –Part 2
Remote Procedure Calls. 2 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs)
Lecture 8 Epidemic communication, Server implementation.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Remote Procedure Call November 21, 2007 Prof. John Kubiatowicz.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 12 Communicating over.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
COSC 3407: Operating Systems
CSC139 Operating Systems Lecture 23 Remote Procedure Call Adapted from Prof. John Kubiatowicz's lecture notes for CS162
Remote Procedure CallCS-502 Fall Remote Procedure Call CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System Concepts,
Jozef Goetz, Application Layer PART VI Jozef Goetz, Position of application layer The application layer enables the user, whether human.
CS 390- Unix Programming Environment CS 390 Unix Programming Environment Topics to be covered: Distributed Computing Fundamentals.
CS 153 Design of Operating Systems Spring 2015 Lecture 23: Inter-Process Communication (IPC) and Remote Procedure Call (RPC)
Implementing Remote Procedure Calls Authored by Andrew D. Birrell and Bruce Jay Nelson Xerox Palo Alto Research Center Presented by Lars Larsson.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
1 Lecture 5 (part2) : “Interprocess communication” n reasons for process cooperation n types of message passing n direct and indirect message passing n.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Distributed Programming November 22, 2010 Prof. John Kubiatowicz.
 Remote Procedure Call (RPC) is a high-level model for client-sever communication.  It provides the programmers with a familiar mechanism for building.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved RPC Tanenbaum.
IT 344: Operating Systems Winter 2008 Module 19 Networking & Remote Procedure Call (RPC) Chia-Chi Teng CTB 265.
CSE 451: Operating Systems Winter 2015 Module 22 Remote Procedure Call (RPC) Mark Zbikowski Allen Center 476 © 2013 Gribble, Lazowska,
Distributed Computing A Programmer’s Perspective.
Hwajung Lee.  Interprocess Communication (IPC) is at the heart of distributed computing.  Processes and Threads  Process is the execution of a program.
Remote Procedure CallCS-502 Fall Remote Procedure Call (continued) CS-502, Operating Systems Fall 2007 (Slides include materials from Operating System.
Remote Procedure Call Andy Wang Operating Systems COP 4610 / CGS 5765.
Networking Implementations (part 1) CPS210 Spring 2006.
Mark Stanovich Operating Systems COP Primitives to Build Distributed Applications send and receive Used to synchronize cooperating processes running.
Lecture 4 Mechanisms & Kernel for NOSs. Mechanisms for Network Operating Systems  Network operating systems provide three basic mechanisms that support.
Implementing Remote Procedure Call Landon Cox February 12, 2016.
© Oxford University Press 2011 DISTRIBUTED COMPUTING Sunita Mahajan Sunita Mahajan, Principal, Institute of Computer Science, MET League of Colleges, Mumbai.
Distributed Computing & Embedded Systems Chapter 4: Remote Method Invocation Dr. Umair Ali Khan.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
Prof. Leonardo Mostarda University of Camerino
IPC and RPC.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Remote Procedure Call April 28, 2008 Prof. Anthony D.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Remote Procedure Call November 21, 2005 Prof. John Kubiatowicz.
CS162 Operating Systems and Systems Programming Lecture 23 Network Communication Abstractions / Distributed Programming November 25, 2009 Prof. John Kubiatowicz.
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CS162 Operating Systems and Systems Programming Lecture 22 Networking II April 23, 2008 Prof. Anthony D. Joseph
DISTRIBUTED COMPUTING
Lecture 4: RPC Remote Procedure Call Coulouris et al: Chapter 5
Sarah Diesburg Operating Systems COP 4610
CSE 451: Operating Systems Autumn 2003 Lecture 16 RPC
CSE 451: Operating Systems Winter 2007 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Lecture 4: RPC Remote Procedure Call CDK: Chapter 5
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Spring 2012 Module 22 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote Procedure Call Hank Levy 1.
CS162 Operating Systems and Systems Programming Lecture 23 Remote Procedure Call April 19, 2005 Prof. Anthony D. Joseph
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CS162 Operating Systems and Systems Programming Lecture 24 Network Communication Abstractions / Distributed Programming November 24, 2008 Prof. John Kubiatowicz.
CSE 451: Operating Systems Winter 2003 Lecture 16 RPC
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

Remote Procedure Calls

2 Announcements Prelim II coming up in one week: –Thursday, April 26 th, 7:30—9:00pm, 1½ hour exam –101 Phillips –Closed book, no calculators/PDAs/… –Bring ID Topics: –Since last Prelim, up to (and including) Monday, April 23 rd –Lectures 19-34, chapters (7 th ed) Project 5 due after Prelim II, Monday, April 30 th –Make sure to look at the lecture schedule to keep up with due dates!

3 Review: Use of TCP: Sockets Socket: an abstraction of a network I/O queue –Embodies one side of a communication channel Same interface regardless of location of other end Could be local machine (called “UNIX socket”) or remote machine (called “network socket”) –First introduced in 4.2 BSD UNIX: big innovation at time Now most operating systems provide some notion of socket Using Sockets for Client-Server (C/C++ interface): –On server: set up “server-socket” Create socket, Bind to protocol (TCP), local address, port call listen(): tells server socket to accept incoming requests Perform multiple accept() calls on socket to accept incoming connection request Each successful accept() returns a new socket for a new connection; can pass this off to handler thread –On client: Create socket, Bind to protocol (TCP), remote address, port Perform connect() on socket to make connection If connect() successful, have socket connected to server

4 Server Socket socket connection Request Connection new socket ServerClient Socket Setup (Con’t) Things to remember: –Connection requires 5 values: [ Src Addr, Src Port, Dst Addr, Dst Port, Protocol ] –Often, Src Port “randomly” assigned Done by OS during client socket setup –Dst Port often “well known” 80 (web), 443 (secure web), 25 (sendmail), etc Well-known ports from 0—1023

5 Socket Example (Java) server: //Makes socket, binds addr/port, calls listen() ServerSocket sock = new ServerSocket(6013); while(true) { Socket client = sock.accept(); PrintWriter pout = new PrintWriter(client.getOutputStream(),true); pout.println(“Here is data sent to client!”); … client.close(); } client: // Makes socket, binds addr/port, calls connect() Socket sock = new Socket(“ ”,6018); BufferedReader bin = new BufferedReader( new InputStreamReader(sock.getInputStream)); String line; while ((line = bin.readLine())!=null) System.out.println(line); sock.close();

6 Goals for Today Implementing Distributed Applications Messages –Send/receive –One vs. two-way communication Remote Procedure Call

7 Distributed Applications How do you actually program a distributed application? –Need to synchronize multiple threads, running on different machines No shared memory, so cannot use test&set –One Abstraction: send/receive messages Already atomic: no receiver gets portion of a message and two receivers cannot get same message Interface: –Mailbox ( mbox ): temporary holding area for messages Includes both destination location and queue For example, mbox is kernel buffer associated with a Socket –Send(message,mbox) Send message to remote mailbox identified by mbox –Receive(buffer,mbox) Wait until mbox has message, copy into buffer, and return If threads sleeping on this mbox, wake up one of them Network Send Receive

8 Using Messages: Send/Recv behavior When should send(message,mbox) return? –When receiver gets message? (i.e. ack received) –When message is safely buffered on destination? –Right away, if message is buffered on source node? Actually two questions here: –When can the sender be sure that receive actually received the message? –When can sender reuse the memory containing message? Mailbox provides 1-way communication from P1  P2 –P1  buffer  P2 –Very similar to producer/consumer Send = V (i.e. signal) Receive = P (i.e. wait) However, can’t tell if sender/receiver is local or not!

9 Messages for Producer-Consumer Using send/receive for producer-consumer style: Producer: int msg1[1000]; while(1) { prepare message; send(msg1,mbox); } Consumer: int buffer[1000]; while(1) { receive(buffer,mbox); process message; } No need for producer/consumer to keep track of space in mailbox: handled by send/receive –One of the roles of the window in TCP: window is size of buffer on far end –Restricts sender to forward only what will fit in buffer Send Message Receive Message

10 Messages for Req/Resp comm. What about two-way communication? –Request/Response Read a file stored on a remote machine Request a web page from a remote web server –Also called: client-server Client  requester, Server  responder Server provides “service” (file storage) to the client Example: File service Client: (requesting the file) char response[1000]; send(“read rutabaga”, server_mbox); receive(response, client_mbox); Server: (responding with the file) char command[1000], answer[1000]; receive(command, server_mbox); decode command; read file into answer; send(answer, client_mbox); Request File Get Response Receive Request Send Response

11 Client/Server Paradigm Common model for structuring distributed computations A server is a program (or collection of programs) that –provides some service, e.g., file service, name service, … –may exist on one or more nodes. A client is a program that uses the service. –It first binds to the server, i.e., locates it in the network and establishes a connection. The client then sends requests to perform actions; –Using messages to indicate the desired service and params. –The server returns a response.

12 Why not use messages? Although messages are flexible, they have problems: –Requires that programmer worry about message formats –Messages must be packed and unpacked –Server needs to decode messages to figure out the request –Messages are often asynchronous –They may require special error handling functions Basically using messages is not a convenient paradigm for most programmers.

13 Procedure Call More natural way is to communicate using procedure calls: –every language supports it –semantics are well defined and understood –natural for programmers to use Basic idea: define server as a module that exports a set of procedures callable by client programs. To use the server, the client just does a procedure call, as if it were linked with the server call return ClientServer

14 (Remote) Procedure Call So, we would like to use procedure call as a model for distributed communication. Lots of issues: –how do we make this invisible to the programmer? –what are the semantics of parameter passing? –how is binding done (locating the server)? –how do we support heterogeneity (OS, arch., language) –etc.

15 Remote Procedure Call The basic model for Remote Procedure Call (RPC) was described by Birrell and Nelson in 1980, based on work done at Xerox PARC. Goal to make RPC as much like local PC as possible. Used computer/language support. There are 3 components on each side: –a user program (client or server) –a set of stub procedures –RPC runtime support

16 RPC Basic process for building a server: –Server program defines the server’s interface using an interface definition language (IDL) –The IDL specifies the names, parameters, and types for all client- callable server procedures –A stub compiler reads the IDL and produces two stub procedures for each server procedure: a client-side stub and a server-side stub –The server writer writes the server and links it with the server-side stubs; the client writes her program and links it with the client-side stubs. –The stubs are responsible for managing all details of the remote communication between client and server.

17 RPC Stubs Client-side stub is a procedure that looks to the client as if it were a callable server procedure. Server-side stub looks like a calling client to the server The client program thinks it is calling the server; –in fact, it’s calling the client stub. The server program thinks it’s called by the client; –in fact, it’s called by the server stub. The stubs send messages to each other to make RPC happen.

18 RPC Call Structure call foo(x,y) proc foo(a,b)call foo(x,y) proc foo(a,b) begin foo... end foo client program client stub RPC runtime RPC runtime server stub server program Call client makes local call to stub proc. stub builds msg packet, inserts params runtime sends msg to remote node server is called by its stub stub unpacks params and makes call runtime receives msg and calls stub call foo send msg call foo msg received

19 RPC Return Structure call foo(x,y) proc foo(a,b)call foo(x,y) proc foo(a,b) begin foo... end foo client program client stub RPC runtime RPC runtime server stub server program return client continues stub unpacks msg, returns to caller runtime receives msg, calls stub server proc returns stub builds result msg with output args runtime responds to original msg return msg received return send msg

20 RPC Information Flow Client (caller) Server (callee) RPC Runtime RPC Runtime call return send receive send receive return call Network Client Stub marshal args marshal return values unmarshal ret vals Server Stub unmarshal args Machine A Machine B mbox1 mbox2

21 RPC Binding Binding is the process of connecting the client and server The server, when it starts up, exports its interface, –identifying itself to a network name server and –telling the local runtime its dispatcher address. The client, before issuing any calls, imports the server, –which causes the RPC runtime to lookup the server through the name service and –contact the requested server to setup a connection. The import and export are explicit calls in the code.

22 RPC Marshalling Marshalling is packing of procedure params into message packet. RPC stubs call type-specific procedures to marshall (or unmarshall) all of the parameters to the call. On client side, client stub marshalls parameters into call packet; –On the server side the server stub unmarshalls the parameters to call the server’s procedure. On return, server stub marshalls return parameters into return packet; –Client stub unmarshalls return params and returns to the client.

23 Problems with RPC Non-Atomic failures –Different failure modes in distributed system than on a single machine –Consider many different types of failures User-level bug causes address space to crash Machine failure, kernel bug causes all processes on same machine to fail Some machine is compromised by malicious party –Before RPC: whole system would crash/die –After RPC: One machine crashes/compromised while others keep working –Can easily result in inconsistent view of the world Did my cached data get written back or not? Did server do what I requested or not? –Answer? Distributed transactions/Byzantine Commit Performance –Cost of Procedure call « same-machine RPC « network RPC –Means programmers must be aware that RPC is not free Caching can help, but may make failure handling complex

24 Cross-Domain Comm./Location Transparency How do address spaces communicate with one another? –Shared Memory with Semaphores, monitors, etc… –File System –Pipes (1-way communication) –“Remote” procedure call (2-way communication) RPC’s can be used to communicate between address spaces on different machines or the same machine –Services can be run wherever it’s most appropriate –Access to local and remote services looks the same Examples of modern RPC systems: –CORBA (Common Object Request Broker Architecture) –DCOM (Distributed COM) –RMI (Java Remote Method Invocation)

25 Microkernel operating systems Example: split kernel into application-level servers. –File system looks remote, even though on same machine Why split the OS into separate domains? –Fault isolation: bugs are more isolated (build a firewall) –Enforces modularity: allows incremental upgrades of pieces of software (client or server) –Location transparent: service can be local or remote For example in the X windowing system: Each X client can be on a separate machine from X server; Neither has to run on the machine with the frame buffer. App file system Windowing Networking VM Threads App Monolithic Structure App File sys windows RPC address spaces threads Microkernel Structure

26 Summary Remote Procedure Call (RPC): Call procedure on remote machine –Provides same interface as procedure –Automatic packing and unpacking of arguments without user programming (in stub) RPC is most common model now for communications in distributed applications. –It is language support for distributed programming. RPC relies on a stub compiler to automatically produce client/server stubs from the IDL server description. RPC is commonly used, even on a single node, for communication between applications running in different address spaces. In fact, most RPCs are intra-node.