Algorithms used by CDNs Stable Marriage Algorithm Consistent Hashing.

Slides:



Advertisements
Similar presentations
The Mathematics Of 1950s Dating: Who wins the battle of the sexes? Great Theoretical Ideas In Computer Science Steven Rudich CS Spring 2003 Lecture.
Advertisements

Piyush Kumar (Lecture 3: Stable Marriage) Welcome to COT5405.
Marriage, Honesty, & Stability N ICOLE I MMORLICA, N ORTHWESTERN U NIVERSITY.
Tutorial 5 of CSCI2110 Eulerian Path & Hamiltonian Cycle Tutor: Zhou Hong ( 周宏 )
Matching Theory.
Lecture 2: Greedy Algorithms II Shang-Hua Teng Optimization Problems A problem that may have many feasible solutions. Each solution has a value In maximization.
Matching problems Toby Walsh NICTA and UNSW. Motivation Agents may express preferences for issues other than a collective decision  Preferences for a.
Selecting the the k-th smallest element in a set.
Social Networks 101 P ROF. J ASON H ARTLINE AND P ROF. N ICOLE I MMORLICA.
Key Algorithms in a Content Delivery System Akamai Technologies and Carnegie Mellon University Bruce Maggs.
1 Discrete Structures & Algorithms Graphs and Trees: IV EECE 320.
Great Theoretical Ideas in Computer Science.
Stable Marriage Problem William Kozma Jr ECE 443/543.
Tirgul 10 Rehearsal about Universal Hashing Solving two problems from theoretical exercises: –T2 q. 1 –T3 q. 2.
CSE 421 Algorithms Richard Anderson Lecture 2. Announcements Office Hours –Richard Anderson, CSE 582 Monday, 10:00 – 11:00 Friday, 11:00 – 12:00 –Yiannis.
1 Bipartite Matching Polytope, Stable Matching Polytope x1 x2 x3 Lecture 10: Feb 15.
Competitive Auctions and Digital Goods Andrew Goldberg, Jason Hartline, and Andrew Wright presenting: Keren Horowitz, Ziv Yirmeyahu.
Courtesy RK Brayton (UCB) and A Kuehlmann (Cadence) 1 Logic Synthesis Two-Level Minimization I.
Chapter 10: Iterative Improvement Simplex Method The Design and Analysis of Algorithms.
Content Overlays (Nick Feamster) February 25, 2008.
The Stable Marriage Problem
Welcome to CSE Applied Algorithms Anna R. Karlin Office Hours: Wed 9: :00 pm and by appointment TA: Ashish Sabharwal
Network Aware Resource Allocation in Distributed Clouds.
How Akamai Handles Large Events Bruce Maggs Carnegie Mellon Duke Akamai Technologies.
The Mathematics Of Dating and Marriage: Who wins the battle of the sexes? The Mathematics Of Dating and Marriage: Who wins the battle of the sexes? (adapted.
The Mathematics Of 1950’s Dating: Who wins the battle of the sexes? Adapted from a presentation by Stephen Rudich.
결혼문제로 본 조합론.
The Mathematics Of 1950’s Dating: Who wins the battle of the sexes? Presentation by Shuchi Chawla with some modifications.
Section 2.1 “Matching in bipartite graphs” in Graph Theory Handout for reading seminar.
Advanced Algorithms Piyush Kumar (Lecture 1: Introduction) Welcome to COT5405.
Stable Matchings a.k.a. the Stable Marriage Problem
Great Theoretical Ideas in Computer Science.
1 The Stable Marriage Problem Algorithms and Networks 2014/2015 Hans L. Bodlaender Johan M. M. van Rooij.
Marriage and Mathematics Lau Ting Sum Samson Suen Wai.
Lecture 23: Stable Marriage ( Based on Lectures of Steven Rudich of CMU and Amit Sahai of Princeton) Shang-Hua Teng.
Stable Matching Lecture 7: Oct 3. Matching A B C DE Boys Girls Today’s goal: to “match” the boys and the girls in a “good” way.
Stable Marriages (Lecture modified from Carnegie Mellon University course Great Theoretical Ideas in Computer Science)
© 2001 by Charles E. Leiserson Introduction to AlgorithmsDay 12 L8.1 Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 8 Prof. Charles E. Leiserson.
Design & Co-design of Embedded Systems Final Project: “The Match Maker” Second Phase Oral Presentation Safa S. Mahmoodian.
Bipartite Matching. Unweighted Bipartite Matching.
CSE 421 Algorithms Richard Anderson (for Anna Karlin) Winter 2006 Lecture 2.
The Stable Marriage Problem
Great Theoretical Ideas in Computer Science for Some.
Matching Lecture 19: Nov 23.
Network Flows Chun-Ta, Yu Graduate Institute Information Management Dept. National Taiwan University.
Fair Shares.
The Mathematics Of 1950’s Dating: Who wins the battle of the sexes? CS Lecture 2.
Graph Algorithms Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]
Market Design and Analysis Lecture 2 Lecturer: Ning Chen ( 陈宁 )
18.1 CompSci 102 Today’s topics 1950s TV Dating1950s TV Dating.
18.1 CompSci 102 Today’s topics Impaired wanderingImpaired wandering Instant InsanityInstant Insanity 1950s TV Dating1950s TV Dating Final Exam reviewFinal.
Stable marriages Competitive programming and problem solving Yoram Meijaard.
Dating Advice from Mathematics
Consistent Hashing. Hashing E.g., h(x) = (((a x + b) mod P) mod |B|), where P is prime, P > |U| a,b chosen uniformly at random from Z P x is a serial.
מתמטיקה בדידה Discrete Math Lecture 12 1 TexPoint fonts used in EMF.
Matching Boys Girls A B C D E
Cybernetica AS & Tartu University
The Stable Marriage Problem
The Mathematics Of 1950’s Dating: Who wins the battle of the sexes?
Algorithmic Nuggets in Content Delivery
CSE 421: Introduction to Algorithms
The Mathematics Of 1950’s Dating: Who wins The Battle of The Sexes?
Edge computing (1) Content Distribution Networks
The Mathematics Of 1950’s Dating: Who wins the battle of the sexes?
S. Raskhodnikova; based on slides by K. Wayne
Computational Processes II
Richard Anderson Autumn 2006 Lecture 1
Who does better, boys or girls?
Computational Processes II
Piyush Kumar (Lecture 3: Stable Marriage)
Presentation transcript:

