IT-601 Distributed System

advertisement
GEC Group of College’s
Dept. of Computer Sc. & Engg. and IT
Teaching Notes
IT – 601
D.S
Prepared by
Ms. Priyashree sharma
1
DISTRIBUTED SYSTEM (IT-601)
SYLLABUS
Unit I: Characterization of Distributed Systems: Introduction, Examples of distributed
Systems, Resource sharing and the Web Challenges. System Models: Architectural models,
Fundamental Models Theoretical Foundation for Distributed System : Limitation of
Distributed system, absence of global clock, shared memory, Logical clocks, Lamport’s
&vectors logical clocks. Distributed Mutual Exclusion: Classification of distributed mutual
exclusion, requirement of mutual exclusion theorem, Token based and non token based
algorithms.
Unit II: Distributed Deadlock Detection: system model, resource Vs communication
deadlocks, deadlock prevention, avoidance, detection & resolution, centralized dead lock
2
detection, distributed dead lock detection, path pushing algorithms, edge chasi algorithms.
Agreement Protocols: Introduction, System models, classification of Agreement
Problem,Byzantine agreement problem, Consensus problem.
Unit III: Distributed Objects and Remote Invocation: Communication between distributed
objects, Remote procedure call, Events and notifications, Java RMI case study. Security:
Overview of security techniques, Distributed File Systems: File service architecture, Sun
Network File System, The Andrew File System.
Unit IV: Distributed Transactions: Flat and nested distributed transactions, Atomic Commit
protocols, Concurrency control in distributed transactions, Distributed deadlocks,
Transaction recovery. Replication: System model and group communication, Fault-tolerant
services, Transactions with replicated data.
Unit V: Distributed Algorithms: Destination based routing, APP (assignment problem in
parallel), Deadlock free Packet switching, Introduction to Wave & traversal algorithms,
Election algorithm. CORBA Case Study:
3
S.NO
1
PAGE NO.
NAME OF TOPIC
INTRODUCTION, ADVANTAGES AND
DISADVANTAGES
2
GOALS OF DISTRIBUTED SYSTEM
3
GENERAL EXAMPLE OF D.S.
4
5-6
7-8
RESOURCE SHARING AND THE WEB
CHALLENGES
5
SYSTEM MODELS
6
LAMPORTS ALGORITHM (clock)
7
1-4
9
10
11
12
8
VECTOR CLOCKS
ABSENCE OF GLOBAL CLOCK AND SHARED
MEMORY
9
MUTUAL EXCLUSION REQUIREMENT
15
10
MUTUAL EXCLUSION IN DISTRIBUTED SYSTEM
16-17
11
MUTUAL EXCLUSION ALGORITHMS :TOKEN BASED
ALGORITHMS, NON TOKEN BASED
4
13-14
18-20
LECTURES NOTES ON DISTRIBUTED SYSTEM (IT – 601)
( UNIT-1)
INTRODUCTION
A distributed system is a collection of independent computers that appear to
the users of the system as a single system.
Examples:
•
•
•
•
•
•
•
•
•
•
•
•
Network of workstations
Distributed manufacturing system (e.g., automated assembly line)
Network of branch office computers
Nationalized bank
5
ADVANTAGES OF DISTRIBUTED SYSTEM OVER CENTRALISED SYSTEM
 Economics: a collection of microprocessors offer a better
price/performance than mainframes. Low price/performance ratio: cost
effective way to increase computing power.
 Speed: a distributed system may have more total computing power than
a mainframe. Ex. 10,000 CPU chips, each running at 50 MIPS. Not
possible to build 500,000 MIPS single processor since it would require
0.002 n sec instruction cycle. Enhanced performance through load
distributing.
 Inherent distribution: Some applications are inherently distributed. Ex.
a supermarket chain.
 Reliability: If one machine crashes, the system as a whole can still
survive. Higher availability and improved reliability.
 Incremental growth: Computing power can be added in small
increments. Modular expandability
 Another deriving force: the existence of large number of personal
computers, the need for people to collaborate and share information.
DISADVANTAGES OF DISTRIBUTED SYSTEM
 Saturation, lossy transmissions
 Security: Software: difficult to develop software for distributed system
 Network easy access also applies to secrete data
