UNIT I NOTES DC
UNIT I NOTES DC
UNIT I INTRODUCTION
1 INTRODUCTION
1.1DEFINITION
Distributed systems also known as distributed computing and distributed databases, a
distributed system is a collection of independent components located on different machines that
share messages with each other in order to achieve common goals.
As such, the distributed system will appear as if it is one interface or computer to the end-user.
The hope is that together, the system can maximize resources and information while preventing
failures, as if one system fails, it won't affect the availability of the service.
Today, data is more distributed than ever, and modern applications no longer run in isolation.
The vast majority of products and applications rely on distributed systems.
Telecommunication networks
Telephone and cellular networks are also examples of distributed networks. Telephone
networks have been around for over a century and it started as an early example of a peer to
peer network. Cellular networks are distributed networks with base stations physically
distributed in areas called cells. As telephone networks have evolved to VOIP (voice over IP), it
continues to grow in complexity as a distributed network.
Parallel Processing
There used to be a distinction between parallel computing and distributed systems. Parallel
computing was focused on how to run software on multiple threads or processors that accessed
the same data and memory. Distributed systems meant separate machines with their own
processors and memory. With the rise of modern operating systems, processors and cloud
services these days, distributed computing also encompasses parallel processing.
As shown in Fig 1.1, Each computer has a memory-processing unit and the computers are
connected by a communication network. Each system connected to the distributed networks
hosts distributed software which is a middleware technology. This drives the Distributed
System (DS) at the same time preserves the heterogeneity of the DS. The term computation or
run in a distributed system is the execution of processes to achieve a common goal.
Examples of middleware: Object Management Group’s (OMG), Common Object Request Broker
Architecture (CORBA), Remote Procedure Call (RPC), Message Passing Interface (MPI)
1.3 MOTIVATION
The motivation for using a distributed system is some or all of the following requirements:
Inherently distributed systems are systems that are distributed by their own nature; in other words,
they are composed of subsystems, which are physically and geographically separated. The
computation is inherently distributed. Eg., money transfer in banking
2. Resource sharing
Resources such as peripherals, complete data sets in databases, special libraries, as well as data
(variable/files) cannot be fully replicated at all the sites. Further, they cannot be placed at a single
site. Therefore, such resources are typically distributed across the system.
For example, distributed databases such as DB2 partition the data sets across several servers
In many scenarios, the data cannot be replicated at every site participating in the distributed
execution because it may be too large or too sensitive to be replicated.
For example, payroll data within a multinational corporation is both too large and too sensitive to
be replicated at every branch office/site.
4. Enhanced reliability
A distributed system has the inherent potential to provide increased reliability because of the
possibility of replicating resources and executions, as well as the reality that geographically
By resource sharing and accessing geographically remote data and resources, the performance/cost
ratio is increased.
6. Scalability
As the processors are usually connected by a wide-area network, adding more processors does not
pose a direct bottleneck for the communication network.
Heterogeneous processors may be easily added into the system without affecting the performance,
as long as those processors are running the same middleware algorithms. Similarly, existing
processors may be easily replaced by other processors.
This allows multiple processes to read and write data to the message queue without being
connected to each other.
Messages are stored on the queue until their recipient retrieves them. Message queues are
quite useful for inter process communication and are used by most operating systems.
Shared memory systems:
The shared memory is the memory that can be simultaneously accessed by multiple
processes. This is done so that the processes can communicate with each other.
Communication among processors takes place through shared data variables, and control
variables for synchronization among the processors.
Semaphores and monitors are common synchronization mechanisms on shared memory
systems.
When shared memory model is implemented in a distributed environment, it is termed as
distributed shared memory.
The shared memory system can be made to act as message passing system. The shared
address space can be partitioned into disjoint parts, one part being assigned to each
processor.
This involves the use of “send” and “receive” operations for “write” and “read” operations. Each
shared location can be modeled as a separate process; “write” to a shared location is emulated by
sending an update message to the corresponding owner process; a “read” to a shared location is
emulated by sending a query message to the owner process. As accessing another processor’s
memory requires send and receive operations, this emulation is expensive. Although emulating
shared memory might seem to be more attractive from a programmer’s perspective, it must be
remembered that in a distributed system, it is only an abstraction. Thus, the latencies involved in
read and write operations may be high even when using shared memory emulation because the
read and write operations are implemented by using network-wide communication under the
covers.
Message send and message receive communication primitives are done through Send() and
Receive(), respectively.
A Send primitive has two parameters: the destination and the buffer in the user space that
holds the data to be sent.
The Receive primitive also has two parameters: the source from which the data is to be
received and the user buffer into which the data is to be received.
There are two ways of sending data when the Send primitive is called:
Buffered: The standard option copies the data from the user buffer to the kernel buffer. The
data later gets copied from the kernel buffer onto the network. For the Receive primitive, the
Blocking primitives
The primitive commands wait for the message to be delivered. The execution of the
processes is blocked.
The sending process must wait after a send until an acknowledgement is made by the
receiver.
The receiving process must wait for the expected message from the sending process
The receipt is determined by polling common buffer or interrupt
This is a form of synchronization or synchronous communication.
A primitive is blocking if control returns to the invoking process after the processing for the
primitive completes.
If send is non blocking, it returns control to the caller immediately, before the message is sent.
The advantage of this scheme is that the sending process can continue computing in parallel
with the message transmission, instead of having the CPU go idle.
This is a form of asynchronous communication.
A primitive is non-blocking if control returns back to the invoking process immediately after
invocation, even though the operation has not completed.
For a non-blocking Send, control returns to the process even before the data is copied out of
the user buffer.
For anon-blocking Receive, control returns to the process even before the data may have
arrived from the sender.
Synchronous primitives
A Send or a Receive primitive is synchronous if both the Send() and Receive() handshake
with each other.
The processing for the Send primitive completes only after the invoking processor learnsthat
the other corresponding Receive primitive has also been invoked and that the receive
operation has been completed.
The processing for the Receive primitive completes when the data to be received is copied
into the receiver’s user buffer.
Asynchronous primitives
A Send primitive is said to be asynchronous, if control returns back to the invoking process
after the data item to be sent has been copied out of the user- specified buffer.
Blocking synchronous
Non- blocking synchronous
Blocking asynchronous
Non- blocking asynchronous
The data gets copied from the user buffer to the kernel buffer and is then sent over the
network.
After the data is copied to the receiver’s system buffer and a Receive call has been issued, an
acknowledgement back to the sender causes control to return to the process that invoked the
Send operation and completes the Send.
The user process that invokes the Send is blocked until the data is copied from the user’s
buffer to the kernel buffer.
The asynchronous Send completes when the data has been copied out of the user’s buffer. The
checking for the completion may be necessary if the user wants to reuse the buffer from which the
data was sent.
Fig 1.4 a) Blocking synchronous send and Fig 1.4 b) Non-blocking synchronous send
blocking receive and blocking receive
Fig 1.4 c) Blocking asynchronous send Fig 1.4 d) Non-blocking asynchronous send
Blocking Receive:
The Receive call blocks until the data expected arrives and is written in the specified user buffer.
Then control is returned to the user process.
The Receive call will cause the kernel to register the call and return the handle of a location
that the user process can later check for the completion of the non-blocking Receive
operation.
This location gets posted by the kernel after the expected data arrives and is copied to the
user-specified buffer. The user process can check for the completion of the non-blocking
Receive by invoking the Wait operation on the returned handle.
“Processor synchrony indicates that all the processors execute in lock-step with their clocks
synchronized.”
Since distributed systems do not follow a common clock, this abstraction is implemented using
some form of barrier synchronization to ensure that no processor begins executing the next step of
code until all the processors have completed executing the previous steps of code assigned to each
of the processors.
There exists a wide range of primitives for message-passing. The message-passing interface (MPI)
library and the PVM (parallel virtual machine) library are used largely by the scientific community
Message Passing Interface (MPI): This is a standardized and portable message- passing system to
function on a wide variety of parallel computers. MPI primarily addresses the message-passing
parallel programming model: data is moved from the address space of one process to that of
another process through cooperative operations on each process.
The primary goal of the Message Passing Interface is to provide a widely used standard for writing
message passing programs.
Parallel Virtual Machine (PVM): It is a software tool for parallel networking of computers. It is
designed to allow a network of heterogeneous Unix and/or Windows machines to be used as a
single distributed parallel processor.
Remote Procedure Call (RPC): The Remote Procedure Call (RPC) is a common model of request
reply protocol. In RPC, the procedure need not exist in the same address space as the calling
procedure. The two processes may be on the same system, or they may be on different systems with
a network connecting them.
Remote Method Invocation (RMI): RMI (Remote Method Invocation) is a way that a programmer
can write object-oriented programming in which objects on different computers can interact in a
Remote Procedure Call (RPC): RPC is a powerful technique for constructing distributed, client-
server based applications. In RPC, the procedure need not exist in the same address space as the
calling procedure. The two processes may be on the same system, or they may be on different
systems with a network connecting them. By using RPC, programmers of distributed applications
avoid the details of the interface with the network. RPC makes the client/server model of
computing more powerful and easier to program.
RMI RPC
RMI uses an object oriented paradigm RPC is not object oriented and does not deal
where the user needs to know the objectand with objects. Rather, it calls specific
the method of the object he needs toinvoke. subroutines that are already established
With RPC looks like a local call. RPC RMI handles the complexities of passingalong
handles the complexities involved with the invocation from the local to theremote
passing the call from the local to the computer. But instead of passing a procedural
remote computer. call, RMI passes a referenceto the object and
the method that is being
called.
Example: In asynchronous communication between systems, the caller sends a message and
continues with its other tasks not waiting for the answer. When the response eventually arrives it
handles it as any other arriving message. It is in contrast with synchronous communication where
Asynchronous Execution:
A communication among processes is considered asynchronous, when every
communicating process can have a different observation of the order of the messages
beingexchanged. In an asynchronous execution:
There is no processor synchrony and there is no bound on the drift rate
of processorclocks
Message delays are finite but unbounded
No upper bound on the time taken by a process
An example asynchronous execution with four processes P0 to P3 is shown in Figure 1.9. The arrows
denote the messages; the tail and head of an arrow mark the send and receive event for that
message, denoted by a circle and vertical line, respectively. Non-communication events, also
termed as internal events, are shown by shaded circles.
Synchronous Execution:
A communication among processes is considered synchronous when every process observes the
same order of messages within the system. In the same manner, the execution is considered
synchronous, when every individual process in the system observes the same total order of all the
processes which happen within it. In an synchronous execution:
Processors are synchronized and the clock drift rate between any two processors is bounded
Message delivery times are such that they occur in one logical step or round
Upper bound on the time taken by a process to execute a step.
An example of a synchronous execution with four processes P0 to P3 is shown in Figure 1.10. The
arrows denote the messages. All the messages sent in a round are received within that same round.
If system A can be emulated by system B, denoted A/B, and if a problem is not solvable in B, then it
is also not solvable in A. If a problem is solvable in A, it is also solvable in B. Hence, in a sense, all
four classes are equivalent in terms of computability in failure-free systems.
Performance
User perceived latency in distributed systems must be reduced. The common issues in
performance:
Sensor networks
o A sensor is a processor with an electro-mechanical interface that is capable of sensing
physical parameters.
o They are low cost equipment with limited computational power and battery life. They
are designed to handle streaming data and route it to external computer network and
processes.
o They are susceptible to faults and have to reconfigure themselves.
o These features introduces a whole new set of challenges, such as position estimation
and time estimation when designing a distributed system .
Ubiquitous or pervasive computing
o In Ubiquitous systems the processors are embedded in the environment to perform
application functions in the background.
o Examples: Intelligent devices, smart homes etc.
o They are distributed systems with recent advancements operating in wireless
environments through actuator mechanisms.
A distributed program is composed of a set of ‘n’ asynchronous processes p1, p2, .., pi ,...., pn.
that communicate by message passing over the communication network. Each process may
run on different processor.
The processes do not share a global memory and communicate solely by passing messages.
These processes do not share a global clock that is instantaneously accessible to these
processes.
Process execution and message transfer are asynchronous – a process may execute an action
spontaneously and a process sending a message does not wait for the delivery of the
message to be complete.
The global state of a distributed computation is composed of the states of the processes and
the communication channels. The state of a process is characterized by the state of its local
memory and depends upon the context.
The state of a channel is characterized by the set of messages in transit in the channel.
Let Cij denote the channel from process pi to process pj and let mij denote a message sent by
pi to pj.
The message transmission delay is finite and unpredictable.
Relation →msg defines causal dependencies between the pairs of corresponding send and receive
events.
An internal event changes the state of the process at which it occurs. A send event changes
the state of the process that sends the message and the state of the channel on which the
message is sent.
A receive event changes the state of the process that receives the message and the state of the
channel on which the message is received.
The partial ordering obtained by generalizing the relationship between two process is called as
happened-before relation or causal ordering or potential causal ordering. This term was coined
by Lamport. Happens-before defines a partial order of events in a distributed system. Some
events can’t be placed in the order. If say A →B if A happens before B. A→B is defined using the
following rules:
Local ordering:A and B occur on same process and A occurs before B.
Messages: send(m) → receive(m) for any message m
Transitivity: e → e’’ if e → e’ and e’ → e’’
When all the above conditions are satisfied, then it can be concluded that a→b is casually related.
Consider two events c and d; c→d and d→c is false (i.e) they are not casually related, then c and
d are said to be concurrent events denoted as c||d.
Casual Precedence
Physical as well as logical concurrency is two events that creates confusion in distributed systems.
Physical concurrency: Several program units from the same program that execute simultaneously.
Logical concurrency: Multiple processors providing actual concurrency. The actual execution of
programs is taking place in interleaved fashion on a single processor.
In a distributed computation, two events are logically concurrent if and only if they do not causally
affect each other.
Physical concurrency, on the other hand, has a connotation that the events occur at the same
instant in physical time.
This property ensures that causally related messages destined to the same destination are
delivered in an order that is consistent with their causality relation.
Causally ordered delivery of messages implies FIFO message delivery. (Note that CO FIFO
Non-FIFO.)
Causal ordering model considerably simplifies the design of distributed algorithms because
it provides a built-in synchronization.
“The global state of a distributed system is a collection of the local states of its components, namely,
the processes and the communication channels.”
• The state of a process is defined by the contents of processor registers, stacks, local memory, etc.
and depends on the local context of the distributed application.
• The state of channel is given by the set of messages in transit in the channel.
• The occurrence of events changes the states of respective processes and channels.