0% found this document useful (0 votes)
13 views33 pages

DS Unit-1

This document provides an introduction to distributed systems, defining them as multiple independent computers working together as a single system. It outlines key characteristics, goals, types, applications, and architectural styles of distributed systems, including concepts like scalability, fault tolerance, and middleware. Additionally, it discusses self-management features and various architectures such as centralized, decentralized, and hybrid systems.
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)
13 views33 pages

DS Unit-1

This document provides an introduction to distributed systems, defining them as multiple independent computers working together as a single system. It outlines key characteristics, goals, types, applications, and architectural styles of distributed systems, including concepts like scalability, fault tolerance, and middleware. Additionally, it discusses self-management features and various architectures such as centralized, decentralized, and hybrid systems.
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
You are on page 1/ 33

Unit 1

Introduction to Distributed Systems


What is a Distributed System?

A Distributed System consists of multiple independent computers that work


together as a single system to the user.

Here, the user feels like they are interacting with one system, but in the
background, multiple systems are working together.

Examples: Internet, web-services etc.

Key Characteristics

Scalability: The system can handle growth in users or workload by adding


more resources.

Fault Tolerance: The system continues functioning even if some components


fail.

Concurrency: Multiple processes run at the same time.

Transparency: Hides the complexity of the system from users (e.g., location,
failure).

Goals of Distributed Systems

Unit 1 1
1. Resource Sharing – Allows multiple users to access shared resources like
files, databases, and printers.
Example: Cloud storage services like Google Drive.

2. Openness – Refers to how easily it can be extended, improved, and integrated


with other systems
Example: upgrading from v1 to v2 without any issues.

3. Scalability – Can handle increased workload by adding more resources


without performance loss.
Example: Netflix scales its servers to handle millions of users.

4. Fault Tolerance – Continues to function even if some components fail.


Example: Google Search remains available even if some servers crash.

5. Concurrency – Supports multiple users performing tasks simultaneously


without conflicts.
Example: Online banking allows multiple users to transfer money at the same
time.

6. Transparency – Hides system complexity so users see it as a single system.


Example: Cloud services like AWS abstract underlying hardware details.

Types of Distributed Systems


Distributed systems are categorized based on their architecture, purpose, and
how they manage resources and computation. The major types include:

1. Distributed Computing Systems


These systems distribute computational tasks across multiple machines to
improve performance, efficiency, and fault tolerance.

1.1 Cluster Computing

A group of interconnected computers (nodes) work together as a single


system.

Nodes are homogeneous (same hardware and OS).

Unit 1 2
Uses load balancing to evenly distribute tasks among nodes.

Common in high-performance computing (HPC), scientific research, and


data processing.

Example:

Google’s MapReduce framework for processing large-scale data.

Hadoop clusters for big data processing.

1.2 Grid Computing

Similar to cluster computing but nodes can be heterogeneous (different


OS, hardware, locations).

Uses a decentralized architecture where resources are shared


dynamically.

Focuses on maximizing computing power by using idle resources in


different locations.

Example:

SETI@home, which analyzes radio signals from space using volunteered


computing power.

Folding@home, which uses distributed computing to simulate protein


folding.

1.3 Cloud Computing

Provides on-demand access to computing resources over the internet.

Virtualized resources are abstracted from physical machines.

Enables scalability, elasticity, and pay-as-you-go services.

Cloud Service Models:

IaaS (Infrastructure as a Service): AWS EC2, Google Compute Engine.

2. Distributed Information Systems


These systems manage and integrate business information across distributed
entities. Used in enterprise applications and database systems.

Unit 1 3
2.1 Transaction Processing Systems (TPS)

Used in financial systems, e-commerce, and banking applications.

Ensure ACID (Atomicity, Consistency, Isolation, Durability) properties in


transactions.

Operations:

Begin Transaction – Initiates a transaction.

Read/Write – Reads and writes data.

Commit – Confirms the transaction.

Abort/Rollback – Reverts changes in case of failure.

Example:

Banking systems: Ensuring that money deducted from one account is


credited to another.

Online booking systems: Managing multiple simultaneous ticket bookings.

3. Distributed Pervasive Systems


These systems integrate computing into the environment seamlessly.

