220 likes | 239 Views
Operating Systems CMPSCI 377 Lecture 20: Distributed Systems (RPC). Emery Berger University of Massachusetts Amherst. Today. Key challenges to distribution in operating systems Resource sharing Timing (synchronization) Critical sections Deadlock detection & recovery Failure recovery.
E N D
Operating SystemsCMPSCI 377Lecture 20: Distributed Systems (RPC) Emery Berger University of Massachusetts Amherst
Today • Key challenges to distribution in operating systems • Resource sharing • Timing (synchronization) • Critical sections • Deadlock detection & recovery • Failure recovery
Computation vs. Communication • Communication fast & cheap )can utilize all resources in distributed environment • Communication slow & expensive )do most processing locally • Reality: somewhere in the middle • Where are the tradeoffs?
Resource Sharing • Data migration: move data • Computation migration: move computation to data • Job migration: move job (computation & data) • Fundamental tradeoff: speed vs. cost
Data Migration: Copying • Process at site A accesses file at site B =copy file B to process A • Costly if file is large • Data format conversion • Multiple copies )consistency problems • All subsequent accesses at A are local
Data Migration: Remote Access • Keep file at B, access remotely from A • Saves file transfer cost • Converting may be difficult in pieces • Single copy of file = no consistency problems • Performance bottleneck
Computation Migration • More efficient to transfer computation than data • Example: database query • Motivates remote procedure calls (RPC) • A sends message to process at B • Process performs requested action • Sends result back to A
Job Migration • May be required: • Job needs hardware somewhere in system • Job requires licensed software • Can improve performance: • Load balancing: • Even workload across distributed system • Computational speedup: • Concurrent (parallel) execution of parts of job
Client/Server Model • Common structure for distributed computation • Server: process/processes providing service • Name servers, file servers, database server • May exist on more than one node • Client uses service • Binds to server • locates on network, establishes connection • Request-response interaction • May use RPC
Remote Procedure Call • Servers export procedures for clients to call • Client does procedure call to use server • OS manages communication
RPC Implementation Issues • For each procedure for which we want to support RPC: • RPC mechanism uses procedure signature(number & type of args & return value) • Generates client stub: bundles RPC arguments, sends to server • Generates server stub: unpacks message, invokes procedure call
RPC: Implementation Issues client stub:build messagesend messageawait responseunpack replyreturn result server stub:create threadsloop await command unpack message call proc. w/thread build reply send reply
RPC Binding • How does client know right port? • Binding may be static (fixed at compile-time) • Or dynamic (fixed at run-time) • Most RPC systems: dynamic binding via name service • Server exports interface, identifies itself to net • Client asks name service for location of server, establishes connection
Example: Java RMI public static void bind(String name, Remote obj) • Binds server to name public static Remote lookup(String name) • Returns server object corresponding to name UnicastRemoteObject supports references to non-replicated objects using TCP • Exports interface automatically when server object is constructed • Tools: • rmiregistry server-side name server • rmic: given server interface, generates client & server stubs that create & interpret packets
Example: Server in Java • Server • Defines interface listing method signatures • Implements each method in interface • Main: • Creates one or more server objects (subclasses of RemoteObject) • Registers objects with remote object registry • Client • Looks up server in remote object registry • Uses normal method call syntax for remote methods • Handles RemoteException
Summary • Data, computation, job migration • Client-server model • Mechanism: RPC • Common model for communication in distributed apps • Effectively: language support for distribution • Relies on stub compiler • Used even on single nodes for communication across address spaces
Next Time • Distributed File Systems