Algorithms used by CDNs Stable Marriage Algorithm Consistent Hashing

Question: How do we pair them off? Dating Scenario There are n boys and n girls Each girl has her own ranked preference list of all the boys Each boy has his own ranked preference list of the girls The lists have no ties

3,5,2,1,4 1 5,2,1,4,3 2 4,3,5,1,2 3 1,2,3,4,5 4 2,3,4,1, ,2,5,1,4 2 1,2,5,3,4 3 4,3,2,1,5 4 1,3,4,2,5 5 1,2,4,5,3

Rogue Couples Suppose we pair off all the boys and girls Now suppose that some boy and some girl prefer each other to the people to whom they are paired They will be called a rogue couple

A pairing of boys and girls is called stable if it contains no rogue couples Stable Pairings

A pairing of boys and girls is called stable if it contains no rogue couples Stable Pairings 3,2,1 1 2,1,3 2 3,1, ,2,1 2 1,2,3 3 3,2,1

Given a set of preference lists, how do we find a stable pairing? Wait! We don’t even know that such a pairing always exists!

Does every set of preference lists have a stable pairing? Better Question:

The Traditional Marriage Algorithm Worshipping Males Female Dating

The Traditional Marriage Algorithm Morning Each girl stands on her balcony Each boy proposes to the best girl on his list who has not rejected him yet Afternoon (for girls with at least one suitor) To today’s best: “Let’s just date for now, come back tomorrow” To any others: “No, I will never marry you, don’t come back” If no boys get a “No”, each girl marries boy she is dating

3,5,2,1,4 1 5,2,1,4,3 4,3,5,1,2 3 1,2,3,4,5 4 2,3,4,1, ,2,5,1,4 2 1,2,5,3,4 3 4,3,2,1,5 4 1,3,4,2,5 5 1,2,4,5,3 2

Improvement Lemma: If a girl is dating someone, then she will always be dating someone at least as good until she is married She would only let go of him in order to date someone better She would only let go of that guy for someone even better AND SO ON…

Contradiction Lemma: No boy can be rejected by all the girls Proof (by contradiction): Suppose boy b is rejected by all the girls At that point: Each girl must have a suitor other than b (By Improvement Lemma, once a girl has a suitor she will always have at least one) The n girls have n suitors, and b is not among them. Thus, there are at least n+1 boys

Theorem: The TMA always terminates in at most n 2 days A “master list” of all n of the boys lists starts with a total of n x n = n 2 girls on it Each day (until the last) at least one boy gets a “No”, so at least one girl gets crossed off the master list Therefore, the number of days is bounded by the original size of the master list

