[go: up one dir, main page]

0% found this document useful (0 votes)
28 views18 pages

RPC, RMI, and Naming in Distributed Systems

The document provides an overview of Remote Procedure Calls (RPC) and Remote Method Invocation (RMI) in distributed systems, detailing how they work, their differences, and challenges faced. It also discusses naming in distributed systems, including types of naming and services like DNS and RMI Registry. Additionally, it compares RPC, RMI, and naming in terms of programming paradigm, language dependency, and use cases.

Uploaded by

Kashmala Alam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views18 pages

RPC, RMI, and Naming in Distributed Systems

The document provides an overview of Remote Procedure Calls (RPC) and Remote Method Invocation (RMI) in distributed systems, detailing how they work, their differences, and challenges faced. It also discusses naming in distributed systems, including types of naming and services like DNS and RMI Registry. Additionally, it compares RPC, RMI, and naming in terms of programming paradigm, language dependency, and use cases.

Uploaded by

Kashmala Alam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Remote Procedure Calls (RPC), RMI,

and Naming in Distributed Systems

Prepared By Miangul Shafiq Ahmad Jan


Contents:

• Introduction to Remote Procedure Calls (RPC)


• How RPC Works
• Synchronous vs. Asynchronous RPC
• RPC Protocols
• Challenges in RPC
• Introduction to Remote Method Invocation (RMI)
• Differences Between RPC and RMI
• How RMI Works
• Naming in Distributed Systems
• Comparison of RPC, RMI, and Naming
1. Remote Procedure Calls (RPC)

What is RPC?
• Remote Procedure Call (RPC) is a protocol that one program can use to request a
service from a program located on another computer within a network. The key
idea is to make network communication look like normal function calls.
• It allows procedures (or functions) to be executed in a different address space,
typically on a remote machine, without the programmer explicitly coding for the
details of remote communication.
In simple terms, you write code as if the procedure is local, but it gets executed on a
different machine.
How Remote Procedure Calls (RPC) Works ?

1. Client-Server Architecture: RPC operates using a client-server model. A client sends a request to a server to
execute a procedure, and the server sends back a response.
2. Stubs: The client stub is a local procedure on the client’s machine, acting as a proxy for the actual remote
procedure. The server stub resides on the server side and communicates with the actual procedure that needs to
be executed.
3. Steps of an RPC call:
o Client Procedure Call: The client program calls the local stub, thinking it’s calling a local function.
o Marshalling: The client stub marshals (packs) the procedure parameters into a message and sends it to the
server.
o Server Reception: The server stub unmarshals (unpacks) the parameters and calls the actual server
procedure.
o Procedure Execution: The server executes the requested procedure.
o Response: The server stub marshals the response and sends it back to the client.
o Client Reception: The client stub unmarshals the response and gives the result to the calling procedure.
Synchronous vs Asynchronous RPC

• Synchronous RPC: The client waits (or blocks) for the server’s response after
making the procedure call.
• Asynchronous RPC: The client continues its execution without waiting for the
server to respond, allowing non-blocking behavior.
RPC Protocols
• ONC RPC (Open Network Computing): Developed by Sun Microsystems, it is a
widely used protocol that supports RPC over TCP or UDP.
• GRPC(Google Remote Procedure call): A modern open-source RPC framework
developed by Google, which uses HTTP/2 for transport, Protocol Buffers as the
interface description language, and can work with multiple programming
languages.
Challenges in RPC

• Transparency: One of the goals of RPC is to make remote communication look like
local procedure calls. However, there are challenges such as handling network
failures and latency.
• Failure Handling: RPC has to deal with failure cases such as:
o Client Failure: The server does not receive the request.
o Server Failure: The client does not receive the response.
o Network Partitioning: Loss of network connection between client and server.
2. Remote Method Invocation (RMI)

What is RMI?
• Remote Method Invocation (RMI) is Java’s implementation of remote procedure
calls that supports object-oriented programming. While RPC allows you to call
procedures remotely, RMI allows you to invoke methods on a remote object as if
the object were local.
Key Differences Between RPC and RMI

• Object-Oriented: Unlike RPC, which is procedural, RMI is inherently object-


oriented, meaning you can invoke methods on remote objects.
• Distributed Objects: In RMI, objects can be passed as parameters and returned as
results. The server can return a reference to a remote object, and the client can
invoke methods on that object.
• Language Dependency: RMI is Java-specific, while RPC can be language-agnostic.
How RMI Works ?

The architecture of RMI is similar to RPC but adapted to object-oriented principles:


1. Client-Side Stub: The client invokes a method on a stub, which is a local
representation of the remote object.
2. Marshalling: The stub marshals the method call into a message (including method
parameters) and sends it to the server.
3. Skeleton: On the server side, the skeleton unmarshals the message and invokes
the method on the actual remote object.
4. Response: The method result is marshaled back and returned to the client.
RMI Components

• RMI Registry: This is a simple name service that allows clients to look up remote
objects by name. It acts as a directory where the server registers its remote
objects.
• Remote Object: The object that resides on the server and can be invoked by
remote clients.
• Stub and Skeleton: They handle the communication between the client and the
remote object. In recent versions of Java, skeletons are not required, and reflection
is used to invoke methods.
Advantages and Disadvantages of RMI

Advantages:
• Allows for easy distribution of objects in a Java-based distributed system.
• Supports object passing (including remote references).
Disadvantages:
• Limited to Java (language-dependent).
• More complex to manage due to the need for managing remote objects and
references.
3. Naming in Distributed Systems

In a distributed system, entities (computers, services, objects, files, etc.) are spread
across different locations. Naming is a critical component that allows these distributed
entities to be located and accessed.
The Importance of Naming
• Naming provides a way to uniquely identify resources in a distributed system, such
as computers, files, services, or users.
• Location Transparency: The goal of a good naming system is to provide location
transparency, meaning that users and applications don’t need to know where a
resource is located; they just need its name.
Types of Naming in Distributed Systems

1. Flat Naming: A simple system where every entity is given a unique identifier (e.g.,
IP addresses). However, these names are not human-readable and can be hard to
remember.
2. Hierarchical Naming: This is used to make naming more manageable by breaking
names into components, like a tree structure (e.g., URLs or file paths). For
example, [Link] is a hierarchical name.
3. Attribute-Based Naming: In this system, objects are identified by a set of attributes
rather than by a single identifier (e.g., resource discovery in a cloud environment,
where resources are found based on attributes such as type, location, or
availability).
Naming Services

• Domain Name System (DNS): The most widely used hierarchical naming service on
the Internet. It maps human-readable names (e.g., [Link]) to IP
addresses.
• RMI Registry: A naming service that helps clients locate remote objects by name in
Java RMI.
• Directory Services: These provide more functionality than naming services by
associating names with attributes (e.g., LDAP – Lightweight Directory Access
Protocol).
Challenges in Naming Systems

• Scalability: The naming system must scale to accommodate large numbers of


resources.
• Consistency and Fault Tolerance: The naming service should be available and
consistent, even in the presence of network partitions or server failures.
• Name Resolution: Resolving a name to its corresponding resource should be fast
and efficient.
Comparison of RPC, RMI, and Naming
Feature RPC RMI Naming
Identification of
Programming
Procedural Object-Oriented entities in a
Paradigm
distributed system
Independent of
Language Can be language-
Java-specific programming
Dependency independent
language
Procedure call Method invocation Provides location
Transparency
transparency transparency transparency
General-purpose Object-oriented Accessing distributed
Use Case remote procedure distributed resources using
execution applications unique names

You might also like