Fair K Mutual Exclusion Algorithm for Peer to Peer Systems ∗
Total Page:16
File Type:pdf, Size:1020Kb
Fair K Mutual Exclusion Algorithm for Peer To Peer Systems ∗ Vijay Anand Reddy, Prateek Mittal, and Indranil Gupta University of Illinois, Urbana Champaign, USA {vkortho2, mittal2, indy}@uiuc.edu Abstract is when multiple clients are simultaneously downloading a large multimedia file, e.g., [3, 12]. Finally applications k-mutual exclusion is an important problem for resource- where a service has limited computational resources will intensive peer-to-peer applications ranging from aggrega- also benefit from a k mutual exclusion primitive, preventing tion to file downloads. In order to be practically useful, scenarios where all the nodes of the p2p system simultane- k-mutual exclusion algorithms not only need to be safe and ously overwhelm the server. live, but they also need to be fair across hosts. We pro- The k mutual exclusion problem involves a group of pro- pose a new solution to the k-mutual exclusion problem that cesses, each of which intermittently requires access to an provides a notion of time-based fairness. Specifically, our identical resource called the critical section (CS). A k mu- algorithm attempts to minimize the spread of access time tual exclusion algorithm must satisfy both safety and live- for the critical resource. While a client’s access time is ness. Safety means that at most k processes, 1 ≤ k ≤ n, the time between it requesting and accessing the resource, may be in the CS at any given time. Liveness means that the spread is defined as a system-wide metric that measures every request for critical section access is satisfied in finite some notion of the variance of access times across a homo- time. geneous host population, e.g., difference between max and For the applications described above, fairness of the mean. We analytically prove the correctness of our algo- k mutual exclusion primitive is important, to ensure pre- rithm, and evaluate its fairness experimentally using simu- dictable staleness. In other words, the primitive should en- lations. Our evaluation under two settings - a LAN setting sure timeliness of data (statistics) collection across nodes. and a WAN based on the King latency data set - shows even Previously proposed algorithms for k mutual exclusion fo- with 100 hosts accessing one resource, the spread of access cus on optimizing the mean time to obtain access to the time is within 15 seconds. critical section, rarely accounting for metrics like fairness. Thus, new solutions are needed that take fairness into con- sideration. Our notion of the fairness metric is as follows: 1. Introduction amongst a group of homogeneous nodes having a constant critical section execution time, the access time spread for In peer to peer (p2p) systems, a distributed k mutual ex- the critical section should be small. clusion primitive provides a mechanism to share resources We do not consider fairness to be a binary property; the like bandwidth in a decentralized fashion. Consider a cen- smaller the access time spread for the critical section, the tral statistics collection server in a p2p system (for exam- more fair the mutual exclusion algorithm. There are other ple Planet-Lab [13]) that provides some distributed services. ways to measure fairness, e.g., [8] defines fairness as FIFO The limited bandwidth at the server is the bottleneck here, with respect to request timestamps. Our notion of fairness and in such a scenario, a k mutual exclusion primitive can is more practical, yet it provides FIFO ordering as a side be used to cap the number of simultaneous connections to affect. the server at k, while providing access to the server in a In this paper, we propose a practical fair algorithm for k decentralized manner. We note that while there is a lot mutual exclusion in p2p systems that minimizes the differ- of emerging work on distributed data collection and data ence between maximum and mean time to access the criti- aggregation [22, 23], the current infrastructure for statis- cal section. We prove that our algorithm satisfies both the tics collection is largely centralized [17]. Another example safety and liveness requirements. We show that our algo- where k mutual exclusion in p2p systems would be useful rithm provides an order of magnitude better fairness char- ∗This work was supported in part by NSF CAREER grant CNS- acteristics as compared to the best-known k mutual exclu- 0448246 and in part by NSF ITR CMS-0427089. sion algorithm [2], while the asymptotic bounds on both the mean time to access the critical section, as well as the num- Message delivery to the destination is time-bounded. There ber of messages per critical section entry, remain the same. are k tokens numbered 1 through k in the system and a node We also propose a fault tolerant methodology for our algo- can be in the critical section only if it is holding a token. A rithm and show that it is resilient against churn. node holds a token for only a finite time. A node does not initiate a new critical section until it has exited all previ- 2. Related Work ous ones. We initially assume no joins or failures; we later handle failures by relying on a distributed hash table (DHT) Classical mutual exclusion algorithms can be classified called Chord. into two groups: permission (quorum)-based and token- The k-mutual exclusion problem involves a group of based. Permission-based algorithms [6,9,16] require one or nodes, each of which intermittently requires access to an more successive rounds of message exchanges among the identical resource or piece of code called the critical section ≤ ≤ nodes to obtain the permission to execute the CS. In token- (CS). At most k nodes, 1 k n, may be in the CS at any based algorithms [4,11,15] a unique token is shared among given time. we next define safety, liveness and fairness: the nodes. A node is allowed to enter its critical section only Safety meansthatatmostk nodes will execute the criti- if it possesses the token. cal section at a time. As the algorithm is token based, only The generalization to k mutual exclusion was proposed nodes with a token can enter the critical section. In order to by Raymond [14], but the algorithm is permission based. provide safety, it is thus sufficient to show that there are at Srimani and Reddy [19] proposed a token based algorithm most k tokens in the system at any time. for the k mutual exclusion problem by extending the ideas Liveness means that every request for critical section ac- of Suzuki and Kasami [21]. Their algorithm involves flood- cess will be satisfied within a finite time. This definition ing of requests, which makes it poorly suitable to p2p sys- requires that neither deadlock nor starvation should occur. tems. Ricart and Agrawala [16] used a single token with a Deadlock means that, while there are less than k nodes exe- counter to keep track of how many processes are currently cuting critical section, no requesting node can ever enter the in the critical section. It is shown in [2] that under high critical section. Starvation occurs when one node must wait load, this system behaves like a single token system. Also, indefinitely to enter the critical section even though other it requires all nodes to communicate in certain stages of the nodes are entering and leaving the critical section. algorithm, making it message inefficient for p2p environ- Fairness means that amongst a group of homogeneous ments. Also, both [19] and [16] are not fault tolerant and nodes having a constant critical section execution time, the do not consider fairness. access time spread to access the critical section should be Bulgannawar and Vaidya [2] presented a token based al- small. gorithm that uses k separate tokens in the system. Their al- gorithm uses k instantiations of a dynamic forest tree struc- 3.2. Algorithm Description ture proposed in [11]. The algorithm uses heuristics for choosing a tree among k, to send the request. This decision Our approach to provide a fair k mutual exclusion can makes the algorithm unfair, since there is no load balanc- be understood intuitively in a real world scenario. Imagine ing of requests. Moreover, the paper does not consider fault a cinema hall with k ticket counters. A person entering the tolerance. cinema hall picks one of the k counters randomly with out In recent years, p2p overlays like Chord [20] have been the prior knowledge of length of queues at each counter. We proposed. It provides flexible route selection and static re- can see that, this randomized strategy as in [2] gives a good silience. Lin et al [6] and Moosa et al [10] proposed quorum average time to get the ticket. However, in the worst case if based protocols for achieving mutual exclusion in dynamic every person enters the same queue i.e., if there is no load p2p systems. The Sigma protocol [6] uses logical replicas balancing among the ticket counters, the maximum time to and quorum consensus to deal with the system dynamism get the ticket will be very high. whereas [10] proposed protocols which combine both token A solution for this real world problem could be to place and quorum based approaches. a moderator (coordinator) at the cinema hall entry who has the information of all the ticket counters. The coordinator 3. A Fair K Mutual Exclusion Algorithm could then guide people who enter the cinema hall to ticket counters in a round robin fashion, i.e., coordinator does the 3.1. System Model and Problem Definition job of load balancing the ticket requests among the k ticket counters.