Remote Procedure CallOutlineIntroductionSlide 4Slide 5The RPC modelRPC MechanismsSlide 8Slide 9Slide 10BenefitsCharacteristicsDesign issuesParameter passingRepresenting dataSlide 16BindingFailuresDelivery guaranteesCall SemanticsSlide 21Slide 22Slide 23More issuesProgramming with RPCSlide 26Slide 27Case Studies: SUN RPCReferencesThank you!1Remote Procedure CallCISC 879 – Spring 03Tam Vu ([email protected])March 06, 032OutlineIntroductionRPC mechanismsDesign issuesProgramming with RPCCase study: SUN RPC3IntroductionProblem with socketsSocket interface is straightforwardConnectRead/writeDisconnectForces read/write mechanismNot how we generally programWe usually use procedure callsTo make distributed computing look more like centralized:I/O is not the way to go4Introduction1984: Birrell & NelsonMechanisms to call procedures on other machinesProcesses on machine A can call procedures on machine BA is suspendedExecution continues on BWhen B returns, control passed back to AGoal: it appears to the programmer that a normal call is taking place5IntroductionRemote Procedure Call (RPC) is a high-level model for client-sever communication.RPC enables clients to communicate with servers by calling procedures in a similar way to the conventional use of procedure calls in high-level languages.Examples: File service, Authentication service.6The RPC modelBlocking stateclientserverrequestreplyExecuting stateCalls procedure and wait for replyReceives request and starts process executionSends reply and wait for next executionResumes execution7RPC MechanismsThe client transfer call request (the procedure name) and the arguments to the server via client stub functionstub function marshals arguments and places them into a message together with the remote procedure identifier.Sends message to server and waits for call return8RPC MechanismsServer receives the call request and passes to an appropriate server stub function.server stub function unmarshals the arguments, call the corresponding (local) service procedure.On return, the server stub marshals the output arguments into a call return message and sends back to the client.9RPC MechanismsClient stub receives call reply, unmarshals value, returns to client code10RPC Mechanismsclient stubfunc.CommunicationmoduleLocal returnLocal callClient computerServer computerserver stubfunc.client service procedureReceivereplySendrequestUnmarshalresultsMarshalargumentsReceiverequestSendreplySelect procedureUnmarshalargumentsMarshalresultsExecute procedure11BenefitsFamiliar procedure call interfaceWriting applications is simplifiedRPC hides all networks codesProgrammers don’t have to worry about details (sockets, port numbers, byte ordering)RPC: presentation layer in OSI model12CharacteristicsThe called procedure is in another process which may reside in another machine.The processes do not share address space.Passing of parameters by reference and passing pointer values make no sense.The called remote procedure executes within the environment of the server process. The called procedure does not have access to the calling procedure's environment.13Design issues14Parameter passingBy values easy, just copy data to network message.By referencemakes no sense without shared memoryTrickCopy items referenced to message bufferShip them overUnmarshal data at serverPass local pointer to server stub functionSend new value back15Representing dataNo such things as incompatibility on local systemsRemote machine may have:Different byte orderingDifferent sizes of integers and other typesDifferent floating point representationsDifferent character setsNeed standard encoding to enable communication between heterogeneous systems16Representing dataImplicit typingOnly values are transmitted, not data type or parameter informationE.g., Sun XDR (eXternal Data Representation)Explicit typingTypes are transmitted with valuesE.g., ISO ANS.1, XML17BindingHow to locate host and server process?Solution 1: use a central DBServer sends message to central DB indicating the services it can offerClients contact this authority whenever they need to locate a serviceSolution 2:Client needs to know server nameServer maintains a DB of available services18FailuresLocal procedure calls do not failIf they core dump, the entire process diesRPC is more vulnerable to failure:Server could generate errorsProblems in networkServer crashClient crash while server is still running code for itTransparency breaks hereApplications should be prepared to deal with RPC failure19Delivery guaranteesRetry request message: Client retransmits the request message until either a reply or the server is assumed to have failed.Duplicate filtering : server filters out duplicate message.Retransmission of replies: Server keeps a history of reply messages to enable lost replies retransmitted without re-executing the server operations.20Call SemanticsSemantic of local procedure calls: exactly-onceExactly-once maybe difficult to achieve with RPCAt-least-onceThe client assumes that the RP is executed at least once (on return from the RP).Can be implemented by retransmission of the request message on time-out. Acceptable only if the server’s operations are idempotent. That is f(x) = f(f(x)).21Call SemanticsAt-most-onceWhen a RPC returns, the remote procedure (RP) is assume to have been called exactly once or not at all.Implemented by the server's filtering of duplicate requests and caching of replies.22Call SemanticsAt-most-onceThis ensure the RP is called exactly once if the server does not crash during execution of the RP. When the server crashes during the RP's execution, the partial execution may lead to erroneous results. In this case, we want the effect that the RP has not been executed at all.23Call Semantics24More issuesPerformanceremote procedure call and return time can be significantly slower than that for local procedure call (1 - 3 orders of magnitude).SecurityMessages visible over the networkAuthenticate clientAuthenticate server25Programming with RPCMost languages (C, C++, Java,…) have no concept of remote procedure callsLanguage compilers will not generate client and server
View Full Document