They provide real-time ubiquitous computing with minimal human


intervention.

Often used in IoT (Internet of Things) and smart environments.

Characteristics:

Context-aware: Adjust behavior based on the environment.

Mobility and Autonomy: Devices can move and operate independently.

Energy Efficiency: Designed to consume minimal power.

Example:

Smart homes: IoT devices like Google Nest, Amazon Alexa.

Wearable technology: Smartwatches tracking health metrics.

Intelligent traffic systems: Adaptive traffic lights reducing congestion.

Unit 1 4
Applications of Distributed Systems
1. Search Engines

Example: Google, Bing.

Purpose: Distributes the task of crawling, indexing, and retrieving web


pages across thousands of servers.

2. Social Media Platforms

Example: Facebook, Instagram.

Purpose: Handles millions of concurrent users and ensures real-time data


sharing across multiple locations.

3. E-Commerce Platforms

Example: Amazon, Flipkart.

Purpose: Ensures reliable shopping experiences by distributing inventory,


databases, and user sessions.

4. Streaming Services

Example: Netflix, YouTube, Spotify.

Purpose: Distributes media content globally for fast and uninterrupted


streaming.

5. Banking and Finance

Example: Online banking, ATMs.

Purpose: Maintains account information and transaction data across


multiple locations for reliability and availability.

6. Healthcare Systems

Example: Distributed health information systems.

Purpose: Stores and retrieves patient records across hospitals and clinics
securely and efficiently.

7. Online Gaming

Example: PUBG, Fortnite.

Unit 1 5
Purpose: Distributes game servers worldwide to ensure low latency and
real-time gameplay.

8. IoT Systems

Example: Smart home devices, connected cars.

Purpose: Manages and processes data from interconnected devices over


distributed networks.

Architectural Styles of Distributed Systems

1. Layered Architecture
This style organizes the system into layers, where each layer has a specific
role.

Layers interact sequentially, with higher layers depending on lower layers.

Commonly used in enterprise applications, web applications, and the OSI


model.

Request flow: Top to Bottom, Response flow: Bottom to Top.

Example:

Presentation Layer (UI)

Business Logic Layer (Service Layer)

Data Access Layer (Database Interactions)

Unit 1 6
2. Object-Oriented Architecture
Based on loosely coupled objects that interact with each other.

No fixed structure like layers; objects call each other directly.

These interactions often use Remote Procedure Calls (RPC) or direct method
calls.

Frequently used in distributed systems and microservices.

Example:

A UserService object calls OrderService to fetch order details.

Objects communicate dynamically instead of a fixed sequence.

3. Data-Centered Architecture
All components are directly connected to a centralized database.

The database acts as the main communication hub.

Used in large-scale data-driven systems, banking, and ERP systems.

Unit 1 7
Example:

A warehouse management system, where all services (inventory, billing,


shipping) rely on a single database.

4. Event-Driven Architecture
Communication happens through events instead of direct calls.

An event is broadcasted via a system bus, and relevant components react to


it.

Used in real-time applications, IoT, and microservices.

Example:

In an e-commerce system, when a payment is processed, an event is


triggered:

Inventory Service updates stock.

Email Service sends a confirmation.

Shipping Service prepares for delivery.

Unit 1 8
Middleware in Distributed Systems
Middleware is software that acts as a bridge between an operating system and a
distributed application. It helps different applications or services communicate
and share data.

How to Implement Middleware?


Middleware can be implemented using different communication techniques:

1. Remote Procedure Call (RPC)

Concept: Allows a program to call a function on another machine as if it


were local.

Example: A client calls a function getUserData() that actually runs on a


remote server.

2. Remote Method Invocation (RMI)

Concept: Java-based RPC that enables calling methods on remote Java


objects.

Example: A Java application calls a method on a remote Java object to


fetch user details.

3. CORBA (Common Object Request Broker Architecture)

Concept: Allows different programming languages to communicate.

Example: A Java app can call a C++ function remotely.

4. COM/DCOM (Component Object Model / Distributed COM)

Concept: Microsoft’s technology for object-based communication


between applications.

Example: Windows applications communicate using COM objects (e.g.,


MS Word interacting with Excel).

Middleware Purpose Key Feature

