Distributed Client-Server Problem - CSE

Randomized Algorithms
CS648
Lecture 14
Expected duration of a randomized experiment
Part II
1
REVISITING
SOME DISCRETE MATHEMATICS
2
Recurrence 1
๐’“0 = 1
For any ๐’Š > ๐ŸŽ ,
1
2
๐’“๐’Š = ๐’“๐’Šโˆ’๐Ÿ
๐Ÿ
๐’
Question: What is the smallest value of ๐’Š such that ๐’“๐’Š โ‰ค for a given ๐’ > ๐Ÿ?
Answer: ??
log 2 ๐’
For any ๐’Š > ๐ŸŽ ,
๐’“0 = 1
๐’“๐’Š = ๐’„ ๐’“๐’Šโˆ’๐Ÿ
for some 0 < ๐’„ < ๐Ÿ
๐Ÿ
๐’
Question: What is the smallest value of ๐’Š such that ๐’“๐’Š โ‰ค for a given ๐’ > ๐Ÿ?
Answer: ??log1/๐‘ ๐’
3
Recurrence 2
๐’“0 =
For any ๐’Š > ๐ŸŽ ,
๐Ÿ
๐Ÿ
๐’“๐’Š = ๐’“๐’Šโˆ’๐Ÿ
2
๐Ÿ
๐’
Question: What is the smallest value of ๐’Š such that ๐’“๐’Š โ‰ค for a given ๐’ > ๐Ÿ?
Answer: ??log 2 log 2 ๐’
For any ๐’Š > ๐ŸŽ ,
๐’“0 = ๐’‚ for some 0 < ๐’‚ < ๐Ÿ
๐’“๐’Š = ๐’“๐’Šโˆ’๐Ÿ ๐’„ for some 1 < ๐’„
๐Ÿ
๐’
Question: What is the smallest value of ๐’Š such that ๐’“๐’Š โ‰ค for a given ๐’ > ๐Ÿ?
Answer: ??log ๐’„ log1/๐‘Ž ๐’
4
DISTRIBUTED CLIENT-SERVER PROBLEM
5
Distributed Client-Server Problem
โ€ข
โ€ข
โ€ข
โ€ข
โ€ข
There are ๐‘›-clients and ๐‘›-servers.
Each client knows address of each server.
Each client has a single job.
It is a distributed computational environment.
A server can execute only one job in one round.
Aim: A distributed protocol to finish all jobs as quickly as possible.
6
Distributed Client-Server Problem
Randomized protocol (one round)
โ€ข Each client sends a request to a server selected randomly uniformly and
independently.
โ€ข Each server which receives one or more requests, accepts only one
request and finishes the corresponding job.
โ€ข Each client, whose job is finished, leaves the system.
โ€ข The remaining clients repeat the same procedure in next round.
Question: what is the expected number of rounds to finish all jobs?
7
Distributed Client-Server problem
Randomized protocol
1
2
3
4
5
6
7
8
7
8
Clients
It can be framed as our familiar
ball-bin problem.
๏Š
Servers
1
2
3
4
5
6
8
Distributed Client-Server problem
Randomized protocol
1
2
1
2
3
4
5
6
7
8
6
7
8
Balls
Bins
3
4
5
9
Distributed Client-Server problem
Randomized protocol
Round 1
1
2
1
2
3
3
4
4
5
5
6
7
8
6
7
8
10
Distributed Client-Server problem
Randomized protocol
3
1
2
3
4
4
5
6
7
8
7
8
11
Distributed Client-Server problem
Randomized protocol
Round 2
3
1
2
3
4
4
5
6
7
8
7
8
12
Distributed Client-Server problem
Randomized protocol
Round 3
8
1
2
3
4
5
6
7
8
13
CALCULATING EXPECTED NO. OF ROUNDS
FIRST APPROACH
14
Distributed Client-Server problem
Randomized protocol
Round 1
1
2
3
1
2
3
๐’โˆ’๐Ÿ
โ€ฆ
๐’-1
๐’
๐’
๐’€ : no. of balls leaving the system at the end of round ๐Ÿ.
E[๐’€] = ??
๐Ÿ
if ๐‘๐‘Ž๐‘™๐‘™ ๐‘– leaves the systems in round ๐Ÿ
๐’€๐’‹ =
๐ŸŽ
otherwise
๐’€=
๐’‹ ๐’€๐’‹
๏ƒจ ๐„[๐’€] =
=
๐’‹ ๐„[๐’€๐’‹ ]
๐’‹ ๐(๐’€๐’‹
= ๐Ÿ)
Not so easy to find
15
Round 1
Distributed Client-Server problem
Randomized protocol
1
2
3
1
2
3
๐’โˆ’๐Ÿ
๐’-1
โ€ฆ
๐’
๐’
๐’€ : no. of balls leaving the system in round ๐Ÿ.
E[๐’€] = ??๐’ โˆ’ ๐ž๐ฑ๐ฉ๐ž๐œ๐ญ๐ž๐ ๐ง๐จ. ๐จ๐Ÿ ๐ž๐ฆ๐ฉ๐ญ๐ฒ ๐›๐ข๐ง๐ฌ
๐Ÿ ๐’
=๐’โˆ’๐’ ๐Ÿโˆ’
๐’ between
Is there any relation
of ๐Ÿempty
= no.
๐Ÿโˆ’
๐’ bins and
๐’† the system in round 1
no. of balls leaving
๐‘ฟ๐Ÿ : no. of balls remaining in the system after round ๐Ÿ.
E[๐‘ฟ๐Ÿ ] =
?
๐’
๐’†
16
Distributed Client-Server problem
Round ๐’Š + ๐Ÿ
Randomized protocol
1
1
2
๐’Ž
2
๐’Ž
๐’-1
โ€ฆ
E[๐‘ฟ๐Ÿ ] =
๐’
๐’
๐’†
๐‘ฟ๐’Š : no. of balls at the end of round ๐’Š.
๐’Ž
E[๐‘ฟ๐’Š+๐Ÿ | ๐‘ฟ๐’Š = ๐’Ž] =โ‰ค??
๐’†
17
Distributed Client-Server problem
Randomized protocol
๐Ÿ
Lemma1 : After round ๐’Š + ๐Ÿ, the expected number of balls left is less than th
๐’†
fraction of the balls after round ๐’Š.
๐’“๐’Š =
๐‘ฟ๐’Š
:
๐’
fraction of balls in the system after round ๐’Š.
๐Ÿ
Lemma 1 implies E[๐’“๐’Š+๐Ÿ ] โ‰ค ? ?๐’“๐’Š
๐’†
๏ƒจ If everything goes as expected, then
Round
No. of balls in the system
Fraction of balls in the system
0
๐’
1
1
๐’/๐’†
๐Ÿ/๐’†
2
< ๐’/๐’†๐Ÿ
< ๐Ÿ/๐’†๐Ÿ
This table gives the intuition for the expected no. of rounds but it directly does
not help us to calculate the expected no. of rounds ? It also does not directly
help to get a high prob. Bound. Convince yourself before proceeding further.
18
Distributed Client-Server problem
Randomized protocol
๐Ÿ
Lemma: After round ๐’Š + ๐Ÿ, the expected no. of balls is less than th fraction
๐’†
of the balls after round ๐’Š.
๐Ÿ
๐Ÿ
Definition: round ๐’Š + ๐Ÿ is good if ๐’“๐’Š+๐Ÿ < ๐’“๐’Š , and bad otherwise.
๐Ÿ
โ‰ค
P(a round is bad) = ??๐’†
๏ƒจ P(a round is good) >
๐Ÿ‘
โ‰ค
๐Ÿ’
Use Markovโ€™s
Inequality
๐Ÿ
๐Ÿ’
Question: After how many good rounds will there be no ball left ?
Expected no. of rounds =โ‰ค??๐Ÿ’ ๐ฅ๐จ๐  ๐Ÿ ๐’
๐ฅ๐จ๐  ๐Ÿ ๐’
Use
Recurrence 1
Each round is good independent
of other rounds.
19
Distributed Client-Server problem
Randomized protocol
Theorem: The Randomized protocol will terminate in expected O(๐ฅ๐จ๐  ๐Ÿ ๐’)
rounds.
This bound is very loose.
Can you see why ?
20
An important insight that we missed
Question: What is the cause of multiple rounds for a ball ?
Answer: presence of other competing balls
INSIGHT
As the algorithm proceeds:
โ€ข The number of these competing balls reduce
โ€ข but the number of bins remain unchanged
๏ƒจ
Chances of a ball to leave the system increases as the algorithm proceeds.
21
CALCULATING EXPECTED NO. OF ROUNDS
WITH NEW INSIGHT
22
Distributed Client-Server problem
Randomized protocol
Partitioning experiment into stages
Stage 1: The number of balls >
Stage 2: The number of balls โ‰ค
Stage 1
๐’
๐Ÿ
๐’
๐Ÿ
๐’
๐ง๐จ. ๐จ๐Ÿ ๐›๐š๐ฅ๐ฅ๐ฌ โ‰ค
๐Ÿ
Stage 2
Expected no. of rounds in Stage 1 : 4.
Expected no. of rounds in Stage 2 : ??
23
CALCULATING EXPECTED NO. OF ROUNDS
IN STAGE 2
24
Distributed Client-Server problem
Randomized protocol
Round ๐’Š + ๐Ÿ
1
2
1
๐’Ž
2
3
โ€ฆ
๐’-1
๐’
๐‘ฟ๐’Š : no. of balls at the end of round ๐’Š.
๐’Ž
๐Ÿ
๐’ ๐Ÿ๐จ๐Ÿโˆ’๐ง๐จ๐ง๐ž๐ฆ๐ฉ๐ญ๐ฒ
๐Ÿโˆ’
๐›๐ข๐ง๐ฌ
E[๐‘ฟ๐’Š+๐Ÿ | ๐‘ฟ๐’Š = ๐’Ž] = ??๐’Ž โˆ’ ๐ง๐จ.
๐’
โ‰ค๐’Žโˆ’๐’ ๐Ÿโˆ’ ๐Ÿโˆ’
๐’Ž
๐’Ž ๐Ÿ
+
๐’
๐Ÿ ๐’๐Ÿ
๐’Ž
๐’Ž ๐Ÿ
=๐’Žโˆ’๐’
โˆ’
๐Ÿ
๐’
๐Ÿ
๐’
๐’Ž
We need๐Ÿa reasonably
bound
๐’Ž good upper
๐Ÿ
๐’Ž ๐Ÿ for this
๐Ÿโˆ’๐’
=๐Ÿโˆ’ ๐’ + ๐’Ž
โ‰ค
โˆ’
+ โ€ฆ
๐’Ž
๐Ÿ ๐’๐Ÿ
๐Ÿ‘ ๐Ÿ ๐’๐Ÿ‘
expression
=
๐Ÿ ๐’
25
Distributed Client-Server problem
Randomized protocol
Round ๐’Š + ๐Ÿ
1
1
2
๐’Ž
2
3
๐’-1
โ€ฆ
๐‘ฟ๐’Š : no. of balls at the end of round ๐’Š.
๐’Ž ๐Ÿ
E[๐‘ฟ๐’Š+๐Ÿ | ๐‘ฟ๐’Š = ๐’Ž] = โ‰ค
??
๐Ÿ ๐’
E
๐’“๐’Š =
๐‘ฟ๐’Š
:
๐’
๐‘ฟ๐’Š+๐Ÿ
|
๐’
๐Ÿ ๐’Ž
๐‘ฟ๐’Š = ๐’Ž =โ‰ค??
๐Ÿ ๐’
๐’
๐’Ž๐Ÿ
โ‰ค
๐Ÿ๐’
๐Ÿ
fraction of balls at the end of round ๐’Š.
๐Ÿ
๐Ÿ
E[๐’“๐’Š+๐Ÿ ] =โ‰ค?? ๐’“๐’Š
๐Ÿ
26
Distributed Client-Server problem
Randomized protocol
Lemma: If ๐’“๐’Š is the fraction of balls at end of round ๐’Š in stage 2, the expected
๐Ÿ
fraction of balls at the end of round ๐’Š + ๐Ÿ will be at most ๐’“๐’Š ๐Ÿ .
๐Ÿ
๐Ÿ
๐’“๐ŸŽ โ‰ค
๐Ÿ
Definition: round ๐’Š + ๐Ÿ is good if ๐’“๐’Š+๐Ÿ โ‰ค ๐’“๐’Š ๐Ÿ , and bad otherwise.
๏ƒจ
๐Ÿ
P(a round is bad) =<
??
๐Ÿ
๐Ÿ
P(a round is good) โ‰ฅ
๐Ÿ
Use Markovโ€™s
Inequality
Question: After how many good rounds will there be no ball left ? โ‰ค ๐ฅ๐จ๐  ๐Ÿ ๐ฅ๐จ๐  ๐Ÿ ๐’
Expected no. of rounds = โ‰ค
??๐Ÿ ๐ฅ๐จ๐  ๐Ÿ ๐ฅ๐จ๐  ๐Ÿ ๐’
Use
Recurrence 2
27
Distributed Client-Server problem
Randomized protocol
Theorem: The expected number of rounds taken by the Randomized protocol
is at most ๐Ÿ’ + ๐Ÿ ๐ฅ๐จ๐  ๐Ÿ ๐ฅ๐จ๐  ๐Ÿ ๐’.
28
Distributed Client-Server problem
Randomized protocol
Points to Ponder :
โ€ข
Why did we analyze the random variable ๐’“๐’Š and not ๐‘ฟ๐’Š ?
โ€ข
Why did we introduce the two stages ?
โ€ข
Do you find any similarity in the analysis with that of of Quick sort concentration?
โ€ข
Can you also achieve lower bound of ๐›€(๐ฅ๐จ๐  ๐Ÿ ๐ฅ๐จ๐  ๐Ÿ ๐’) on the expected number of
rounds ? (this question is only for those whose aim is more than just grade A )
โ€ข
Can you achieve high probability bound on the number of rounds ?
29
RUMOR SPREADING
30
Rumor Spreading
There are ๐’ persons in a city.
On day ๐ŸŽ, a person comes to know a rumor.
The following protocol is repeated from day ๐Ÿ :
โ€ข Each person knowing the rumor does the following
- Picks phone number of a randomly selected person
- Calls him/her and communicate the rumor.
Question:
What is the expected number of days until everyone knows the rumor?
31
Rumor Spreading
Question:
What is the minimum number of days until everyone knows the rumor?
Answer: ๐ฅ๐จ๐  ๐Ÿ ๐’
Number of people knowing
the rumor can only double
in a day.
32
Rumor Spreading
Theorem (it should surprise you):
1. The entire city comes to know the rumor in O(๐ฅ๐จ๐  ๐Ÿ ๐’) expected days.
2. The entire city comes to know the rumor in O(๐ฅ๐จ๐  ๐Ÿ ๐’) days with high
probability.
33
Rumor Spreading
Intuition 1:
In the beginning, there are few persons who know the rumor. As a result
โ€ข The chances of selecting a person who does not know the rumor is more.
โ€ข The chances of collisions are also few.
๏ƒจ
As long as the no. of people knowing the rumor is less than c๐’, for some suitable c <
1, the no. of people knowing the rumor should increase by a factor ๐’ƒ > ๐Ÿ every day.
Intuition 2:
Once there are more than c๐’ persons knowing the rumor, the probability of a person
unaware of rumor to get a phone call about rumor should be high.
Can you use these two intuitions to partition the algorithm into stages ?
34
Rumor Spreading
Partition the experiment into stages
Select some c < 1 suitably.
Stage 1: the number of people knowing the rumor is less than c๐’
Stage 2: the number of people knowing the rumor is more than c๐’
Stage 1
Stage 2
๐ง๐จ. ๐จ๐Ÿ ๐ฉ๐ž๐จ๐ฉ๐ฅ๐ž ๐ค๐ง๐จ๐ฐ๐ข๐ง๐  ๐ซ๐ฎ๐ฆ๐จ๐ซ > c๐’
35
EXPECTED NO. OF DAYS IN
STAGE 2
36
Rumor Spreading
In the beginning of Stage 2: the no. of people knowing the rumor > c๐’ .
โ€ข Pick any person ๐‘ not knowing the rumor.
โ€ข Show that he/she will know the rumor in ๐Ž(๐ฅ๐จ๐  ๐Ÿ ๐’) days with high
probability.
โ€ข Use Union theorem to conclude that the number of days in Stage 2 is
๐Ž(๐ฅ๐จ๐  ๐Ÿ ๐’) with high probability.
37
EXPECTED NO. OF DAYS IN
STAGE 1
38
It is left as a home work to be
discussed in some future class.
I shall be happy to see a correct
solution by some of you in the next
class.
39