33
Introduction & Background Lakshmish Ramaswamy

Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Embed Size (px)

Citation preview

Page 1: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Introduction & Background

Lakshmish Ramaswamy

Page 2: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Why Distributed Systems?• A collection of independent computers that

appears to its users as a single coherent system

• Reasons for distribution– Distributed (and mobile) users– Distributed data/information– Distributed organizations– Distributed resources

• Enabling technology – Communications and networking

Page 3: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Distributed System Organization

A distributed system organized as middleware.Note that the middleware layer extends over multiple machines.

1.1

Page 4: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Design Goals • Enable controlled resource sharing

• Transparency

• Openness

• Scalability

• Performance

• Failure resilience

• Security & privacy

Page 5: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Examples of Distributed Systems

• World Wide Web– Information disseminations– E-commerce

• Distributed file systems

• Distributed databases

• Web-farms

• P2P file sharing systems

• Ad-hoc networks

• Sensor networks

Page 6: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Middleware• Layer on top of Network OS services• Hide heterogeneity • Doesn’t manage individual nodes• Provides complete set of services

Page 7: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Client Server Model

• Earliest model– Simple– Still applicable in many scenarios

• Server– Implements specific service

• Client– Requests service

• Models of communication– Connectionless– Connection-oriented

Page 8: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Clients and Servers

General interaction between a client and a server.

1.25

Page 9: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Multitiered Architectures (2)

An example of a server acting as a client.

1-30

Page 10: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Modern Architectures

An example of horizontal distribution of a Web service.

1-31

• Vertical Distribution: Different components on different machines

• Horizontal Distribution: Each part operates on its own complete

• Hybrid: Incorporates features of both vertical and horizontal

Page 11: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Peer-to-Peer Architectures• No distinction between client and server

– Nodes can act both as client and server

• Promotes interaction within social groups

• Provides better scalability

• File sharing has been the dominant application– Napster, Gnutella, Kazaa

• Other applications are still in nascent stages

• Decentralized protocols

Page 12: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Network Protocols

Layers, interfaces, and protocols in the OSI model.

2-1

Page 13: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Functionalities of Layers

• Physical: Standardizes signaling interfaces• Data link: Organizes bits to form frames, detects and

corrects transmission errors• Network layer: Routing (Internet protocol [IP])• Transport layer: Reliability (retransmission, ordering of

packets)• Session layer: Dialog control and synchronization• Presentation layer: Formats of messages and records• Application layer: Specific to applications (HTTP, FTP)

Page 14: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Types of Communication

• Persistence – Persistent communication – Stores message until

communicated to user– Transient communication – Stored only when sending

and receiving processes are alive• Transport level protocols provide transient communication

• Synchronicity– Asynchronous – Sender continues after sending message– Synchronous – Sender blocks until message is stored at

receiver's local buffer, delivered to receiver or processed by receiver

Page 15: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Message Oriented Transient Communication -Berkeley Sockets

Communication pattern using TCP/IP sockets

• Interface for transport layer

• A communications end point

Page 16: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Processes & Threads

• Virtual processors– Created by OS to execute a program

• Process is a program in execution– Executed on one of the virtual processors

• Operating systems ensure that processes are independent and transparent– Resource sharing is transparent

• Creating processes is costly

• Switching processes is costly too

Page 17: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Threads• Similar to a process

– Perceived as execution of (a part of) program– Information maintained for sharing CPU is minimal

• Context of threads is captured by CPU context– May be a little more information is needed for

management (like locks)

• Very little overheads– Thread switching is easy

• Can provide performance gains

Page 18: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Names & Naming System• Required for identifying entities, locating them,

communicating to them• Name can be resolved to the entity it refers to• Name is a string of bits used to refer to an entity• Entity can resources/users/data/processes• Access Point – Host of another entity

– Name of access point is its address

• Naming system resolves names• Naming system in distributed systems can itself

be distributed

Page 19: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Name Spaces

A general naming graph with a single root node.

• Organization of names usually as a directed graph • Leaf Node – Represents named entity• Directory node – Enlists other names

Page 20: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Name Space Distribution

An example partitioning of the DNS name space, including Internet-accessible files, into three layers.

Page 21: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Importance of Clocks & Synchronization

• Avoiding simultaneous access of resources

• Process may need to agree upon ordering of events

• Synchronization & ordering is difficult in distributed setting

• Notion of time is tricky in distributed setting– How to deal with clock drifts?

• Logical clocks– Agreement with regards to ordering of events suffices

• Happens-before relation

Page 22: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Mutual Exclusion

• Ensuring consistency of data sometimes needs exclusive access to data

• Critical regions for mutual exclusion

• When a process wants to read/update shared data structures it first enters a critical region

• Only one process allowed to be in the critical region

• Coordinator-based centralized algorithm

• Ricart and Agrawala’s algorithm

• Token ring algorithm

Page 23: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Transactions• Protects data and allows processes to access and modify

multiple data items as a single atomic transaction– If process backs out halfway, everything is restored back

• Originated in business world– Parties free to negotiate and back-off during negotiation

– No backing-off after the contract is signed

• Initiator process announces the beginning of a transaction• Processes create, update, and delete entries• Initiator announces that it wants others to “commit”

– Transaction made permanent if everyone agrees

– Otherwise transaction is aborted and all entries are restored back

Page 24: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Transaction Primitives

Examples of primitives for transactions.

Primitive Description

BEGIN_TRANSACTION Make the start of a transaction

END_TRANSACTION Terminate the transaction and try to commit

ABORT_TRANSACTION Kill the transaction and restore the old values

READ Read data from a file, a table, or otherwise

WRITE Write data to a file, a table, or otherwise

Page 25: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

ACID Properties of Transactions• Atomic – Happens indivisibly to the outside world

• Consistent – Does not violate system constraints

• Isolated – Concurrent transactions do not interfere with each other

• Durable – Changes are permanent when a transaction commits

Page 26: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

How to Implement Transactions?• Private workspace

– When a process starts a transaction, it gets a private workspace of all files it needs to use

– Operations only on private workspace– Private workspace is written back (ignored) on commit

(abort)– Efficiency problems – copying everything is costly.

Page 27: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Distributed Transactions• Distributed transaction is a transaction where in data

is distributed• 2 Phase commit protocol• Commit request phase

– Coordinator sends query to commit message to all nodes– Nodes place an entry into their undo and redo logs– Nodes send agreement/abort messages

• Commit phase– Coordinator places an entry into log– Sends commit/abort messages to all nodes– Nodes send acknowledgements

Page 28: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Concurrency Control• Concurrent transactions are isolated

– Final result should be the same as if the transactions were executed one after another in some order

• Synchronization classification– Locking– Timestamps

• Two phase locking – Growing & shrinking phases– Transaction acquires all locks before releasing any of

them

• Distributed 2PL– Coordinator manages all lock operations

Page 29: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Replication• Two primary reasons

– Improving reliability of system– Improving scalability and performance of system

• Reliability– Resilience to failures– Protection against data corruption: Byzantine failures and

quorum-based systems

• Scalability– Scaling in numbers– Geographical scaling

Page 30: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Problems of Replication

• Creating and maintaining replicas is not free

• Multiple copies leads to consistency problems– What happens when one of the replicas gets modified?– Modifications have to be carried out at all replicas– How and when determines the cost of replication

• WWW-based systems– Browser and client side caches– May lead to stale pages– TTL model, Update/Invalidate model

Page 31: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Consistency Models

• Strict

• Sequential

• Linearizable

• Causal

• Fifo

• Weak

• Release

• Entry

Page 32: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Fault Tolerance & Dependability• Availability

– Ready to be used IMMEDIATELY

• Reliability– Run continuously without FAILURE

• Safety– When fails, nothing catastrophic happens

• Maintainability– How easy a failed system can be repaired

• Failures can be malicious or non-malicious

Page 33: Introduction & Background Lakshmish Ramaswamy. Why Distributed Systems? A collection of independent computers that appears to its users as a single coherent

Failure Masking

• Hiding failures from other processes

• Fault tolerance by redundancy

• Information redundancy – Error correcting codes

• Temporal redundancy – Transactions

• Physical redundancy – Multiple disks