RPC Function calls between systems Works like a local function call

RMI Java-to-Java communication Object-oriented

Unit 1 9
CORBA Cross-language communication Works across multiple languages

COM/DCOM Windows-based communication Microsoft-specific

How Middleware Works Imagine you are using an online


shopping application. Here's how
middleware works:

1. Frontend (Client): You use a


browser or mobile app to place an
order.

2. Middleware: The middleware


handles the communication
between the frontend and the
backend. It can:

Convert your request into a


format the backend can
understand.

Send the request over a


network securely.

Handle errors if something


goes wrong.

3. Backend (Server): The backend


processes the request (e.g.,
checking if the item is available,
updating the inventory).

4. Database: The backend queries


the database for order details or
inventory updates.

Middleware handles all the complex


communication, security, and
integration between these
components.

Unit 1 10
Interceptors

An interceptor is software that


interrupts the normal flow of a
program and allows additional logic to
be executed before or after a specific
operation.
How Do Interceptors Work?

Interceptors are often used in


middleware, security, logging, and
request handling. They work by
hooking into the execution flow and
modifying or inspecting data.

Self-Management in Distributed Systems


Self-management in distributed systems refers to the system’s ability to
autonomously configure, heal, optimize, and protect itself without human
intervention.

This is critical in large-scale distributed environments where manual management


is impractical.
Key Components of Self-Management

1. Self-Configuration

The system automatically configures itself in response to changes.

Example: Cloud platforms like AWS Auto Scaling dynamically adjust


resources when load increases or decreases.

2. Self-Healing

The system detects failures and takes corrective action without manual
intervention.

Unit 1 11
Example: Kubernetes restarts failed pods automatically to maintain
application availability.

3. Self-Optimization

The system adjusts resources and configurations to improve


performance and efficiency.

Example: Database sharding and caching mechanisms dynamically


optimize query performance.

4. Self-Protection (Security & Resilience)

The system detects and mitigates security threats or performance


anomalies.

Example: A firewall that automatically blocks suspicious traffic or an


intrusion detection system (IDS) that prevents unauthorized access.

Real-World Examples of Self-Management

1. Cloud Computing:

Auto-scaling in cloud services like AWS EC2 automatically adjusts the


number of virtual machines based on the load, ensuring resources are
efficiently used without manual intervention.

Self-healing mechanisms in cloud platforms can automatically detect


failed instances and replace them without downtime.

2. Microservices Architecture:

Systems like Kubernetes enable self-management by automatically


handling container orchestration, scaling, and recovery. When a
microservice fails, Kubernetes can automatically restart the container or
move it to another node.

Feedback Control System


A feedback control system is a system that monitors its own output and adjusts
its behavior to achieve a desired outcome. It continuously takes feedback (output

Unit 1 12
measurement), compares it with the expected value, and makes necessary
corrections to maintain stability and performance.
Key Components of a Feedback Control System

1. Reference Input (Setpoint)

The desired value or target the system should maintain.

Example: A thermostat is set to 24°C.

2. Controller

Compares the actual output with the desired setpoint and decides how to
adjust the system.

Example: If the room temperature is 22°C instead of 24°C, the thermostat


signals the heater to increase the temperature.

3. Process/System

The part of the system being controlled.

Example: The heater in a thermostat system.

4. Sensor (Feedback Mechanism)

Measures the actual output and sends the data back to the controller.

Example: A temperature sensor detects room temperature and sends the


data to the thermostat.

5. Feedback Loop

The continuous cycle where the system takes the output, compares it with
the setpoint, and makes adjustments.

System Architecture in Distributed Systems

Unit 1 13
1. Centralized Architecture
In a centralized architecture, a single central entity (often called a central server
or master node) controls all or most of the system's operations. This entity is
responsible for managing tasks like data storage, processing, and decision-
making. Other nodes or clients in the system communicate with the central entity
for resources or services.

Key Characteristics:

Single Point of Control: The central server handles the main processing and
decision-making.

Centralized Data Management: All critical data is stored at the central server,
and all queries go through it.

Easy to Manage: Since there’s a central authority, it's easier to manage and
maintain the system.

Scalability Challenges: As the number of clients increases, the central server


can become a bottleneck, limiting scalability.