g b g*g* I rejected you when you came to my balcony. Now I’ve got someone better Theorem: The pairing T produced by TMA is stable

Who is better off in traditional dating, the boys or the girls? Opinion Poll

Presumably, she might be better than the girl he gets in the stable pairing output by TMA The Optimal Girl A boy’s optimal girl is the highest ranked girl for whom there is some stable pairing in which the boy gets her

A boy’s pessimal girl is the lowest ranked girl for whom there is some stable pairing in which the boy gets her The Pessimal Girl

Dating Heaven and Hell A pairing is male-optimal if every boy gets his optimal mate. This is the best of all possible stable worlds for every boy simultaneously A pairing is male-pessimal if every boy gets his pessimal mate. This is the worst of all possible stable worlds for every boy simultaneously

Dating Heaven and Hell A pairing is female-optimal if every girl gets her optimal mate. This is the best of all possible stable worlds for every girl simultaneously A pairing is female-pessimal if every girl gets her pessimal mate. This is the worst of all possible stable worlds for every girl simultaneously

The Naked Mathematical Truth! The Traditional Marriage Algorithm always produces a male-optimal, female- pessimal pairing

Theorem: TMA produces a male- optimal pairing Suppose, for a contradiction, that some boy gets rejected by his optimal girl during TMA At time t, boy b got rejected by his optimal girl g because she said “maybe” to a preferred b* Therefore, b* likes g at least as much as his optimal Let t be the earliest time at which this happened By the definition of t, b* had not yet been rejected by his optimal girl

Since g is the optimal girl for b, there must exist a stable pairing S in which b and g are married, but … b* wants g more than his wife in S: g wants b* more than her husband in S: Contradiction g is at least as good as his best and he does not have her in stable pairing S b is her husband in S and she rejects him for b* in TMA

Theorem: The TMA pairing, T, is female-pessimal We know it is male-optimal. Suppose there is a stable pairing S where some girl g does worse than in T Let b be her mate in T Let b* be her mate in S By assumption, g likes b better than her mate in S b likes g better than his mate in S (we already know that g is his optimal girl) Therefore, S is not stable Contradiction

The largest, most successful dating service in the world uses a computer to run TMA!

Assigning Name Servers to Clusters Every resolving (name server, traffic type) pair is a “boy”; each boy comes with a predicted load Every Akamai cluster is a “girl” Preferences are based on measured packet loss and latency to the name server’s core point and the cost to serve traffic from the cluster There are many more boys than girls, but each girl can marry multiple boys! (Up to the capacity of the cluster) Marriage dictates which clusters should serve which clients 26

Why not find a maximum matching? The stable marriage algorithm is much faster in practice. But locally optimal as opposed to globally optimum. Warning: changing a single preference can cause ALL boys and girls to switch to new partners Before computing a new solution, boys increase preference for previous partner 27

Extension: Multiple Resources Each server has several resources (e.g., processor, disk access, network bandwidth) each with finite capacity. Each type of traffic (e.g., video, web, secure) puts different demands on each resource. Matching must not exceed the capacity of any of the individual resources. 28

Extension: Resource Trees Assumption: resource constraints can be modeled hierarchically Each class of traffic puts load on a path to a leaf (video class load shown in blue) Stable marriage algorithm can be extended to respect these constraints. 29 Aggregate cluster capacity (in black) traffic class limit (in black) Bps)

Hashing E.g., h(x) = (((a x + b) mod P) mod |B|), where P is prime, P > |U| a,b chosen uniformly at random from Z P x is a serial number Universe U of all possible objects, set B of buckets. object: set of web objects with same serial number bucket: web server Hash function h: U  B Assigns objects to buckets

f(d) = d + 1 mod 5 Difficulty changing number of buckets bucket object f(d) = d + 1 mod 4

Consistent Hashing Idea: Map both objects and buckets to unit circle. object bucket Assign object to next bucket on circle in clockwise order. new bucket

Complication – Different Views select servers within cluster Low-level DNS servers act independently and may have different ideas about how many and which servers are alive. a212.g.akamai.net Akamai Low-Level DNS Servers

Properties of Consistent Hashing Monotonicity: When a bucket is added/removed, the only objects affected are those that are/were mapped to the bucket. Balance: Objects are assigned to buckets “randomly”. -- can be improved by mapping each bucket to multiple places on unit circle Load: Objects are assigned to buckets evenly, even over a set of views. Spread: An object should be mapped to a small number of buckets over a set of views.

How we really do it a212: a213: a214: a215: random permutations of servers Why? To spread load for one serial number.