(INTERACTION BETWEEN A CLIENT AND SERVER)
6
GOALS OF DISTRIBUTED SYSTEM
• Resource Accessibility
• Distribution Transparency
• Openness
• Scalability
1) RESOURCE SCALABILITY
a)Support user access to remote resources (printers, data files, web
pages, and CPU cycles) and the fair sharing of the resources.
b) Economics of sharing expensive resources
c) Performance enhancement – due to multiple processors; also due
to ease of collaboration and info exchange – access to remote services
d)Resource sharing introduces security problems
2) DISTRIBUTION TRANSPARENCY
a) Software hides some of the details of the distribution of system
resources.
b) Makes the system more user friendly.
c) A distributed system that appears to its users & applications to be a
single computer system is said to be transparent.
– Users & apps should be able to access remote resources in the
same way they access local resources.
d) Transparency has several dimensions.
7
3) OPENESS
– An open distributed system “…offers services according to
standard rules that describe the syntax and semantics of those
services.”
– Compare to network protocols, Not proprietary
• Interface Definition/Description Languages (IDL): used todescribe the
interfaces between software components, usually in a distributed
system
– Definitions are language & machine independent
– Support communication between systems using different
OS/programming languages; e.g. a C++ program running on
Windows communicates with a Java program running on UNIX
– Communication is usually RPC-based.
4) SCALABILITY
• Dimensions that may scale:
– With respect to size
– With respect to geographical distribution
– With respect to the number of administrative organizations
spanned
• A scalable system still performs well as it scales up along any of the
three dimensions.
PITFALLS/ ISSUES OF D.S
8
• Requirement for advanced software to realize the potential benefits.
• Security and privacy concerns regarding network communication
• Replication of data and services provides fault tolerance and availability,
but at a cost.
• Network reliability, security, heterogeneity, topology
• Latency and bandwidth
• Administrative domains.
GENERAL EXAMPLE OF D.S.
 Internet ( collection of networks of networks)
 Intranets( it is a part of internet)
 Mobile networks
1) INTERNET
 The Internet is a vast interconnected collection of computer
networks of many different types.
 Multimedia services are available in the Internet enabling users to
access audio and video dataincluding music, radio, TV channels,
phone, and video conferencing.
2) INTRANET
9
An intranet is a portion of the Internet that is separately administered
and has a boundary that can be configured to enforce local security
policies.
3) MOBILE NETWORKS
 Technological advances in device miniaturization and wireless
networking have led increasingly to the integration of small and
portable computing devices into distributed systems.
 These devices include:
 Laptop computer
 GENERAL EXAMPLES OF DISTRIBUTED SYSTEM
 Handheld devices
• Personal digital assistants(PDAs)
• Mobile phones
• Pagers
• Video cameras
• Digital cameras Wearable devices
• Smart watches with functionality similar to a PDA
• Devices embedded in appliances
• Washing machines
• Hi-fi systems
• Cars
• Refrigerators
10
RESOURCE SHARING AND THE WEB CHALLENGES
The World Wide Web
 The World Wide Web is an evolving system for publishing and
accessing resources and services across the Internet.
DESIGN CHALLENGES / WEB CHALLENGES
Designers of distributed systems need to take the following challenges into
account:
 Heterogeneity: - Heterogeneous components must be able to
interoperate.
 Openness:-Interfaces should allow components to be added or
replaced.
11
 Security:-The system should only be used in the way intended.
 Scalability:-System should work efficiently with an increasing
number of users.
 System performance should increase with inclusion of additional
resources.
 Failure handling:-Failure of a component (partial failure) should
not result in failure of the whole system.
 Transparency:-Distribution should be hidden from the user as
much as possible.
SYSTEM MODELS
Architectural Models
• An architectural model simplifies and abstracts the Functions of the
individual components of a Distributed system and then it considers
– The placement of the components across a network of Computers
– The interrelationships between the components
• Process classification
– Server process: a process that accepts requests from Other processes
– Client process, peer process.
Fundamental Distributed System Models
– Description of properties that are present in all distributed architectures.
Interaction Models
– Issues dealing with the Interaction of process such as performance and
events.
Failure Models
– Specification of faults that can be Exhibited by processes and
communication channels
Security Models
– Threats to processes and
Communication channels
12
LAMPORTS ALGORITHM (clock)
Lamport's algorithm is based on two implementation rules that define how
each process's local clock is incremented.
Notation:
• the processes are named Pi ,
• each process has a local clock, Ci
• The clock time for an event a on process Pi is denoted by Ci (a).
Rule 1:
If a and b are two successive events in Pi and a > b
Then Ci (b) = Ci (a) + d where d > 0.
Rule 2:
If a is a message send event on Pi and b is the message receive event on Pj
then:
• the message is assigned the timestamp tm = Ci (a)
• Cj (b) = max ( Cj , tm +d)
LIMITATION OF LAMPORTS ALGO
In Lamport's algorithm two events that are causally related will be related
through their clock times. That is:
If a --> b then C (a) <C (b)
13
However, the clock times alone do not reveal which events are causally
related. That is, if C (a) <C (b) then it is not known if a --> b or not. All that is
known is:
If C (a) <C (b) then b -/-> a
It would be useful to have a stronger property - one that guarantees that
a-->b if C (a) <C (b)
This property is guaranteed by Vector Clocks.
VECTOR CLOCKS
• Each process Pi has a clock Ci, which is an integer vector of size ‘n’ (n =
number of processes)
• For every event ‘a’ in Pi, the clock has a value Ci(a), called the timestamp of event ‘a’ in Pi
• The elements of clock Ci(a) are the clock values of all processes, e.g.
– Ci [ i ], the i-th entry, is Pi clock value at ‘a’
– Ci [ j ], for j  i is Pi’s best guess of Pj’s logical time (last event in Pj
communicated to Pi)
• Implementation rules
14
– Ci incremented for every event ‘a’ in Pi
Ci[i]Ci[i] + d, where d > 0
1. If event ‘a’ is Pi sending message ‘m’, then message ‘m’ receives
vector time-stamp
tm = Ci (a)
When Pj receives message ‘m’, its clock Cj updated
k, Cj[k] max (Cj[k], tm[k])
ABSENCE OF GLOBAL CLOCK AND SHARED MEMORY
• Absence of a global clock
– Possible solutions
1. Common clock for all distributed computers
– Disadvantage: Unpredictable and variable transmission
delays make it impractical
2. Synchronized clocks, one for each computer
– Disadvantage: Each clock will drift at a different rate,
making it impractical
– Conclusion
1. No system-wide physical common (global) clock can be
implemented
– Consequences
1. Temporal ordering of events is difficult (e.g., scheduling)
2. Collecting up to date information is difficult
• Absence of shared memory
– No single process can have complete, up-to-date state of entire
distributed system (global state)Any operatingsystem or process
cannot know accurately the current state of all processes in the
distributed system
– An operating system or process can only know
15
– The current state of all processes on the local system
– The state of remote operating systems and processes that is
received by messages
– These messages represent the state in the past
– Implementation of mutual exclusion and avoidance of deadlock
and starvation become much more complicated
EXAMPLES:-
• Bank account distributed over two branches
– The total amount in the account is the sum at each branch
– Account balance determined at 3 p.m.
– Messages are sent to request the information
• Process/event graph: processes, events, snapshots, and messages
• At the time of balance determination, the balance from branch A is in
transit to branch B
• Balance = $0
• Possible solution: include in the ‘state’ information both the current
balance and the transfers (messages)
• Additional problem: the clocks at the two branches are not perfectly
synchronized
• Balance: $200
16
MUTUAL EXCLUSION REQUIREMENT
• Mutual exclusion must be enforced: only one process at a time is
allowed in its critical section
• A process that halts in its noncritical section must do so without
interfering with other processes
• It must not be possible for a process requiring access to a critical section
to be delayed indefinitely: no deadlock or starvation
• When no process is in a critical section, any process that requests entry
to its critical section must be permitted to enter without delay
• No assumptions are made about relative process speeds or number of
processors
• A process remains inside its critical section for a finite time only
17
MUTUAL EXCLUSION IN DISTRIBUTED SYSTEM
• Centralized algorithm
– One node is designated as the control node
– This node controls access to all shared objects
– To access a critical resource, a process sends Request to the local
resource controlling process
– The local resource controlling process forwards Request to the
control node
– The control node returns Reply (permission) when shared resource
available
– When process that received resource has finished, sends Release
to control node
– Disadvantages: performance and availability
– Distributed algorithm
18
– All nodes have equal amount of information, on average
– Each node has only a partial picture of the total system and must
make decisions based on this information
– All nodes bear equal responsibility for the final decision
– All nodes expend equal effort, on average, in effecting a final
decision
– Failure of a node, in general, does not result in a total system
collapse
– There exists no system wide common clock with which to regulate
the time of events
19
MUTUAL EXCLUSION ALGORITHMS
1. TOKEN BASED
2. NON TOKEN BASED
Mutual exclusion algorithms for distributed systems are classified by
Their communication topology (non-token-based, token-based), and
The amount of information maintained by each site about the other sites
– Non-token-based algorithms
• Sites exchange two or more rounds of messages
• A site can enter CS when an assertion on local variables
becomes true
– Token-based algorithms
• Token is passed between sites
• A site can enter CS if it holds the token
TOKEN BASED ALGORITHMS
• Principle of operation
20
– A site allowed to enter CS if it holds a token: unique token shared
by all sites for CS access control
– Sequence numbers used by token-based algorithms (unlike nontoken-based algorithms which use time-stamps)
• Upon requesting the token, a site records a sequence
number
(Sequence number) i (sequence number) i + 1
It represents the number of requests that site made for the CS
– Sequence numbers of different sites advance independently
– Sequence numbers are used to distinguish between old (known or
serviced) requests and new ones
• Correctness proof
– Exclusion guaranteed if only the site that holds token accesses CS
NON TOKEN BASED ALGORITHM
•
•
•
•
•
•
•
•
•
Ricart-Agarwala Algorithm
Improvement over Lamport’s
Main Idea:
– node j need not send a REPLY to node i if j has a request with
timestamp lower than the request of i (since i cannot enter before
j anyway in this case)
Does not require FIFO
2(n – 1) messages per critical section invocation
Synchronization delay = max. message transmission time
requests granted in order of increasing timestamps
To request critical section:
send timestamped REQUEST message (tsi, i)
On receiving request (tsi, i) at j:
21
send REPLY to i if j is neither requesting nor executing critical section or if j is
requesting and i’s request timestamp is smaller than j’s request timestamp.
Otherwise, defer the request.
• To enter critical section:
• i enters critical section on receiving REPLY from all nodes
• To release critical section:
• send REPLY to all deferred requests
•
Maekawa’s Algorithm
To request critical section:
send times tamped REQUEST message (tsi, i)
On receiving request (tsi, i) at j:
– send REPLY to i if j is neither requesting nor executing critical
section or if j is requesting and i’s request timestamp is smaller
than j’s request timestamp. Otherwise, defer the request.
To enter critical section:
– i enters critical section on receiving REPLY from all nodes
To release critical section:
– send REPLY to all deferred requests
– To request critical section:
– i sends REQUEST message to all process in Ri
– On receiving a REQUEST message:
– send a REPLY message if no REPLY message has been sent since
the last RELEASE message is received. Update status to indicate
that a REPLY has been sent. Otherwise, queue up the REQUEST
– To enter critical section:
– i enters critical section after receiving REPLY from all nodes in Ri
– To release critical section:
22
– send RELEASE message to all nodes in Ri
– On receiving a RELEASE message, send REPLY to next node in
queue and delete the node from the queue. If queue is empty,
update status to indicate no REPLY message has been sent.
–
Message Complexity: 3*sqrt(N)
Synchronization delay =
2 *(max message transmission time)
Major problem: DEADLOCK possible
Need three more types of messages (FAILED, INQUIRE, YIELD) to
handle deadlock. Message complexity can be 5*sqrt(N)
23
Download