Example: Client-Server Model


In this model, the client sends requests to a central server, which processes the
request and sends back the response.

Unit 1 14
Layers in the Client-Server Model - (Multi layered)

1. User Interface Layer (Presentation Layer)

The front-end that users interact with.

Example: Web browser, mobile app UI.

2. Process Layer (Application Layer)

Handles business logic and processes requests.

Example: Web server (Node.js, Java Spring Boot).

3. Data Layer (Database Layer)

Stores and retrieves data as requested by the application layer.

Example: MySQL, MongoDB.

2. Decentralized Architecture

Unit 1 15
In a decentralized architecture, there is no central authority controlling the
system. Instead, multiple distributed nodes operate independently, making their
own decisions and handling their own tasks.

Each node can act as both a client and a server, communicating with other nodes
in a peer-to-peer (P2P) fashion.

Key Characteristics:

Multiple Points of Control: No single central server; every node in the system
has equal authority.

Distributed Data Management: Each node may store its own data or replicate
data among other nodes.

Fault Tolerance: The system can continue functioning even if one or more
nodes fail.

Example:

Blockchain Networks: In a blockchain, no central authority controls the


system. Instead, every node (or participant) in the network holds a copy of the
ledger and participates in the validation and recording of transactions.

3. Hybrid Architecture
A hybrid architecture is a mix of centralized and decentralized systems. Some
tasks are handled by a central entity, while other tasks are managed
independently by distributed nodes.
Centralized for Control – A main server or entity manages critical operations.

Unit 1 16
Decentralized for Efficiency – Independent nodes handle tasks without relying on
a central server.

Key Characteristics:

Combination of Control Points: Some aspects of the system are managed by


a central entity, while others are distributed across nodes.

Mixed Data Management: Some data may be centrally stored, while other
data is distributed or replicated across various nodes.

Flexible Design: The system can leverage the benefits of both centralized and
decentralized systems, adapting to the needs of different tasks.

Example:

Edge Servers: edge server systems, hybrid architecture plays a crucial role in
balancing performance, scalability, and reliability.

1. Clients (Users) → Connected to the Internet via an ISP (Internet Service


Provider).

2. Content Provider → The source of data, such as a streaming service or


website.

3. Core Internet → The backbone network connecting everything.

4. Edge Servers → Placed at the network edge, handling requests before


reaching the central network.

5. Enterprise Network → Businesses or organizations hosting private edge


servers.

How Edge Servers Fit into Hybrid Architecture

Unit 1 17
1. Centralized Component (Core Internet & Content Provider)

The content provider (e.g., a streaming service, cloud storage, or website)


is centrally managed and connected to the core Internet.

This part of the system ensures data integrity, control, and consistency
by managing global services.

2. Decentralized Component (Edge Servers & Enterprise Networks)

Edge servers act as decentralized units that are placed closer to the
users.

These servers store cached content and process requests locally without
needing to reach the central system every time.

Example: A Netflix video is stored on multiple edge servers worldwide, so


users don’t have to fetch it from a central server in the US.

3. Client Interaction

Clients first interact with the nearest edge server.

If the requested data is available (cached or preprocessed), the edge


server delivers it instantly (decentralized aspect).

If not, the edge server fetches it from the central content provider
(centralized aspect).

Process
A process is a program under execution, consisting of various memory sections:

1. Text Section → Contains the executable code.

2. Data Section → Holds global/static variables.

3. Heap → Stores dynamically allocated memory.

4. Stack → Maintains function calls, local variables, and return


addresses.

Execution Context

Unit 1 18
A process maintains an execution context, which includes:

Program Counter (PC) → Keeps track of the next instruction.

Stack Pointer (SP) → Points to the top of the stack.

Data Registers → Hold intermediate values during execution.

Thread
A thread is a lightweight unit of execution within a process. A process can have
one or multiple threads.

Why Use Threads?

A thread allows a process to split into multiple tasks that run concurrently.

Threads share the same memory space but have their own execution context
(stack, PC, SP, registers).

Threads in Distributed Systems


1. Single-Threaded Server

Handles one request at a time.

Simple but inefficient for handling multiple clients.

Example: A basic HTTP server processing one request per client at a time.

2. Multi-Threaded Server

Unit 1 19
Spawns a new thread for each client request.

Improves performance by handling multiple requests concurrently.

Example: A chat server where multiple users send messages


simultaneously.

3. Multi-Threaded Client-Server Model

Both client and server use multiple threads for better efficiency.

Example: A web browser (multi-threaded client) sending parallel requests


to a web server (multi-threaded server).

Virtualization
Virtualization is the process of creating virtual versions of physical resources
like computers, storage, or networks. It allows multiple users, applications, or
organizations to share the same physical infrastructure efficiently.
How Virtualization Works
A special software called a hypervisor is used to create and manage multiple
virtual machines (VMs) on a single physical system.
Hypervisor – A software layer that separates physical hardware from virtual
machines. It ensures that multiple VMs can run independently on the same
machine.
Virtual Machine (VM) – A software-based computer that runs an operating
system and applications like a real computer.
Host Machine – The physical computer running the hypervisor.
Guest Machine – The virtual machines running on top of the hypervisor.

Advantages of Virtualization

1. Cost Savings – Reduces the need for buying more hardware.

2. Resource Efficiency – Maximizes the use of physical resources.

3. Scalability – Easily create more VMs as needed.

Types of Virtualization

Unit 1 20
1. Hardware Virtualization (Virtual Machines)
Creating multiple virtual computers on a single physical machine.

Each virtual computer (VM) has its own CPU, RAM, storage, and OS.

The hypervisor ensures that all VMs share the physical system resources
efficiently.

Example:

Running Windows and Linux on the same computer using VMware or


VirtualBox.

Cloud platforms like AWS, Azure, and Google Cloud use virtualization to
provide cloud servers.

2. Application Virtualization
Running an application without installing it directly on a system.

The application runs in a virtual environment, separate from the operating


system.

It prevents software conflicts and allows apps to run on different devices


without compatibility issues.

Example:

Google Docs runs in a browser without installation.

Microsoft App-V allows Windows applications to run without installing


them on each device.

3. Network Virtualization
Creating multiple virtual networks on a single physical network.

It separates different network traffic into isolated virtual networks.

Improves security, scalability, and performance.

Example:

VPN (Virtual Private Network) allows secure internet browsing.

Unit 1 21
Software-Defined Networking (SDN) lets companies control networks
using software.

4. Desktop Virtualization
Using a virtual desktop instead of a physical computer.

Users log into a virtual desktop running on a remote server.

Allows employees to access their desktops from any device.

Example:

Amazon WorkSpaces offers cloud-based desktops.

Remote Desktop Protocol (RDP) lets you access another computer


remotely.

5. Storage Virtualization
Combining multiple storage devices into a single virtual storage system.

It improves data management, scalability, and reliability.

Example:

Google Drive, AWS S3, Dropbox store your data across multiple servers.

RAID (Redundant Array of Independent Disks) combines multiple physical


hard drives into one.

Software Agents
Software agents are programs that act autonomously to perform tasks on behalf
of users or other systems. They can make decisions, adapt to changes, and
communicate with other agents.

Types of Software Agents


1. Collaborative Agents

These agents work together with users or other agents to complete tasks
efficiently.

Unit 1 22
Example: A chatbot that helps customer support by answering common
queries and forwarding complex issues to a human agent.

2. Mobile Agents

These agents can move from one system or network to another, carrying
out tasks remotely.

Example: A software agent that collects stock market data from different
sources and delivers it to your financial app.

3. Interface Agents

These agents interact directly with users, learning their habits and
preferences to provide personalized assistance.

Example: A virtual assistant like Siri or Google Assistant that learns your
favorite apps, reminders, or frequently visited places.

4. Information Agents

These agents gather, process, and deliver useful information from various
sources.

Example: A news aggregator app that collects and summarizes trending


articles based on your reading history.

Client and Server


A client and server are two main components in a computer network that
communicate with each other to exchange data.

1. Client
A client is a device or software that requests services or data from a server.

Clients rely on servers to process their requests and send back results.

Unit 1 23
Examples:

A web browser (Chrome, Firefox) is a client that requests web pages from
a web server.

A mobile banking app is a client that requests account details from a


bank’s server.

2. Server
A server is a powerful computer or software that processes requests from
clients and sends back responses.

