DSnotes
DSnotes
Client-Server System
A client-server system consists of client machines that request services and a central server that
provides those services.
Advantages
Disadvantages
In a peer-to-peer system, all nodes are equal — they act as both clients and servers, sharing
resources without a central coordinator.
Advantages
Highly scalable.
No single point of failure.
Cost-effective as no centralized server is needed.
Disadvantages
A three-tier system separates functionality into three layers: presentation (client), logic
(application server), and data (database server).
Advantages
Disadvantages
A distributed computing system involves multiple computers working together to solve a large
computational problem.
Advantages
Disadvantages
Key Features
Examples
Advantages
Disadvantages
🔷 Grid Computing
Definition
Grid computing is a distributed computing system where geographically
dispersed and heterogeneous systems work together to solve a large-scale task. It
pools resources from different administrative domains.
Key Features
Examples
Advantages
Disadvantages
Distributed OS Architecture
1. Client-Server Architecture
✅ Description
Tasks are divided between clients (which request services) and servers
(which provide services).
Servers manage resources like files, databases, printers, etc.
Clients interact with servers over the network.
📊 Use Case
📌 Pros
Simple to design.
Centralized resource management.
❌ Cons
✅ Description
📊 Use Case
📌 Pros
Fault tolerant.
Scalable and decentralized.
❌ Cons
📊 Use Case
📌 Pros
OS architecture refers to the internal design and structure of the operating system, describing
how its components are organized, how they interact, and how the OS manages hardware and
software resources.
Types of OS Architecture
🔹 1. Monolithic Architecture
✅ Description
✅ Advantages
❌ Disadvantages
🔹 2. Layered Architecture
✅ Description
The OS is divided into layers, each built on top of the lower one.
Each layer only interacts with the layer directly beneath or above it.
📌 Examples: THE operating system, some versions of UNIX
✅ Advantages
❌ Disadvantages
🔹 3. Microkernel Architecture
✅ Description
Only the essential parts (like memory, CPU scheduling, IPC) run in the kernel.
Other services (file system, drivers) run in user space as separate processes.
✅ Advantages
❌ Disadvantages
🔹 4. Modular Architecture
✅ Description
Like monolithic, but components are organized as modules that can be loaded/unloaded
dynamically.
📌 Examples: Modern Linux kernel
✅ Advantages
❌ Disadvantages
🔹 5. Hybrid Architecture
✅ Description
✅ Advantages
❌ Disadvantages
Instead of downloading a file from one server, BitTorrent allows users (called peers) to
download and upload parts of the file simultaneously from and to each other.
Term Description
Peer A computer participating in the file sharing process.
Seeder A peer that has the complete file and is sharing it.
Leecher A peer that is downloading the file (may also upload parts).
Tracker A server that coordinates peers by keeping track of who has what pieces.
Swarm The group of peers sharing the same file.
Torrent File A small file containing metadata (file info and tracker address).
Piece The file is divided into small chunks (pieces) which are shared individually.
⚙️Working Mechanism
1. User downloads a .torrent file that contains metadata (not the actual content).
2. The BitTorrent client contacts a tracker to get a list of peers.
3. The client connects to multiple peers and starts downloading pieces of the file.
4. Once a peer gets a piece, it can immediately start uploading it to others.
5. The more peers, the faster the distribution (more sources to download from).
Think of middleware as the "glue" that connects different parts of a distributed system and helps
them work together smoothly.
🧩 Functions of Middleware
Function Description
Communication Handles message passing between different components or services.
Security Manages authentication, authorization, and data encryption.
Allows different systems to access files, databases, or devices
Resource Sharing
remotely.
Fault Tolerance Detects and recovers from errors to ensure system reliability.
Concurrency Control Manages multiple requests happening at the same time.
Naming and Directory Helps identify and locate components/services in the network.
Ensures operations are completed fully or not at all (like in
Transaction Management
databases).
📊 Types of Middleware
Here's a simple visual representation to help you understand where middleware sits:
🔎 Diagram Explanation:
Application Layer: The user-facing apps (e.g., web apps, mobile apps).
Middleware Layer: Provides services like communication, security, directory services,
etc.
Operating System & Hardware: The foundational layer managing resources on each
machine.
✅ Benefits of Middleware
❌ Challenges
In the context of a Distributed System, X Windows could refer to the X Window System,
which is a framework for managing graphical user interfaces (GUIs) that can be used across
different machines in a distributed network.
In a distributed system, the X Window System allows for graphical user interfaces to be run on
one machine (client), while the display (and often input devices) are handled on another machine
(server). The X Window System itself is highly distributed in nature, enabling remote access to
GUIs and running graphical applications over a network.
1. Client-Server Architecture:
o The X Server is the machine that controls the display hardware (monitor,
keyboard, mouse) and manages the graphical environment. It doesn't necessarily
run the application but is responsible for rendering graphical data on the screen.
o The X Client is the application that sends graphical instructions to the X Server
for rendering. The X Client can run on any machine in the network, allowing the
user to interact with graphical applications remotely.
2. Network Transparency:
X Windows are network-transparent, meaning that the X Client (application) can run on
one machine while the X Server (display) runs on a different machine. This is
fundamental to distributed systems, where resources (like computational power and
displays) may be spread across multiple machines.
3. Communication Mechanism:
o The X Protocol is the communication mechanism between the X Client and X
Server. It allows for remote GUI applications to interact with the display server.
o X Clients use the protocol to send commands such as drawing windows, handling
user input (mouse and keyboard events), or updating the screen.
4. Event Handling in Distributed Systems:
o Events like mouse clicks, keyboard presses, or window movements are captured
by the X Server and passed to the appropriate X Client. The event-handling
system is crucial in a distributed environment to ensure that the graphical
interface responds promptly to user input.
o This also involves data structures such as event queues and event handlers to
manage the flow of input and output between the client and the server.
5. Scalability:
o The X Window System is designed to scale in distributed environments. Multiple
clients can interact with the same X Server, enabling various users to access
different parts of the graphical system at once, often used in large-scale systems
or remote desktop environments.
Event Queues: Store and manage events generated by user interactions (mouse,
keyboard, etc.). The server processes these events and forwards them to the correct client.
Buffers/Memory Management: Handles the transfer of graphical data between the
client and server, ensuring that rendering and display tasks are managed efficiently.
Window Hierarchies: In complex GUIs, the windows are often organized into a
hierarchical structure (parent-child relationships). Trees and linked lists are commonly
used to manage and update window states.
Example of X Windows in Distributed Systems:
Imagine a user running an application (X Client) on one machine in a remote office. The
graphical output is displayed on a different machine (X Server) located in a data center. The user
interacts with the application through the X Server, and the system handles these events over the
network. The X Window System enables this remote display capability, making it ideal for
distributed environments.
In summary, X Windows in a distributed system refers to how graphical interfaces are managed
and displayed in a networked, client-server architecture, leveraging the X Window System for
remote access, event handling, and scalability.
1. Process Migration:
o In this type of migration, a process (or task) running on one machine is
transferred to another machine. This is often done to balance the load across
different machines in a system.
o The challenges include ensuring that the process continues to function properly on
the target machine, even if the hardware architecture or operating system differs.
o Example: A process running on a Linux machine can be migrated to an ARM-
based system that uses a different architecture.
2. Data Migration:
o Data migration involves transferring data from one storage location to another,
typically across different machines or platforms.
o In heterogeneous systems, data migration might require converting the data
format or adjusting access methods to account for differences in file systems or
databases.
o Example: Migrating data between two databases, one running on a Windows
machine and the other on a Linux machine.
3. Virtual Machine (VM) Migration:
o This is a specialized form of process migration where the entire virtual machine is
moved from one host to another. This is often used in cloud computing and
containerized environments.
o VM migration is typically more complex in heterogeneous environments, as the
source and target hosts may have different hardware or software configurations.
o Example: A VM running on an x86 server in a data center might be migrated to
an ARM-based server or a different cloud provider with different architecture.
4. Task/Computation Migration:
o This refers to moving computational tasks from one node to another in a
distributed environment.
o Task migration is beneficial for load balancing or energy efficiency, especially in
heterogeneous systems where some machines might be more powerful than
others.
o Example: A computational task might be migrated from a CPU-based server to a
GPU-based server for better performance.
5. Service Migration:
o This involves migrating services, which might be large-scale applications or
microservices, between different machines or clusters.
o In heterogeneous systems, this could mean moving a service from a system
running one type of operating system or hardware architecture to another system
with different configurations.
o Example: Migrating a web service from an Intel-based server running a Linux OS
to a cloud-based ARM architecture.
Challenges of Migration in Heterogeneous Systems:
1. Compatibility:
o Hardware and Software Differences: The source and target machines in a
heterogeneous system may have different hardware architectures (e.g., x86 vs
ARM) or operating systems (e.g., Windows vs Linux). The migration process
must account for these differences, such as converting data formats or adjusting
system calls.
o Dependencies: Applications often rely on specific system libraries or software
versions, which may differ between the source and destination systems. Ensuring
compatibility between different versions of libraries or system components is a
challenge.
2. Performance Overhead:
o Migrating tasks, data, or processes may incur performance overhead, particularly
in heterogeneous systems where the transfer speeds and resource availability of
source and target machines can vary greatly.
o Migration may also involve serialization and deserialization of data, which can be
time-consuming.
3. State Preservation:
o During migration, it's important to preserve the state of the task or process so that
it can resume execution without loss of information. This is particularly
challenging when migrating between different hardware architectures, as the state
may not be directly transferable without some form of adaptation or translation.
4. Network Latency and Bandwidth:
o The migration process may require significant data transfer over a network, and in
heterogeneous systems, the network speeds and latency between different
machines may vary. This can affect the efficiency of migration and delay task
execution.
5. Security:
o Migration in heterogeneous systems introduces potential security concerns. When
moving data or processes between different machines or environments, ensuring
that data remains secure during transfer and that access control policies are
consistently enforced across different platforms is critical.
1. Load Balancing:
o By migrating tasks or processes between different machines, systems can balance
their workload more efficiently. For example, tasks can be moved from an
underutilized machine to a heavily-loaded machine to improve overall system
performance.
2. Resource Optimization:
o Migration enables better resource utilization in heterogeneous environments. For
instance, computational tasks can be offloaded from general-purpose CPUs to
more specialized processors like GPUs, or tasks can be moved from high-energy-
consuming machines to more energy-efficient ones.
3. Fault Tolerance:
o In the event of a failure in one part of the system, migration allows for the transfer
of tasks or data to other parts of the system, ensuring that the overall system
remains operational and resilient to failures.
4. Flexibility:
o Heterogeneous systems provide the flexibility to migrate tasks or services to
different platforms based on specific requirements such as performance, cost, or
energy efficiency. For instance, computation-heavy tasks could be migrated from
an x86 server to a more powerful GPU cluster.
Code Migration refers to the process where a piece of software or code (typically an executable
program or a process) moves from one machine or node to another within a distributed system.
This concept is especially useful in heterogeneous systems where different machines may have
different processing capabilities, resources, or operating environments. Code migration allows a
program to run on a machine that is better suited for the task at a given time, improving
performance, efficiency, or fault tolerance.
Code migration involves transferring both the code and the execution state of a program so that
it can continue its execution from the point it was left off when moved to another machine.
1. Load Balancing:
In a distributed system, the load might not always be evenly distributed. Code migration
helps move tasks from an overloaded machine to a machine with more resources,
improving system efficiency and preventing bottlenecks.
2. Fault Tolerance:
If a machine or node is likely to fail, migrating code and data to a more stable node helps
ensure that the execution continues uninterrupted.
3. Performance Optimization:
In some cases, it may be beneficial to migrate code to a machine with better hardware
resources (such as moving compute-intensive tasks to a machine with more CPU power
or a specialized GPU).
4. Energy Efficiency:
Code can be migrated to machines with better power efficiency, such as moving
computation-heavy tasks from power-hungry servers to more energy-efficient nodes.
5. Heterogeneous Systems:
In heterogeneous distributed systems, code migration can allow programs to take
advantage of different hardware or platforms, such as migrating from an Intel-based
architecture to ARM-based systems or from CPU-based servers to GPU clusters.
There are different approaches or models for implementing code migration, each with its own
strengths and use cases. These models describe the manner in which code migration is achieved
and how the execution environment is handled.
In this model, a process (or program) is migrated from one machine to another. The
execution state of the process, including variables, memory contents, and program
counter, is transferred to the new machine.
The source machine sends the process’s execution state, which is received by the target
machine. After the migration, the process continues its execution on the new machine.
Challenges:
o The source and target machines must be compatible in terms of hardware and
software for the migration to succeed.
o Network latency and bandwidth can impact performance during migration.
Steps in Process Migration:
Similar to process migration, but threads (individual units of execution within a process)
are migrated instead of entire processes. A thread migration allows for more fine-grained
control, enabling only specific tasks to be moved rather than the whole process.
This model is often used in multi-threaded applications, where different threads might be
moved to different machines based on their resource needs or execution state.
In this model, a specific function or method of an application is migrated rather than the
entire process or thread.
This approach allows for targeted code migration, where only parts of the program that
are resource-heavy or require special hardware are migrated to more capable machines.
For example, in a computation-heavy program, the function that performs complex
calculations could be migrated to a machine with a specialized processor, like a GPU.
Challenges:
o The system needs to ensure that the function's dependencies and environment are
correctly set up on the target machine.
In this model, entire containers (such as Docker containers) are migrated between
different systems. Containers encapsulate the application along with its environment,
making it easier to migrate the entire workload, including dependencies, to another
machine.
This is often used in cloud computing and microservices architectures, where entire
applications or services are containerized and moved between machines or cloud
platforms for scaling, load balancing, or fault tolerance.
Challenges:
o Container orchestration tools (e.g., Kubernetes) are needed to handle migration
and ensure that the container environment is properly replicated on the target
machine.
Virtual machine (VM) migration involves moving an entire virtual machine (including
the operating system, applications, and data) from one host machine to another.
VM migration is commonly used in cloud environments where virtualized infrastructure
is employed. In heterogeneous systems, VM migration may also be used to move a VM
between machines that may differ in architecture or operating system.
This model is often used for load balancing, fault tolerance, or optimizing resources in
cloud data centers.
Challenges:
o Ensuring that the VM environment is properly recreated on the target machine,
including any device drivers or hardware interfaces.
o The complexity of migrating entire virtualized environments, which may have
different hardware configurations.
1. Code Identification: Identify which code or process needs to be migrated and the target
machine for migration. This may involve monitoring system performance, analyzing
workloads, and determining the best node for migration.
2. State Capture: The state of the code, including data, variables, stack, registers, etc., must
be captured. This is often done by creating a snapshot of the process or thread’s state.
3. Transfer: The captured state is transferred to the target machine. This step may involve
sending over the network, and the transfer method must ensure that the entire state is
transferred correctly.
4. Reconfiguration: The code or process might need to be reconfigured to ensure it works
correctly on the target machine. This includes adjusting for differences in hardware
architecture, operating systems, or resource availability.
5. Resumption: The process or code is resumed on the target machine. In some models, it
may start running from where it left off, while in others, it might begin execution from a
specific state that was transferred.
State Preservation: Ensuring that the program’s state is faithfully transferred, including
memory allocation and register values, to avoid loss of progress.
System Compatibility: Ensuring that the source and target systems are compatible in
terms of architecture, OS, libraries, etc. This is particularly challenging in heterogeneous
systems.
Performance Overhead: The process of migration itself introduces overhead, such as
data transfer times and potential downtime during the transition.
Security: Migrating code may expose the system to vulnerabilities, such as data leakage
or unauthorized access, especially if the migration involves sensitive data.
Weak Mobility and Strong Mobility are terms used to describe the ability of code, processes, or
objects to migrate in distributed systems. These terms define the extent to which a system allows
its components (like processes, threads, or objects) to move from one machine or node to another
in a network, and how well the execution state is handled during the migration.
Weak Mobility:
Weak mobility refers to a migration model where only the code or program is moved from one
machine to another, but execution state (e.g., variables, memory content, registers, stack) is not
fully preserved. In other words, the program is restarted or re-executed from the beginning on the
new machine, and it doesn’t continue from where it left off. The migration might involve
transferring the program and its code, but the program's execution context is typically lost during
the transfer.
Code migration only: The program or process is transferred, but the execution context
(state) is not.
No continuity: The program doesn't continue execution from the point it was at when
migration occurred. It usually starts from the beginning or from an initial state on the new
machine.
Simple migration: Since only code is moved, weak mobility is relatively simpler to
implement.
Less overhead: The transfer doesn’t involve capturing the entire state of the process,
making it faster and less resource-intensive.
Use cases: Weak mobility can be used for load balancing or fault tolerance when
continuity of execution isn't critical.
A program that is running on a machine might be moved to another machine, but when it
starts on the new machine, it begins execution from the beginning without retaining any
previous state (variables or ongoing computations). It’s as if the program is being
restarted.
Strong Mobility:
Strong mobility refers to a migration model where both the code and the execution state of a
process are moved from one machine to another. This means that when the program is migrated,
it continues execution exactly where it left off, preserving its entire execution context, including
memory state, variable values, the program counter, and stack. In strong mobility, the system can
effectively "pause" a process, migrate it to another machine, and resume it seamlessly, as if the
migration was transparent to the process itself.
A computational task running on a machine can be paused, its execution state (including
memory, variables, registers, etc.) captured, and then transferred to another machine.
When the task resumes on the new machine, it continues execution from the exact point it
was paused, with no loss of information.
In Distributed Systems (DS), communication refers to the exchange of data and messages between
different components (like processes, nodes, or machines) that are part of the system. Communication
in distributed systems is crucial because it allows various components to work together seamlessly,
despite being located on different machines or across different networks.
There are several types of communication models in distributed systems, depending on the
requirements of the application, such as whether the communication is synchronous or asynchronous,
and whether it's point-to-point or group communication. Below is a breakdown of the different types of
communication in distributed systems:
IPC refers to the mechanisms that allow processes (running programs) to communicate and exchange
data with each other, either within the same machine (local communication) or across different
machines (remote communication).
Types of IPC:
Shared Memory: Multiple processes share a region of memory. One process writes to the
shared memory, and others can read from it. It’s a fast form of communication but can be
complex to manage, especially when dealing with synchronization.
Message Passing: Communication happens by sending messages between processes. This can
happen either synchronously or asynchronously, and it can involve various forms of data, such
as files, objects, or simple data packets.
Communication in a distributed system can be classified based on whether the sending and receiving
processes are synchronized or not.
Synchronous Communication: The sender waits for the receiver to acknowledge receipt of the
message before proceeding. This ensures that communication happens in a well-defined order,
but it can lead to performance bottlenecks due to the waiting time.
Example: A remote procedure call (RPC) is typically synchronous — the client sends a request
and waits for the response before proceeding.
Asynchronous Communication: The sender does not wait for the receiver’s acknowledgment. It
sends the message and continues processing. Asynchronous communication is more efficient in
terms of time, but it may make handling responses more complex.
Example: In a messaging system like email, the sender sends a message and moves on without
waiting for the recipient to read or acknowledge it.
3. Point-to-Point Communication:
In point-to-point communication, data is sent from one specific sender to one specific receiver. The
sender and receiver can be two different processes on the same machine or distributed across different
machines in a network.
Example: A client-server model where a client sends a request to a server and the server
responds with the result.
4. Multicast Communication:
In multicast communication, a sender sends a message to a group of receivers at the same time. This
type of communication allows one-to-many communication, often used in broadcast systems.
Example: Streaming services, where a single server sends data to many clients simultaneously,
or group chat systems where a single message is delivered to all participants in the chat.
5. Broadcast Communication:
Broadcast communication refers to the process of sending a message from one sender to all possible
receivers in the system. It’s a special case of multicast communication where the message is sent to
every node in a network.
Example: A broadcast message in a local area network (LAN) where a node sends a message to
all other nodes connected to the same network.
6. Client-Server Communication:
In client-server communication, the client sends requests to a server, and the server responds with the
requested data. This is a very common model in distributed systems and forms the foundation of many
services, such as web servers, database servers, and application servers.
Example: A web browser (client) sends HTTP requests to a web server, which responds with the
requested web page or resource.
In peer-to-peer communication, there is no central server. Every participant (peer) in the system can act
as both a client and a server. Peers communicate directly with each other, sharing resources, data, and
services.
Example: Peer-to-peer file sharing applications (e.g., BitTorrent), where each participant can
upload and download files from other peers.
8. Remote Procedure Call (RPC):
RPC is a communication mechanism that allows a program (client) to call a procedure or method on a
different machine (server) as if it were a local call. RPC abstracts the communication details, making
remote interaction seem like calling a local function.
Example: A client application calling a function on a remote server to retrieve some data (like
querying a database).
In Distributed Systems (DS), the terms transient and persistent refer to the nature of data and
its lifespan in the system. Specifically, they describe whether data is temporary (transient) or
permanent (persistent) across system states, failures, and reboots.
1. Transient Data:
Definition: Transient data is temporary, and its existence is limited to the current session
or process. It is not meant to be stored permanently and can be discarded or lost once the
process finishes or the system crashes.
Characteristics:
o Short-lived: Transient data exists only for the duration of a session, process, or
active communication.
o Non-durable: If the system crashes, reboots, or the process terminates, transient
data is typically lost.
o Memory-based: Often stored in volatile memory (RAM), which is cleared when
the system is restarted.
o Performance optimized: Because it doesn’t require long-term storage, systems
can use faster, in-memory data structures for transient data.
o Temporary State: Transient data may include intermediate results of a
computation or session information in a user’s active session.
Use Cases:
o Session data: Information that is relevant only for the duration of a user’s session,
such as login status, temporary settings, or cache.
o Intermediate results: Data that is produced and consumed during the processing
of a task but is not needed after the task is complete.
o Caches: Storing frequently accessed data temporarily for fast retrieval without the
need for long-term storage.
Example:
o Session variables in a web application: When a user logs into a web application,
the server might store session data that is discarded when the session ends or the
server restarts.
2. Persistent Data:
Definition: Persistent data is data that is stored for the long term, meaning it survives
system crashes, reboots, or session terminations. This data is durable and is intended to
remain intact over time.
Characteristics:
o Long-lived: Persistent data is meant to exist for an extended period and is not tied
to the life of any single session or process.
o Durable: The data will remain in the system even after a failure, crash, or reboot.
This is ensured by writing the data to stable storage, such as disk drives or
databases.
o Non-volatile: Persistent data is typically stored in non-volatile storage media (like
hard drives, SSDs, or databases) that retain data even when power is lost.
o Backup and recovery: Persistent data can be backed up and recovered, providing
durability and consistency even in the face of system failure.
o Consistency and Integrity: Systems managing persistent data often implement
mechanisms like database transactions to ensure data integrity and consistency.
Use Cases:
o Databases: Storing user information, financial records, product data, etc., that
must persist across system failures.
o File systems: Saving documents, images, logs, and other types of data that must
remain available even after system restarts.
o Configuration files: Settings or configurations that are required for system
operation and need to persist across restarts.
Example:
o User profile data: In a web application, user profile information (name, email,
preferences) stored in a database is persistent. Even if the system crashes, this
data will still be available when the system recovers.
In the context of distributed systems (DS) or communication models, synchronous and
asynchronous are two ways of handling communication between processes, tasks, or systems.
They define how the sender and receiver interact in terms of waiting for acknowledgments,
responses, or results during communication.
Synchronous Communication:
Asynchronous Communication:
RPC follows a client-server model, where the client sends a request to invoke a procedure on a
remote server, and the server processes the request and sends back a result. The process typically
involves the following steps:
1. Client-side stub:
o The client invokes the procedure in the usual way, but the actual call is handled
by a "stub" — a proxy function that represents the remote function.
o The client sends the procedure’s parameters to the server by marshalling
(serializing) them into a format suitable for transmission over the network.
2. Marshalling:
o Marshalling is the process of packing the procedure arguments into a
standardized message format so that they can be transmitted over the network.
o Data is converted into a form that can be sent over a network (e.g., a byte stream).
3. Transmission:
o The request (with marshalled arguments) is transmitted over the network using a
transport protocol (e.g., TCP/IP).
4. Server-side stub:
o The server has its own stub, which acts as the remote procedure’s receiver.
o The server-side stub receives the message, unmarshals (unpacks) the procedure
arguments, and calls the actual function on the server with the unmarshalled data.
5. Execution:
o The server executes the requested procedure with the given parameters.
6. Return and Response:
o Once the server completes the procedure, the result (or output) is sent back to the
client using the reverse process: marshalling, transmission, and unmarshalling.
o The client-side stub then unmarshals the result and returns it to the client as if it
were the result of a local function call.
1. Client makes a local procedure call: The client calls a procedure as though it were
local.
2. Client Stub marshals the parameters: The client-side stub packs the parameters for the
procedure call into a message format suitable for transmission.
3. Message sent across the network: The marshalled message is transmitted from the
client to the server, typically over TCP/IP.
4. Server Stub receives the request: The server-side stub receives the request and
unmarshals the parameters (decodes the message).
5. Server executes the procedure: The server stub invokes the actual procedure with the
unmarshalled parameters.
6. Return the result: After the server procedure executes, the result is sent back to the
client in a similar marshalled format.
7. Client Stub receives the result: The client stub unmarshals the response and presents it
to the client.
8. Client processes the result: The client receives the result and continues execution as
though the procedure had been executed locally.
Types of RPC:
1. Traditional RPC:
o The client and server communicate synchronously, meaning the client waits for a
response before continuing.
o If the server fails to respond, the client will block and wait for a timeout or error.
2. Asynchronous RPC:
o In asynchronous RPC, the client sends the request and does not wait for an
immediate response. The client continues executing and can handle the response
when it arrives.
o This can be useful for operations that take time, such as querying a large database
or waiting for external resources.
3. One-way RPC:
o A one-way RPC call is when the client sends a request to the server but does not
expect any response back. This type is useful for logging, status updates, or
notifying the server of an event without expecting confirmation.
4. Deferred RPC:
o This is a variation of asynchronous RPC where the client can continue working,
and the response is processed once the procedure is completed.
Advantages of RPC:
1. Transparency:
o The client does not need to know that the procedure is being executed remotely. It
looks and behaves like a local function call.
2. Language and Platform Independence:
o RPC can be implemented in many programming languages and across different
platforms (though this depends on the implementation). Protocols like gRPC
allow for communication between systems regardless of the underlying
technology stack.
3. Abstraction of Networking:
o The complexity of network communication, including data serialization, error
handling, and communication protocols, is abstracted away from the developer,
making it easier to work with distributed systems.
4. Simplified Remote Communication:
o RPC simplifies the process of invoking remote services, making it similar to
calling local functions.
Disadvantages of RPC: