chubby

97
Chubby Lock Service Amir H. Payberah [email protected] Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 1 / 38

Upload: amir-payberah

Post on 15-Jul-2015

94 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Chubby

Chubby Lock Service

Amir H. [email protected]

Amirkabir University of Technology(Tehran Polytechnic)

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 1 / 38

Page 2: Chubby

What is the Problem?

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 2 / 38

Page 3: Chubby

What is the Problem?

I Large distributed system

I How to ensure that only one process across a fleet of processes actson a resource?

• Ensure only one server can write to a database.• Ensure that only one server can perform a particular action.• Ensure that there is a single master that processes all writes.• ...

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 3 / 38

Page 4: Chubby

What is the Problem?

I Large distributed system

I How to ensure that only one process across a fleet of processes actson a resource?

• Ensure only one server can write to a database.• Ensure that only one server can perform a particular action.• Ensure that there is a single master that processes all writes.• ...

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 3 / 38

Page 5: Chubby

What is the Problem?

I All these scenarios need a simple way to coordinate execution ofprocess to ensure that only one entity is performing an action.

I We need agreement (consensus)

I Paxos ...

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 4 / 38

Page 6: Chubby

What is the Problem?

I All these scenarios need a simple way to coordinate execution ofprocess to ensure that only one entity is performing an action.

I We need agreement (consensus)

I Paxos ...

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 4 / 38

Page 7: Chubby

What is the Problem?

I All these scenarios need a simple way to coordinate execution ofprocess to ensure that only one entity is performing an action.

I We need agreement (consensus)

I Paxos ...

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 4 / 38

Page 8: Chubby

How Can We Use Paxosto Solve the Problemof Coordination?

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 5 / 38

Page 9: Chubby

Possible Solutions

I Building a consensus library

I Building a centralized lock service

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 6 / 38

Page 10: Chubby

Consensus Library vs. Centralized Service

I Consensus library

• Library code has to be included in every program.• Application developers to be experts in distributed system.• Need to wait on majority (quorums).

I Centralized lock service

• Clean interface.• Service can be modified independently.• A single client can obtain a lock and make progress (non-quorum

based decisions, the lock service takes care of it)• Application developers do not have to worry about dealing with

operations, various failure modes debugging etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 7 / 38

Page 11: Chubby

Consensus Library vs. Centralized Service

I Consensus library• Library code has to be included in every program.

• Application developers to be experts in distributed system.• Need to wait on majority (quorums).

I Centralized lock service

• Clean interface.• Service can be modified independently.• A single client can obtain a lock and make progress (non-quorum

based decisions, the lock service takes care of it)• Application developers do not have to worry about dealing with

operations, various failure modes debugging etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 7 / 38

Page 12: Chubby

Consensus Library vs. Centralized Service

I Consensus library• Library code has to be included in every program.• Application developers to be experts in distributed system.

• Need to wait on majority (quorums).

I Centralized lock service

• Clean interface.• Service can be modified independently.• A single client can obtain a lock and make progress (non-quorum

based decisions, the lock service takes care of it)• Application developers do not have to worry about dealing with

operations, various failure modes debugging etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 7 / 38

Page 13: Chubby

Consensus Library vs. Centralized Service

I Consensus library• Library code has to be included in every program.• Application developers to be experts in distributed system.• Need to wait on majority (quorums).

I Centralized lock service

• Clean interface.• Service can be modified independently.• A single client can obtain a lock and make progress (non-quorum

based decisions, the lock service takes care of it)• Application developers do not have to worry about dealing with

operations, various failure modes debugging etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 7 / 38

Page 14: Chubby

Consensus Library vs. Centralized Service

I Consensus library• Library code has to be included in every program.• Application developers to be experts in distributed system.• Need to wait on majority (quorums).

I Centralized lock service

• Clean interface.• Service can be modified independently.• A single client can obtain a lock and make progress (non-quorum

based decisions, the lock service takes care of it)• Application developers do not have to worry about dealing with

operations, various failure modes debugging etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 7 / 38

Page 15: Chubby

Consensus Library vs. Centralized Service

I Consensus library• Library code has to be included in every program.• Application developers to be experts in distributed system.• Need to wait on majority (quorums).

I Centralized lock service• Clean interface.

• Service can be modified independently.• A single client can obtain a lock and make progress (non-quorum

based decisions, the lock service takes care of it)• Application developers do not have to worry about dealing with

operations, various failure modes debugging etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 7 / 38

Page 16: Chubby

Consensus Library vs. Centralized Service

I Consensus library• Library code has to be included in every program.• Application developers to be experts in distributed system.• Need to wait on majority (quorums).

I Centralized lock service• Clean interface.• Service can be modified independently.

• A single client can obtain a lock and make progress (non-quorumbased decisions, the lock service takes care of it)

• Application developers do not have to worry about dealing withoperations, various failure modes debugging etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 7 / 38

Page 17: Chubby

Consensus Library vs. Centralized Service

I Consensus library• Library code has to be included in every program.• Application developers to be experts in distributed system.• Need to wait on majority (quorums).

I Centralized lock service• Clean interface.• Service can be modified independently.• A single client can obtain a lock and make progress (non-quorum

based decisions, the lock service takes care of it)

• Application developers do not have to worry about dealing withoperations, various failure modes debugging etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 7 / 38

Page 18: Chubby

Consensus Library vs. Centralized Service

I Consensus library• Library code has to be included in every program.• Application developers to be experts in distributed system.• Need to wait on majority (quorums).

I Centralized lock service• Clean interface.• Service can be modified independently.• A single client can obtain a lock and make progress (non-quorum

based decisions, the lock service takes care of it)• Application developers do not have to worry about dealing with

operations, various failure modes debugging etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 7 / 38

Page 19: Chubby

Centralized Lock Service

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 8 / 38

Page 20: Chubby

Chubby is a Lock Service

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 9 / 38

Page 21: Chubby

Chubby

I Primary goals: reliability and availability (not high performance)

I Used in Google: GFS, Bigtable, etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 10 / 38

Page 22: Chubby

Chubby

I Primary goals: reliability and availability (not high performance)

I Used in Google: GFS, Bigtable, etc.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 10 / 38

Page 23: Chubby

Chubby Structure

I Two main components:• Server (chubby cell)• Client library

I Communicate via RPC

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 11 / 38

Page 24: Chubby

Chubby Cell

I A small set of servers (replicas)

I One is the master (elected from the replicas via Paxos)

I Maintain copies of simple database (replicated state machines)

• Only the master initiates reads and writes of this database.• All other replicas simply copy updates from the master (using the

Paxos protocol).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 12 / 38

Page 25: Chubby

Chubby Cell

I A small set of servers (replicas)

I One is the master (elected from the replicas via Paxos)

I Maintain copies of simple database (replicated state machines)

• Only the master initiates reads and writes of this database.• All other replicas simply copy updates from the master (using the

Paxos protocol).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 12 / 38

Page 26: Chubby

Chubby Cell

I A small set of servers (replicas)

I One is the master (elected from the replicas via Paxos)

I Maintain copies of simple database (replicated state machines)

• Only the master initiates reads and writes of this database.• All other replicas simply copy updates from the master (using the

Paxos protocol).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 12 / 38

Page 27: Chubby

Chubby Cell

I A small set of servers (replicas)

I One is the master (elected from the replicas via Paxos)

I Maintain copies of simple database (replicated state machines)• Only the master initiates reads and writes of this database.• All other replicas simply copy updates from the master (using the

Paxos protocol).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 12 / 38

Page 28: Chubby

Chubby Client

I Find the master: sending master location requests to replicas.

I All requests are sent directly to the master.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 13 / 38

Page 29: Chubby

Chubby Operations

I Write requests

• The master receives the request.• Write requests are propagated via the consensus protocol to all

replicas.• Acknowledges when write request reaches the majority of the

replicas

I Read requests

• Satisfied by the master alone.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 14 / 38

Page 30: Chubby

Chubby Operations

I Write requests• The master receives the request.

• Write requests are propagated via the consensus protocol to allreplicas.

• Acknowledges when write request reaches the majority of thereplicas

I Read requests

• Satisfied by the master alone.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 14 / 38

Page 31: Chubby

Chubby Operations

I Write requests• The master receives the request.• Write requests are propagated via the consensus protocol to all

replicas.

• Acknowledges when write request reaches the majority of thereplicas

I Read requests

• Satisfied by the master alone.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 14 / 38

Page 32: Chubby

Chubby Operations

I Write requests• The master receives the request.• Write requests are propagated via the consensus protocol to all

replicas.• Acknowledges when write request reaches the majority of the

replicas

I Read requests

• Satisfied by the master alone.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 14 / 38

Page 33: Chubby

Chubby Operations

I Write requests• The master receives the request.• Write requests are propagated via the consensus protocol to all

replicas.• Acknowledges when write request reaches the majority of the

replicas

I Read requests

• Satisfied by the master alone.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 14 / 38

Page 34: Chubby

Chubby Operations

I Write requests• The master receives the request.• Write requests are propagated via the consensus protocol to all

replicas.• Acknowledges when write request reaches the majority of the

replicas

I Read requests• Satisfied by the master alone.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 14 / 38

Page 35: Chubby

Let’s Go into More Details

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 15 / 38

Page 36: Chubby

Chubby Interface (1/2)

I Chubby exports a unix-like filesystem interface.

I Tree of files with names separated by slashes (namesapace):/ls/cell1/aut/cc14:

• 1st component (ls): lock service (common to all names)• 2nd component (cell1): the chubby cell name• The rest: the name of the directory and the file (name inside the

cell)

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 16 / 38

Page 37: Chubby

Chubby Interface (1/2)

I Chubby exports a unix-like filesystem interface.

I Tree of files with names separated by slashes (namesapace):/ls/cell1/aut/cc14:

• 1st component (ls): lock service (common to all names)• 2nd component (cell1): the chubby cell name• The rest: the name of the directory and the file (name inside the

cell)

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 16 / 38

Page 38: Chubby

Chubby Interface (1/2)

I Chubby exports a unix-like filesystem interface.

I Tree of files with names separated by slashes (namesapace):/ls/cell1/aut/cc14:

• 1st component (ls): lock service (common to all names)

• 2nd component (cell1): the chubby cell name• The rest: the name of the directory and the file (name inside the

cell)

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 16 / 38

Page 39: Chubby

Chubby Interface (1/2)

I Chubby exports a unix-like filesystem interface.

I Tree of files with names separated by slashes (namesapace):/ls/cell1/aut/cc14:

• 1st component (ls): lock service (common to all names)• 2nd component (cell1): the chubby cell name

• The rest: the name of the directory and the file (name inside thecell)

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 16 / 38

Page 40: Chubby

Chubby Interface (1/2)

I Chubby exports a unix-like filesystem interface.

I Tree of files with names separated by slashes (namesapace):/ls/cell1/aut/cc14:

• 1st component (ls): lock service (common to all names)• 2nd component (cell1): the chubby cell name• The rest: the name of the directory and the file (name inside the

cell)

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 16 / 38

Page 41: Chubby

Chubby Interface (2/2)

I Chubby maintains a namespace that contains files and directories,called nodes.

I Clients can create nodes and add contents to nodes.

I Support most normal operations:• create, delete, open, write, ...

I Clients open nodes to obtain handles that are analogous to unix filedescriptors.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 17 / 38

Page 42: Chubby

Chubby Interface (2/2)

I Chubby maintains a namespace that contains files and directories,called nodes.

I Clients can create nodes and add contents to nodes.

I Support most normal operations:• create, delete, open, write, ...

I Clients open nodes to obtain handles that are analogous to unix filedescriptors.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 17 / 38

Page 43: Chubby

Chubby Interface (2/2)

I Chubby maintains a namespace that contains files and directories,called nodes.

I Clients can create nodes and add contents to nodes.

I Support most normal operations:• create, delete, open, write, ...

I Clients open nodes to obtain handles that are analogous to unix filedescriptors.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 17 / 38

Page 44: Chubby

Chubby Interface (2/2)

I Chubby maintains a namespace that contains files and directories,called nodes.

I Clients can create nodes and add contents to nodes.

I Support most normal operations:• create, delete, open, write, ...

I Clients open nodes to obtain handles that are analogous to unix filedescriptors.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 17 / 38

Page 45: Chubby

Locks (1/2)

I Each Chubby file and directory (node) can act as a reader/writerlock.

I A client handle may hold the lock in two modes: writer (exclusive)mode or reader (shared) mode.

• Only one client can hold lock in writer mode.• Many clients can hold lock in reader mode.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 18 / 38

Page 46: Chubby

Locks (1/2)

I Each Chubby file and directory (node) can act as a reader/writerlock.

I A client handle may hold the lock in two modes: writer (exclusive)mode or reader (shared) mode.

• Only one client can hold lock in writer mode.• Many clients can hold lock in reader mode.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 18 / 38

Page 47: Chubby

Locks (1/2)

I Each Chubby file and directory (node) can act as a reader/writerlock.

I A client handle may hold the lock in two modes: writer (exclusive)mode or reader (shared) mode.

• Only one client can hold lock in writer mode.• Many clients can hold lock in reader mode.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 18 / 38

Page 48: Chubby

Locks (2/2)

I Locks are advisory in Chubby.

• Holding a lock is not necessary to access file.

• Holding a lock does not prevent other clients accessing file.

• Conflicts only with other attempts to acquire the same lock.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 19 / 38

Page 49: Chubby

Chubby Example (1/2)

I Electing a primary (leader) process.

I Steps in primary election:

• Clients open a lock file and attempt to acquire the lock in writemode.

• One client succeeds (becomes the primary) and writes itsname/identity into the file.

• Other clients fail (become replicas) and discover the name of theprimary by reading the file.

• Primary obtains sequencer and passes it to servers (servers caninsure that the elected primary is still valid).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 20 / 38

Page 50: Chubby

Chubby Example (1/2)

I Electing a primary (leader) process.

I Steps in primary election:• Clients open a lock file and attempt to acquire the lock in write

mode.

• One client succeeds (becomes the primary) and writes itsname/identity into the file.

• Other clients fail (become replicas) and discover the name of theprimary by reading the file.

• Primary obtains sequencer and passes it to servers (servers caninsure that the elected primary is still valid).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 20 / 38

Page 51: Chubby

Chubby Example (1/2)

I Electing a primary (leader) process.

I Steps in primary election:• Clients open a lock file and attempt to acquire the lock in write

mode.• One client succeeds (becomes the primary) and writes its

name/identity into the file.

• Other clients fail (become replicas) and discover the name of theprimary by reading the file.

• Primary obtains sequencer and passes it to servers (servers caninsure that the elected primary is still valid).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 20 / 38

Page 52: Chubby

Chubby Example (1/2)

I Electing a primary (leader) process.

I Steps in primary election:• Clients open a lock file and attempt to acquire the lock in write

mode.• One client succeeds (becomes the primary) and writes its

name/identity into the file.• Other clients fail (become replicas) and discover the name of the

primary by reading the file.

• Primary obtains sequencer and passes it to servers (servers caninsure that the elected primary is still valid).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 20 / 38

Page 53: Chubby

Chubby Example (1/2)

I Electing a primary (leader) process.

I Steps in primary election:• Clients open a lock file and attempt to acquire the lock in write

mode.• One client succeeds (becomes the primary) and writes its

name/identity into the file.• Other clients fail (become replicas) and discover the name of the

primary by reading the file.• Primary obtains sequencer and passes it to servers (servers can

insure that the elected primary is still valid).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 20 / 38

Page 54: Chubby

Chubby Example (2/2)

I Leader election

Open("/ls/foo/OurServicePrimary", "write mode")

if (successful) { // primary

SetContents(primary_identity)

} else { // replica

Open("/ls/foo/OurServicePrimary", "read mode",

"file-modification event")

when notified of file modification:

primary = GetContentsAndStat()

}

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 21 / 38

Page 55: Chubby

APIs

I Open(), Close(), Delete()

I GetContentsAndStat(), GetStat(), ReadDir()

I SetContents()

I SetACL()

I Locks: Acquire(), TryAcquire(), Release()

I Sequencers: GetSequencer(), SetSequencer(),CheckSequencer()

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 22 / 38

Page 56: Chubby

Events

I Chubby clients may subscribe to many events when they create ahandle.

I Events include:• File contents modified• Child node added, removed, or modified• Chubby master failed over• Handle has become invalid• Lock acquired• Conflicting lock requested from another client

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 23 / 38

Page 57: Chubby

Events

I Chubby clients may subscribe to many events when they create ahandle.

I Events include:• File contents modified• Child node added, removed, or modified• Chubby master failed over• Handle has become invalid• Lock acquired• Conflicting lock requested from another client

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 23 / 38

Page 58: Chubby

Locking - Problem

I After acquiring a lock and issuing a request (R1) a client may fail.

I Another client may acquire the lock and issue its own request (R2).

I R1 arrive later at the server and be acted upon (possible inconsis-tency).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 24 / 38

Page 59: Chubby

Locking - Problem

I After acquiring a lock and issuing a request (R1) a client may fail.

I Another client may acquire the lock and issue its own request (R2).

I R1 arrive later at the server and be acted upon (possible inconsis-tency).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 24 / 38

Page 60: Chubby

Locking - Problem

I After acquiring a lock and issuing a request (R1) a client may fail.

I Another client may acquire the lock and issue its own request (R2).

I R1 arrive later at the server and be acted upon (possible inconsis-tency).

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 24 / 38

Page 61: Chubby

Locking - Solutions (1/3)

I Solution 1: virtual time

• But, it is costly to introduce sequence numbers into all theinteractions.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 25 / 38

Page 62: Chubby

Locking - Solutions (1/3)

I Solution 1: virtual time• But, it is costly to introduce sequence numbers into all the

interactions.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 25 / 38

Page 63: Chubby

Locking - Solutions (2/3)

I Solution 2: sequencers

• Sequence numbers are introduced into only those interactions thatmake use of locks.

• A lock holder can obtain a sequencer from Chubby.• It attaches the sequencer to any requests that it sends to other

servers (e.g., Bigtable)• The other servers can verify the sequencer information

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 26 / 38

Page 64: Chubby

Locking - Solutions (2/3)

I Solution 2: sequencers• Sequence numbers are introduced into only those interactions that

make use of locks.

• A lock holder can obtain a sequencer from Chubby.• It attaches the sequencer to any requests that it sends to other

servers (e.g., Bigtable)• The other servers can verify the sequencer information

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 26 / 38

Page 65: Chubby

Locking - Solutions (2/3)

I Solution 2: sequencers• Sequence numbers are introduced into only those interactions that

make use of locks.• A lock holder can obtain a sequencer from Chubby.

• It attaches the sequencer to any requests that it sends to otherservers (e.g., Bigtable)

• The other servers can verify the sequencer information

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 26 / 38

Page 66: Chubby

Locking - Solutions (2/3)

I Solution 2: sequencers• Sequence numbers are introduced into only those interactions that

make use of locks.• A lock holder can obtain a sequencer from Chubby.• It attaches the sequencer to any requests that it sends to other

servers (e.g., Bigtable)

• The other servers can verify the sequencer information

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 26 / 38

Page 67: Chubby

Locking - Solutions (2/3)

I Solution 2: sequencers• Sequence numbers are introduced into only those interactions that

make use of locks.• A lock holder can obtain a sequencer from Chubby.• It attaches the sequencer to any requests that it sends to other

servers (e.g., Bigtable)• The other servers can verify the sequencer information

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 26 / 38

Page 68: Chubby

Locking - Solutions (3/3)

I Solution 3: lock-delay

• Correctly released locks are immediately available.• If a lock becomes free because holder failed or becomes inaccessible,

lock cannot be claimed by another client until lock-delay expires.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 27 / 38

Page 69: Chubby

Locking - Solutions (3/3)

I Solution 3: lock-delay• Correctly released locks are immediately available.

• If a lock becomes free because holder failed or becomes inaccessible,lock cannot be claimed by another client until lock-delay expires.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 27 / 38

Page 70: Chubby

Locking - Solutions (3/3)

I Solution 3: lock-delay• Correctly released locks are immediately available.• If a lock becomes free because holder failed or becomes inaccessible,

lock cannot be claimed by another client until lock-delay expires.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 27 / 38

Page 71: Chubby

Caching

I To reduce read traffic, Chubby clients cache file data and nodemeta-data.

I Write-through: write is done synchronously both to the cache andto the primary copy.

I Master will invalidate cached copies upon a write request.

I The client also can allow its cache lease to expire.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 28 / 38

Page 72: Chubby

Caching

I To reduce read traffic, Chubby clients cache file data and nodemeta-data.

I Write-through: write is done synchronously both to the cache andto the primary copy.

I Master will invalidate cached copies upon a write request.

I The client also can allow its cache lease to expire.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 28 / 38

Page 73: Chubby

Caching

I To reduce read traffic, Chubby clients cache file data and nodemeta-data.

I Write-through: write is done synchronously both to the cache andto the primary copy.

I Master will invalidate cached copies upon a write request.

I The client also can allow its cache lease to expire.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 28 / 38

Page 74: Chubby

Caching

I To reduce read traffic, Chubby clients cache file data and nodemeta-data.

I Write-through: write is done synchronously both to the cache andto the primary copy.

I Master will invalidate cached copies upon a write request.

I The client also can allow its cache lease to expire.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 28 / 38

Page 75: Chubby

Session Lease (1/3)

I Lease: a promise by one party to abide by an agreement for a giveninterval of time unless the promise is explicitly revoked.

I Session: a relationship between a Chubby cell and a Chubby client.

I Session lease: interval during which client’s cached items (handles,locks, files) are valid.

I Session maintained through KeepAlives messages.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 29 / 38

Page 76: Chubby

Session Lease (1/3)

I Lease: a promise by one party to abide by an agreement for a giveninterval of time unless the promise is explicitly revoked.

I Session: a relationship between a Chubby cell and a Chubby client.

I Session lease: interval during which client’s cached items (handles,locks, files) are valid.

I Session maintained through KeepAlives messages.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 29 / 38

Page 77: Chubby

Session Lease (1/3)

I Lease: a promise by one party to abide by an agreement for a giveninterval of time unless the promise is explicitly revoked.

I Session: a relationship between a Chubby cell and a Chubby client.

I Session lease: interval during which client’s cached items (handles,locks, files) are valid.

I Session maintained through KeepAlives messages.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 29 / 38

Page 78: Chubby

Session Lease (1/3)

I Lease: a promise by one party to abide by an agreement for a giveninterval of time unless the promise is explicitly revoked.

I Session: a relationship between a Chubby cell and a Chubby client.

I Session lease: interval during which client’s cached items (handles,locks, files) are valid.

I Session maintained through KeepAlives messages.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 29 / 38

Page 79: Chubby

Session Lease (2/3)

I If client’s local lease expires (happens when a master fails over)

• Client disables cache.• Session in jeopardy, client waits in grace period (45s).• Sends jeopardy event to application.• Application can suspend activity.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 30 / 38

Page 80: Chubby

Session Lease (2/3)

I If client’s local lease expires (happens when a master fails over)• Client disables cache.

• Session in jeopardy, client waits in grace period (45s).• Sends jeopardy event to application.• Application can suspend activity.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 30 / 38

Page 81: Chubby

Session Lease (2/3)

I If client’s local lease expires (happens when a master fails over)• Client disables cache.• Session in jeopardy, client waits in grace period (45s).

• Sends jeopardy event to application.• Application can suspend activity.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 30 / 38

Page 82: Chubby

Session Lease (2/3)

I If client’s local lease expires (happens when a master fails over)• Client disables cache.• Session in jeopardy, client waits in grace period (45s).• Sends jeopardy event to application.

• Application can suspend activity.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 30 / 38

Page 83: Chubby

Session Lease (2/3)

I If client’s local lease expires (happens when a master fails over)• Client disables cache.• Session in jeopardy, client waits in grace period (45s).• Sends jeopardy event to application.• Application can suspend activity.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 30 / 38

Page 84: Chubby

Session Lease (3/3)

I Client attempts to exchange KeepAlive messages with master duringgrace period.

• Succeed: re-enables cache; send safe event to application• Failed: discards cache; sends expired event to application

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 31 / 38

Page 85: Chubby

Session Lease (3/3)

I Client attempts to exchange KeepAlive messages with master duringgrace period.

• Succeed: re-enables cache; send safe event to application

• Failed: discards cache; sends expired event to application

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 31 / 38

Page 86: Chubby

Session Lease (3/3)

I Client attempts to exchange KeepAlive messages with master duringgrace period.

• Succeed: re-enables cache; send safe event to application• Failed: discards cache; sends expired event to application

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 31 / 38

Page 87: Chubby

Scaling

I Reducing communication with the master.

I Two techniques:• Proxies• Partitioning

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 32 / 38

Page 88: Chubby

Scaling - Proxies

I Proxy is a trusted process that pass requests from other clients toa Chubby cell.

I Can handle KeepAlives and reads → reduce the master load.

I Cannot reduce write loads, but they are << 1% of workload.

I Introduces another point of failure.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 33 / 38

Page 89: Chubby

Scaling - Proxies

I Proxy is a trusted process that pass requests from other clients toa Chubby cell.

I Can handle KeepAlives and reads → reduce the master load.

I Cannot reduce write loads, but they are << 1% of workload.

I Introduces another point of failure.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 33 / 38

Page 90: Chubby

Scaling - Proxies

I Proxy is a trusted process that pass requests from other clients toa Chubby cell.

I Can handle KeepAlives and reads → reduce the master load.

I Cannot reduce write loads, but they are << 1% of workload.

I Introduces another point of failure.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 33 / 38

Page 91: Chubby

Scaling - Proxies

I Proxy is a trusted process that pass requests from other clients toa Chubby cell.

I Can handle KeepAlives and reads → reduce the master load.

I Cannot reduce write loads, but they are << 1% of workload.

I Introduces another point of failure.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 33 / 38

Page 92: Chubby

Scaling - Partitioning

I Namespace partitioned between servers.

I N partitions, each with master and replicas

I Node D/C stored on P(D/C) = hash(D) mod N

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 34 / 38

Page 93: Chubby

Scaling - Partitioning

I Namespace partitioned between servers.

I N partitions, each with master and replicas

I Node D/C stored on P(D/C) = hash(D) mod N

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 34 / 38

Page 94: Chubby

Summary

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 35 / 38

Page 95: Chubby

Summary

I Library vs. Service

I Chubby: coarse-grained lock service

I Chubby cell and clients

I Unix-like interface

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 36 / 38

Page 96: Chubby

References:

I M. Burrows, The Chubby lock service for loosely-coupled distributedsystems, OSDI, 2006.

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 37 / 38

Page 97: Chubby

Questions?

Amir H. Payberah (Tehran Polytechnic) Chubby 1393/7/5 38 / 38