It can store data, host applications, or provide services like file sharing, email,
or databases.

Examples:

A web server (like Apache or Nginx) stores and delivers websites.

A database server (like MySQL or MongoDB) stores and retrieves data for
applications.

Code Migration
Code migration refers to moving code from one machine to another in a
distributed system. It helps improve performance, reduce network load, and
balance resources efficiently.
Reasons for Code Migration

1. Load Balancing → Distribute tasks across multiple servers to prevent


overload.

2. Performance Improvement → Move code closer to the data to reduce


network latency.

3. Fault Tolerance → If one machine fails, code can move to another machine.

4. Resource Sharing → Some devices may have better processing power, so


moving code helps in efficient execution.

Process Segments in Migration:

Unit 1 24
1. Code Segment → The actual program logic or instructions.

2. Resource Segment → Files, database connections, or other system resources


needed for execution.

3. Execution Segment → The current execution state, including registers, stack,


and program counter.

Types of Code Migration


1. Weak Migration

Only moves the code segment to another machine.

Execution starts from the beginning on the new machine.

Example: A web page script runs on a different server but starts fresh
each time.

2. Strong Migration

Moves the code, resources, and execution state to another machine.

Execution resumes from where it stopped on the previous machine.

Example: A running virtual machine (VM) is migrated to another server


without stopping execution.

1. Synchronous Communication

The sender waits for the receiver to acknowledge or respond before


proceeding.

Both sender and receiver must be active at the same time.

Ensures immediate communication but can cause delays if the receiver is


slow.

Unit 1 25
Example:

A function call in a program where execution stops until a response is


received.

API calls that require an immediate response (e.g., requesting user details
from a database).

Use Cases:

Online banking transactions

Request-response systems (REST APIs)

Remote Procedure Calls (RPC)

2. Asynchronous Communication

The sender sends a message and does not wait for an immediate response.

The receiver processes the message whenever it is available.

Improves system efficiency and scalability but introduces complexity in


handling delayed responses.

Example:

Sending an email: the sender does not wait for the recipient to read it.

Message queues (e.g., RabbitMQ, Kafka) where messages are stored and
processed later.

Use Cases:

Notification systems

Background processing in web applications

Unit 1 26
3. Persistent Communication

Messages are stored in a system (e.g., a database or message queue) until the
receiver is ready to process them.

Ensures that messages are not lost even if the receiver is temporarily
unavailable.

Used in systems where reliability is important.

Example:

Kafka stores messages and allows consumers to process them later.

Order processing in e-commerce: If a payment service is down, the order


request is stored and processed later.

Use Cases:

Logging and monitoring systems

Transaction processing

Distributed database replication

Receiver Must Message


Type Sender Waits? Example
Be Active? Persistence?

API requests,
Synchronous Yes Yes No
RPC

Email, message
Asynchronous No No Optional
queues

Kafka, order
Persistent No No Yes
processing

Types of Communication in Distributed Systems

1. Message-Oriented Communication

Involves sending and receiving discrete messages.

Each message is independent and contains all necessary information.

Unit 1 27
Used in scenarios where communication is asynchronous (sender and
receiver don’t need to be active at the same time).

Example:

Email, SMS, message queues like RabbitMQ or Kafka.

Use Cases:

Event-driven systems, notifications, chat applications.

2. Stream-Oriented Communication

Instead of sending individual messages, data is sent as a continuous stream.

Suitable for real-time data transmission.

Sender and receiver must remain connected for data exchange.

Example:

Video streaming (Netflix, YouTube), VoIP calls (Zoom, Skype).

Use Cases:

Live streaming, audio/video conferencing, real-time gaming.

3. Multicast Communication

One sender sends data to multiple receivers at the same time.

Efficient for broadcasting updates without sending multiple copies of the same
data.

Example:

Live sports streaming, software updates sent to multiple devices, IoT device
communication.

Use Cases:

Distributed databases, stock market data distribution, online lectures.

4. Remote Procedure Call (RPC)

Unit 1 28
Remote Procedure Call (RPC) is a communication protocol that allows a program
on one machine to execute a function on another machine as if it were a local
function.
This abstraction simplifies distributed computing by hiding the complexities of
network communication, making remote interactions seamless.
Key Characteristics of RPC:

