unit 1
unit 1
Introduction
Picture a world where your favourite websites never crash or slow down, even when millions of
people are accessing them at the same time.
In this article, we will explore the depths of distributed systems. We will also study the characteristics
of the revolutionary approach to computing.
Client/Server Systems: These are the most basic forms of servers. The client gives an input
to the server, and the server replies with an output. The client wants to perform a task on a
server, and the server allocates and performs the task and sends the result as a response.
These types of servers can be applied to many other servers.
Peer-to-Peer Systems: In this system, each node executes its task on its locally allocated
memory and shares the data through a supporting medium. Computer network applications
use a peer-to-peer system to manage processors that communicate with each other but
maintain independent memory bases.
Middleware: It is an application which sits between two different applications and provides
services and benefits to both.
Three-tier: Three-tier system uses a distinct layer and server for each program function. The
client's data is stored in the middle tier. It contains an application layer, a data layer, and a
presentation layer. This three-tier system is most commonly used in web or online
applications.
N-tier: It is also known as a multitier distributed system. As the name suggests, this system
may contain any number of functions, similar to the three-tier system. This N-tier system is
more commonly used in web applications and data systems.
In Networking, ethernet and LAN are the best examples of distributed systems. Computers
sent messages to other computers and systems using local IP addresses.
In Real-time Systems, the systems are distributed globally. Many major industries use these
systems. Companies like Uber and Lyft use dispatch systems, many significant airlines use
flight control systems and e-commerce websites, and logistic companies use real-time
tracking systems.
Transparency
One of the essential characteristics of the distributed system, transparency, is the notion that the
user interacts with a whole quantity rather than a cluster of cooperating elements. A system capable
of presenting itself as a whole to the user is called transparent.
Transparency is divided into the eight sub-characteristics illustrated in the following table:
Transparency Description
Relocation Hide the location of the moving object while still in use.
Heterogeneity
Heterogeneity refers to the system's ability to operate on various hardware and software
components. Middleware in the software layer helps achieve heterogeneity. The goal of the
middleware is to interpret the programming calls such that the distributed processing gets
completed.
Openness
Scalability
A centralised system affects the scalability of a distributive system. If a system is centralised, more
nodes will try to communicate, which results in a bottleneck at that particular time in the system.
Fault Tolerance
A distributed system is very likely to be prone to system failures. This is due to the fact that several
computers have diverse-aged hardware. The ability of a system to handle these failures is called fault
tolerance. Fault tolerance is achieved by:
Recovery: Systems and processes will have a stored backup. It takes over when the system
fails.
Concurrency
Concurrency is the system's capability to access and use shared resources. It means multiple actions
are performed at the same time. In distributive systems, the concurrent execution of activities takes
place in different components running on numerous machines.
Efficiency
Efficiency refers to the capability of the system to use its resources effectively to execute the given
tasks. The system's design, the workload handled by the system, and the hardware and software
resources used are some critical factors affecting the system's efficiency.
Some of the common ways to improve the efficiency of the system are:
Optimising the design of the system. This minimises the amount of communication and
coordination required between the different components, reducing any extra power
consumption.
Carefully negating the workload of the system. This balance avoids any component overload
and ensures that the system can make the most efficient use of its resources.
After expanding your knowledge of the characteristics of distributed systems, let us now discuss the
disadvantages of distributed systems.
If there is a delay in the network, the user may face difficulty accessing data.
The distributive system has an intricate Database that faces challenges to manage.
Network overloading is also a challenge faced in distributive systems. This happens when all
the nodes send data at once.
Challenge: Components (nodes, hardware, or software) may fail, and the system must
continue to function correctly despite these failures.
Key Issues:
o Identifying failures promptly.
o Recovering gracefully without impacting the overall system.
Example: Handling server crashes in cloud computing.
2. Scalability
Challenge: The system must handle increased loads by adding more resources.
Key Issues:
o Avoiding bottlenecks, such as centralized components.
o Maintaining performance as the number of nodes grows.
Example: Scaling up e-commerce platforms during high-traffic events like Black
Friday.
3. Concurrency
4. Data Consistency
Challenge: Ensuring data remains consistent across all nodes in the system.
Key Issues:
o Trade-offs between consistency, availability, and partition tolerance (CAP
theorem).
o Achieving consistency in the face of network delays or failures.
Example: Banking systems ensuring account balances are updated accurately across
branches.
5. Latency
6. Security
Challenge: Protecting the system from unauthorized access, breaches, and attacks.
Key Issues:
o Secure communication between nodes.
o Preventing attacks like Distributed Denial of Service (DDoS) or data
interception.
Example: Encrypting data transmission in online banking.
7. Heterogeneity
8. Transparency
Challenge: Masking the complexity of the distributed system from users and
developers.
Types of Transparency:
o Access Transparency: Users shouldn’t need to know how to access remote
resources.
o Location Transparency: Resources’ physical locations shouldn’t matter.
o Failure Transparency: Failures should be handled seamlessly.
o Replication Transparency: Multiple copies of data shouldn’t be visible.
Example: A user accessing files in Google Drive without worrying about their
storage location.
9. Synchronization
EXAMPLES :-
Distributed systems are systems that break down large tasks into smaller sub-tasks that can be
executed in parallel on different system components. The goal of a distributed system is to improve
performance, reliability, and scalability. Some examples of distributed systems include:
Hadoop Distributed File System (HDFS): Used for distributed computing on the Hadoop
framework
Synchronous System Calls: In synchronous system calls both sender and receiver use
blocking system calls to transmit the data which means the sender will wait until the
acknowledgment is received from the receiver and the receiver waits until the message
arrives.
Asynchronous System Calls: In asynchronous system calls, both sender and receiver use non-
blocking system calls to transmit the data which means the sender doesn’t wait from the
receiver acknowledgment.
Integrity: Messages must arrive without corruption and duplication to the destination.
Below are the types of interprocess communication (IPC) commonly used in distributed systems:
Message Passing:
Shared Memory
Shared memory enables multiple processes to access a common region of memory. This
method is efficient as it minimizes communication overhead.
Key Concepts
Often implemented within a single machine but can extend to distributed environments
through specialized shared memory technologies.
Pros
o Definition: RPC allows one process to invoke a procedure (or function) in another
process, typically located on a different machine over a network.
Sockets:
Publish-Subscribe Systems:
These types of IPC mechanisms each have distinct advantages and are chosen based on factors such
as communication requirements, performance considerations, and the nature of the distributed
system architecture. Successful implementation often involves selecting the most suitable IPC type or
combination thereof to meet specific application needs.
Facilitates Communication:
o IPC enables processes or components distributed across different nodes to
communicate seamlessly.
o This allows for building complex distributed applications where different parts of the
system can exchange information and coordinate their activities.
Scalability:
o IPC techniques in distributed systems often include mechanisms for handling failures
and ensuring resilience.
o For example, message queues can buffer messages during network interruptions,
and RPC frameworks can retry failed calls or implement failover strategies.
Performance Optimization:
o Distributed systems operate over networks where latency (delay in transmission) and
bandwidth limitations can affect IPC performance.
o Minimizing latency and optimizing bandwidth usage are critical challenges, especially
for real-time applications.
Security:
o Distributed systems often transmit sensitive data over networks, requiring robust
encryption, authentication, and access control mechanisms.
Consider a distributed system where you have two processes running on separate computers, a client
process (Process A) and a server process (Process B). The client process needs to request information
from the server process and receive a response.
1. RPC Setup:
Process B (Server): Listens for incoming RPC requests and responds accordingly.
2. Steps Involved:
o The client process prepares an RPC request, which includes the name of the
remote procedure to be called and any necessary parameters.
o After processing the request, the server process prepares a response (if
needed) and sends it back to the client process (Process A) over the
network.
3. Communication Flow:
Process A and Process B communicate through the RPC framework, which manages
the underlying network communication and data serialization.
The RPC mechanism abstracts away the complexities of network communication and
allows the client and server processes to interact as if they were local.
Process A (Client) could be a web application requesting user data from a database
hosted on Process B (Server).
Process B (Server) receives the request, queries the database, processes the data,
and sends the results back to Process A (Client) via RPC.
The client application then displays the retrieved data to the user.
In this example, RPC serves as the IPC mechanism facilitating communication between the client and
server processes in a distributed system. It allows processes running on different machines to
collaborate and exchange data transparently, making distributed computing more manageable and
scalable.
This programmer's reference describes an interface to the transport layer of the Basic
Reference Model of Open Systems Interconnection (OSI). Although the API is capable of
interfacing to proprietary protocols, the Internet open network protocols are the intended
providers of the transport service. This document uses the term "open" to emphasize that
any system conforming to one of these standards can communicate with any other system
conforming to the same standard, regardless of vendor. These protocols are contrasted with
proprietary protocols that generally support a closed community of systems supplied by a
single vendor External Data Representation and Marshalling.
There are several different types of data that use in computers and these types are not the same in
every place that data needed to transfer. Let’s see how these types differ from one to another.
To effectively communicate these different types of data between computers there should be a way
to convert every data to a common format. External data representation is the data type that act as
the intermediate data type in the transmission.
Marshalling
Marshalling is the process of taking a collection of the data structures to transfer and format them
into an external data representation type which suitable for transmission in a message.
Unmarshalling
Unmarshalling is the inverse of this process, which is reformatting the transferred data on arrival to
produce the original data structures at the destination.
Let’s find how this external data representation works in different use cases.
Common Object Request Broker Architecture aka CORBA is a specification developed by Object
Management Group (OMG) currently the leading middleware solutions in most distributed systems.
Its a specification for creating, distributing, and managing objects in distributed networks. CORBA
describes a messaging mechanism by which objects distributed over a network can transfer
messages with each other irrespective of the platform or language used to create those objects. This
enables collaboration between systems on different architectures, operating systems, programming
languages as well as computer hardware.
CORBA’s Common Data Representation specification includes 15 primitive data types and other
constructed types.
CORBA CDR Example
In Java remote method invocation (RMI), both objects and primitive data values may be passed as
arguments and results of method invocations. In Java, the term serialization refers to the activity of
flattening an object(An instance of a class) or a connected set of objects into a serial form that is
suitable for storing on disk or transmitting in a message.
Java Object Serialization Example
XML is a markup language that was defined by the World Wide Web Consortium for general use on
the web. XML was initially developed for writing structured documents for the web. XML is used to
enable clients to communicate with web services and for defining the interfaces and other properties
of web services.
Conclusion
In CORBA’s common data representation and Java’s object serialization, the marshalling and
unmarshalling activities are intended to be carried out by a middleware layer without any
involvement on the part of the application programmer. Even in the case of XML, which is textual and
therefore more accessible to hand-encoding, software for marshalling and unmarshalling is available
for all commonly used platforms and programming environments. Because marshalling requires the
consideration of all the finest details of the representation of the primitive components of composite
objects, the process is likely to be error-prone if carried out by hand. Compactness is another issue
that can be addressed in the design of automatically generated marshalling procedures.
In CORBA’s common data representation and Java’s object serialization, the primitive data types are
marshalled into a binary form. In XML, the primitive data types are represented textually. The textual
representation of a data value will generally be longer than the equivalent binary representation. The
HTTP protocol, which is described in Chapter 5, is another example of the textual approach.
Another issue with regard to the design of marshalling methods is whether the marshalled data
should include information concerning the type of its contents. For example, CORBA’s representation
includes just the values of the objects transmitted and nothing about their types. On the other hand,
both Java serialization and XML do include type information, but in different ways. Java puts all of the
required type information into the serialized form, but XML documents may refer to externally
defined sets of names (with types) called namespaces.
Although we are interested in the use of an external data representation for the arguments and
results of RMIs and RPCs, it does have a more general use for representing data structures, objects or
structured documents in a form suitable for transmission in messages or storing in files.
1. Sockets Mechanism
3. Message Passing
4. Inter-process Communication
Sockets Mechanism
The Sockets are the End Points of Communication between two machines. They provide a way for
processes to communicate with each other, either on the same on machine or over through Internet
also possible. The Sockets enable the communication connection between Serthe er and the client to
transfer data in a bidirectional way.
Client Server Communication using Sockets
Remote Procedure Call is a Protocol. A Protocol is set of Instructions. It allows a client to execute a
procedure call on remote server, as if it is local procedure call. PRC is commonly used in Client Server
communication Architecture. PRC Provide high level of abstraction to the programmer. In This The
client Program issues a procedure call , which is translated into message that is sent over the
network to the Server, The Server execute the call and send back to the Client Machine.
Message Passing
Message Passing is a communication Method. Where the machines communicated with each one by
send and receiving the messages. This approach is commonly used in Parallel and Distributed
Systems, This approach enables data exchange among the System.
Message Passing Process
The Inter Process Communication also called IPC. It allows communication between processes within
the same Machine. The IPC can enable data sharing and Synchronous between different processes
running concurrently on an operating system. And it includes Sharing Memory, message queues,
semaphores and pipes among others.
Distributed File Systems provide access to files from multiple machines in network. Client can access
and manipulate files stored on Remote Server, Through Standard Interface Example Network File
System and Server Message Block.
Group communication in distributed systems refers to the process of exchanging information among
multiple nodes or entities that are geographically dispersed or located on different machines within a
network. It involves mechanisms and protocols designed to facilitate communication and
coordination among members of a group, where each member typically plays a specific role or
performs particular tasks within the distributed system.
Group communication is critically important in distributed systems due to several key reasons:
o Distributed systems often involve multiple nodes or entities that need to collaborate
and synchronize their activities.
o This ensures that all parts of the system are aware of the latest updates and can act
in a coordinated manner.
o In distributed systems, different nodes may generate or process data that needs to
be shared among multiple recipients.
o This enhances the overall reliability and availability of the distributed system.
Scalability:
o As distributed systems grow in size and complexity, the ability to scale effectively
becomes crucial.
o They enable the system to maintain its responsiveness and efficiency as it scales up.
Types of Group Communication in a Distributed System
1. Unicast Communication
Unicast Communication
Unicast communication refers to the point-to-point transmission of data between two nodes in a
network. In the context of distributed systems:
Definition: Unicast involves a sender (one node) transmitting a message to a specific receiver
(another node) identified by its unique network address.
Characteristics:
Use Cases:
Advantages:
o Low latency since messages are sent directly to the intended recipient.
Disadvantages:
2. Multicast Communication
Multicast Communication
Multicast communication involves sending a single message from one sender to multiple receivers
simultaneously within a network. It is particularly useful in distributed systems where broadcasting
information to a group of nodes is necessary:
Characteristics:
o Group Membership: Receivers voluntarily join and leave multicast groups as needed.
Use Cases:
Advantages:
Disadvantages:
3. Broadcast Communication
Broadcast communication involves sending a message from one sender to all nodes in the network,
ensuring that every node receives the message:
Broadcast Communication
Definition: A sender transmits a message to all nodes within the network without the need
for specific recipients.
Characteristics:
Use Cases:
Advantages:
o Ensures that every node receives the message without requiring explicit recipient
lists.
Disadvantages:
o Requires careful network design and management to control the scope and impact
of broadcast messages.
Reliable multicast protocols are essential in distributed systems to ensure that messages sent from a
sender to multiple recipients are delivered reliably, consistently, and in a specified order. These
protocols are designed to handle the complexities of group communication, where ensuring every
member of a multicast group receives the message correctly is crucial. Types of Reliable Multicast
Protocols include:
FIFO Ordering:
o Ensures that messages are delivered to all group members in the order they were
sent by the sender.
Causal Ordering:
o Ensures that messages are delivered in an order that respects the causal
dependencies observed by the sender.
o Guarantees that all group members receive messages in the same global order.
o Ensures that operations based on the multicast messages (like updates to shared
data) appear atomic or indivisible to all recipients.
Scalability and performance are critical aspects of group communication in distributed systems,
where the ability to handle increasing numbers of nodes, messages, and participants while
maintaining efficient operation is essential. Here’s an in-depth explanation of scalability and
performance considerations in this context:
1. Scalability
Scalability in group communication refers to the system’s ability to efficiently accommodate growth
in terms of:
Volume of Messages: Handling a larger volume of messages being exchanged among group
members, ensuring that communication remains timely and responsive.
2. Challenges in Scalability
Communication Overhead: As the group size increases, the overhead associated with
managing group membership, message routing, and coordination can become significant.
Network Bandwidth: Ensuring that the network bandwidth can handle the increased traffic
generated by a larger group without causing congestion or delays.
Partitioning and Sharding: Dividing the system into smaller partitions or shards can reduce
the scope of communication and management tasks, improving scalability.
Replication and Caching: Replicating data or messages across multiple nodes can reduce
access latency and improve fault tolerance, supporting scalability.
Scalable Protocols and Algorithms: Using efficient communication protocols and algorithms
designed for large-scale distributed systems, such as gossip protocols or scalable consensus
algorithms.
4. Performance
Low Latency: Minimizing the time delay between sending and receiving messages within the
group.
High Throughput: Maximizing the rate at which messages can be processed and delivered
across the system.
Efficient Resource Utilization: Using network bandwidth, CPU, and memory resources
efficiently to support fast and responsive communication.
5. Challenges in Performance
Message Ordering: Ensuring that messages are delivered in the correct order while
maintaining high throughput can be challenging, especially in protocols that require strict
ordering guarantees.
Concurrency Control: Managing concurrent access to shared resources or data within the
group without introducing contention or bottlenecks.
Optimized Message Routing: Using efficient routing algorithms to minimize the number of
network hops and reduce latency.
Group communication in distributed systems poses several challenges due to the inherent
complexities of coordinating activities across multiple nodes or entities that may be geographically
dispersed or connected over unreliable networks. Here are some of the key challenges:
Reliability: Ensuring that messages are reliably delivered to all intended recipients despite
network failures, node crashes, or temporary disconnections. Reliable delivery becomes
especially challenging when nodes join or leave the group dynamically.
Concurrency and Consistency: Ensuring consistency of shared data across distributed nodes
while allowing concurrent updates can be difficult. Coordinating access to shared resources
to prevent conflicts and maintain data integrity requires robust synchronization mechanisms.
Fault Tolerance: Dealing with node failures, network partitions, and transient communication
failures without compromising the overall reliability and availability of the system. This
involves mechanisms for detecting failures, managing group membership changes, and
ensuring that communication continues uninterrupted.
IPC in UNIX :-
Inter-process communication (IPC) in UNIX allows processes to exchange data and signals,
enabling collaboration between different programs or processes. UNIX provides several IPC
mechanisms, each designed for different use cases, performance requirements, and levels of
complexity. Here are the key IPC methods in UNIX:
### 1. **Pipes**
- **Description**: Pipes are one of the simplest IPC mechanisms that allow data to flow in
one direction between two related processes (parent-child).
- **Types**:
- **Anonymous Pipes**: Used for communication between processes that have a
common ancestor, like parent and child processes.
- **Named Pipes (FIFOs)**: These pipes have a name in the filesystem, allowing
communication between unrelated processes.
- **Example**:
```bash
$ ls | grep txt
```
In this example, the output of the `ls` command is passed through a pipe to the `grep`
command.
### 4. **Semaphores**
- **Description**: Semaphores are used to control access to shared resources by multiple
processes, ensuring that only a certain number of processes can access the resource at a
time.
- **Types**:
- **Binary Semaphores**: They behave like mutexes, allowing only one process to access
a critical section.
- **Counting Semaphores**: These allow a specific number of processes to access a
resource.
- **System Calls**:
- `semget()`: Create or access a semaphore set.
- `semop()`: Perform operations on a semaphore set (e.g., wait, signal).
- `semctl()`: Control operations on the semaphore set.
### 5. **Signals**
- **Description**: Signals are asynchronous notifications sent to a process to notify it of an
event (e.g., `SIGTERM`, `SIGKILL`, `SIGINT`).
- **Use Case**: Used to notify a process of events such as termination requests, timeouts,
or errors.
- **System Calls**:
- `kill()`: Send a signal to a process.
- `signal()`: Set a signal handler for a process.
- `sigaction()`: Advanced signal handling.
- **Example**:
```bash
$ kill -9 <pid>
```
### 6. **Sockets**
- **Description**: Sockets provide communication between processes, either on the same
machine or over a network. They support bidirectional communication.
- **Types**:
- **UNIX Domain Sockets**: For local inter-process communication (same machine).
- **Internet Domain Sockets**: For communication over networks (e.g., TCP/IP).
- **System Calls**:
- `socket()`: Create a socket.
- `bind()`: Bind a socket to an address.
- `listen()`, `accept()`: Listen for and accept connections.
- `send()`, `recv()`: Send and receive data through the socket.
Each method has its trade-offs between simplicity, performance, and the specific needs of
the communication.