Enables inter-process communication across different machines in a


network.

The function call appears local to the client, but it actually executes on a
remote server.

Works on a client-server model, where the client requests execution and the
server processes it.

Requires stubs (proxy code) to handle function call conversions.

Can be synchronous or asynchronous, depending on how responses are


handled.

Main Components of RPC


RPC primarily involves five key elements:

1. Client – The process that initiates the function call.

2. Client Stub – A proxy that converts the request into a format suitable for
network transmission.

3. RPC Runtime – Handles message passing between the client and server,
managing network communication.

4. Server Stub – Receives the request, converts it back into a local function call.

Unit 1 29
5. Server – Executes the actual function and sends back the result.

What is a Stub?
A stub is a piece of code that acts as an intermediary, converting function calls
into network messages and vice versa.

The client stub converts the function call into a network request.

The server stub receives the request and executes the corresponding
function on the server.

Example of RPC in Action


Imagine a web application that fetches user data from a remote server:

1. The client application calls getUserData() expecting user information.

2. The client stub converts this request into a network message and sends it to
the remote server.

3. The server stub receives the request, decodes it, and calls the actual
getUserData() function on the server.

4. The server processes the function and sends back the result.

Unit 1 30
5. The client stub receives the response, decodes it, and returns the result as if it
were a normal function call.

Use Cases of RPC


Microservices Communication – Allows different services to interact
efficiently.

Distributed Applications – Used in cloud computing and enterprise systems.

File Systems – Enables remote access in systems like NFS (Network File
System).

Database Access – Clients can execute queries on remote databases


seamlessly.

Popular RPC Technologies


gRPC – Google's high-performance RPC framework, widely used in modern
microservices.

Apache Thrift – A cross-language RPC framework developed by Facebook.

XML-RPC – An older RPC protocol that uses XML for communication.

Implementation Issues of RPC (Remote Procedure Call)


→ Choice of Protocol
RPC relies on an underlying communication protocol to send requests and
receive responses. The two main types of protocols are:
a) Connection-Oriented Protocol (e.g., TCP)

Establishes a dedicated connection between the client and server


before exchanging messages.

Ensures reliable, ordered, and error-free communication.

Advantages:

1. Guarantees message delivery.

2. Maintains session information (stateful).

3. Suitable for long-duration requests.

Unit 1 31
Disadvantages:

1. Overhead of connection establishment and maintenance.

2. Increased latency for short-lived requests.


b) Connectionless Protocol (e.g., UDP)

No dedicated connection; each request is sent independently.

Best effort delivery (packets may be lost or arrive out of order).

Advantages:

1. Low overhead and faster communication.

2. Suitable for high-performance applications with many small requests.

Disadvantages:

1. No guarantee of message delivery or ordering.

2. Requires additional mechanisms for error handling and retransmission.

5. Remote Method Invocation (RMI)

Similar to RPC but specific to Java.

Allows a Java program to call methods of an object located on another Java


Virtual Machine (JVM).

Key Components in Java RMI:

1. Java Client – The application that makes a remote call to a method on the
server.

Unit 1 32
2. Client Stub – Acts as a proxy for the remote object. It marshals (serializes) the
method call and sends it to the server.

3. RMI Registry – A naming service where remote objects are registered,


allowing clients to look them up and invoke methods remotely.

4. Server Skeleton – Unmarshals (deserializes) the request and invokes the


actual method on the Java Server.

5. Java Server – Contains the actual implementation of the remote methods.

Example:

A banking application where the client interacts with remote objects like
Account.getBalance() .

Use Cases:

Java-based distributed applications, cloud-based Java services.

Communication
Description Example Use Case
Type

Asynchronous
Independent
Message-Oriented Email, Kafka messaging,
messages exchanged
notifications

Real-time streaming,
Stream-Oriented Continuous data flow Netflix, Zoom
voice calls

One sender to Live updates, IoT Broadcasting, stock


Multicast
multiple receivers devices market updates

Function call on a Microservices,


RPC gRPC, API calls
remote machine distributed computing

Remote object Java-based distributed


RMI Java RMI
invocation in Java apps

Unit 1 33

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy