large scale graph processing - pregel and graphlab · large scale graph processing - pregel and...

104
Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah [email protected] 01/10/2018

Upload: others

Post on 18-Jun-2020

19 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Large Scale Graph Processing - Pregel and GraphLab

Amir H. [email protected]

01/10/2018

Page 2: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

The Course Web Page

https://id2221kth.github.io

1 / 61

Page 3: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Where Are We?

2 / 61

Page 4: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

I A flexible abstraction for describing relationships between discrete objects.

3 / 61

Page 5: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Large Graph

4 / 61

Page 6: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Algorithms Challenges

I Difficult to extract parallelism based on partitioning of the data.

I Difficult to express parallelism based on partitioning of computation.

I Graph partition is a challenging problem.

5 / 61

Page 7: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Algorithms Challenges

I Difficult to extract parallelism based on partitioning of the data.

I Difficult to express parallelism based on partitioning of computation.

I Graph partition is a challenging problem.

5 / 61

Page 8: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning

I Partition large scale graphs and distribut to hosts.

6 / 61

Page 9: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Edge-Cut Graph Partitioning

I Divide vertices of a graph into disjoint clusters.

I Nearly equal size (w.r.t. the number of vertices).

I With the minimum number of edges that span separated clusters.

7 / 61

Page 10: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Vertex-Cut Graph Partitioning

I Divide edges of a graph into disjoint clusters.

I Nearly equal size (w.r.t. the number of edges).

I With the minimum number of replicated vertices.

8 / 61

Page 11: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Edge-Cut vs. Vertex-Cut Graph Partitioning (1/2)

I Natural graphs: skewed Power-Law degree distribution.

I Edge-cut algorithms perform poorly on Power-Law Graphs.

9 / 61

Page 12: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Edge-Cut vs. Vertex-Cut Graph Partitioning (2/2)

10 / 61

Page 13: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank with MapReduce

11 / 61

Page 14: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank

R[i] =∑

j∈Nbrs(i)wjiR[j]

12 / 61

Page 15: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank Example (1/2)

I R[i] =∑

j∈Nbrs(i)wjiR[j]

I Input

V1: [0.25, V2, V3, V4]

V2: [0.25, V3, V4]

V3: [0.25, V1]

V4: [0.25, V1, V3]

I Share the rank among all outgoing links

V1: (V2, 0.25/3), (V3, 0.25/3), (V4, 0.25/3)

V2: (V3, 0.25/2), (V4, 0.25/2)

V3: (V1, 0.25/1)

V4: (V1, 0.25/2), (V3, 0.25/2)

13 / 61

Page 16: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank Example (1/2)

I R[i] =∑

j∈Nbrs(i)wjiR[j]

I Input

V1: [0.25, V2, V3, V4]

V2: [0.25, V3, V4]

V3: [0.25, V1]

V4: [0.25, V1, V3]

I Share the rank among all outgoing links

V1: (V2, 0.25/3), (V3, 0.25/3), (V4, 0.25/3)

V2: (V3, 0.25/2), (V4, 0.25/2)

V3: (V1, 0.25/1)

V4: (V1, 0.25/2), (V3, 0.25/2)

13 / 61

Page 17: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank Example (1/2)

I R[i] =∑

j∈Nbrs(i)wjiR[j]

I Input

V1: [0.25, V2, V3, V4]

V2: [0.25, V3, V4]

V3: [0.25, V1]

V4: [0.25, V1, V3]

I Share the rank among all outgoing links

V1: (V2, 0.25/3), (V3, 0.25/3), (V4, 0.25/3)

V2: (V3, 0.25/2), (V4, 0.25/2)

V3: (V1, 0.25/1)

V4: (V1, 0.25/2), (V3, 0.25/2)

13 / 61

Page 18: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank Example (2/2)

I R[i] =∑

j∈Nbrs(i)wjiR[j]

V1: (V2, 0.25/3), (V3, 0.25/3), (V4, 0.25/3)

V2: (V3, 0.25/2), (V4, 0.25/2)

V3: (V1, 0.25/1)

V4: (V1, 0.25/2), (V3, 0.25/2)

I Output after one iteration

V1: [0.37, V2, V3, V4]

V2: [0.08, V3, V4]

V3: [0.33, V1]

V4: [0.20, V1, V3]

14 / 61

Page 19: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank Example (2/2)

I R[i] =∑

j∈Nbrs(i)wjiR[j]

V1: (V2, 0.25/3), (V3, 0.25/3), (V4, 0.25/3)

V2: (V3, 0.25/2), (V4, 0.25/2)

V3: (V1, 0.25/1)

V4: (V1, 0.25/2), (V3, 0.25/2)

I Output after one iteration

V1: [0.37, V2, V3, V4]

V2: [0.08, V3, V4]

V3: [0.33, V1]

V4: [0.20, V1, V3]

14 / 61

Page 20: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Map (1/2)

I Map function

map(key: [url, pagerank], value: outlink_list)

for each outlink in outlink_list:

emit(key: outlink, value: pagerank / size(outlink_list))

emit(key: url, value: outlink_list)

I Input (key, value)

((V1, 0.25), [V2, V3, V4])

((V2, 0.25), [V3, V4])

((V3, 0.25), [V1])

((V4, 0.25), [V1, V3])

15 / 61

Page 21: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Map (1/2)

I Map function

map(key: [url, pagerank], value: outlink_list)

for each outlink in outlink_list:

emit(key: outlink, value: pagerank / size(outlink_list))

emit(key: url, value: outlink_list)

I Input (key, value)

((V1, 0.25), [V2, V3, V4])

((V2, 0.25), [V3, V4])

((V3, 0.25), [V1])

((V4, 0.25), [V1, V3])

15 / 61

Page 22: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Map (2/2)

I Map function

map(key: [url, pagerank], value: outlink_list)

for each outlink in outlink_list:

emit(key: outlink, value: pagerank / size(outlink_list))

emit(key: url, value: outlink_list)

I Intermediate (key, value)

(V2, 0.25/3), (V3, 0.25/3), (V4, 0.25/3), (V3, 0.25/2), (V4, 0.25/2), (V1, 0.25/1),

(V1, 0.25/2), (V3, 0.25/2)

(V1, [V2, V3, V4])

(V2, [V3, V4])

(V3, [V1])

(V4, [V1, V3])

16 / 61

Page 23: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Map (2/2)

I Map function

map(key: [url, pagerank], value: outlink_list)

for each outlink in outlink_list:

emit(key: outlink, value: pagerank / size(outlink_list))

emit(key: url, value: outlink_list)

I Intermediate (key, value)

(V2, 0.25/3), (V3, 0.25/3), (V4, 0.25/3), (V3, 0.25/2), (V4, 0.25/2), (V1, 0.25/1),

(V1, 0.25/2), (V3, 0.25/2)

(V1, [V2, V3, V4])

(V2, [V3, V4])

(V3, [V1])

(V4, [V1, V3])

16 / 61

Page 24: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Shuffle

I Intermediate (key, value)

(V2, 0.25/3), (V3, 0.25/3), (V4, 0.25/3), (V3, 0.25/2), (V4, 0.25/2), (V1, 0.25/1),

(V1, 0.25/2), (V3, 0.25/2)

(V1, [V2, V3, V4])

(V2, [V3, V4])

(V3, [V1])

(V4, [V1, V3])

I After shuffling

(V1, 0.25/1), (V1, 0.25/2), (V1, [V2, V3, V4])

(V2, 0.25/3), (V2, [V3, V4])

(V3, 0.25/3), (V3, 0.25/2), (V3, 0.25/2), (V3, [V1])

(V4, 0.25/3), (V4, 0.25/2), (V4, [V1, V3])

17 / 61

Page 25: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Shuffle

I Intermediate (key, value)

(V2, 0.25/3), (V3, 0.25/3), (V4, 0.25/3), (V3, 0.25/2), (V4, 0.25/2), (V1, 0.25/1),

(V1, 0.25/2), (V3, 0.25/2)

(V1, [V2, V3, V4])

(V2, [V3, V4])

(V3, [V1])

(V4, [V1, V3])

I After shuffling

(V1, 0.25/1), (V1, 0.25/2), (V1, [V2, V3, V4])

(V2, 0.25/3), (V2, [V3, V4])

(V3, 0.25/3), (V3, 0.25/2), (V3, 0.25/2), (V3, [V1])

(V4, 0.25/3), (V4, 0.25/2), (V4, [V1, V3])

17 / 61

Page 26: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Reduce (1/2)

I Reduce function

reducer(key: url, value: list_pr_or_urls)

outlink_list = []

pagerank = 0

for each pr_or_urls in list_pr_or_urls:

if is_list(pr_or_urls):

outlink_list = pr_or_urls

else

pagerank += pr_or_urls

emit(key: [url, pagerank], value: outlink_list)

I Input of the Reduce function

(V1, 0.25/1), (V1, 0.25/2), (V1, [V2, V3, V4])

(V2, 0.25/3), (V2, [V3, V4])

(V3, 0.25/3), (V3, 0.25/2), (V3, 0.25/2), (V3, [V1])

(V4, 0.25/3), (V4, 0.25/2), (V4, [V1, V3])

18 / 61

Page 27: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Reduce (1/2)

I Reduce function

reducer(key: url, value: list_pr_or_urls)

outlink_list = []

pagerank = 0

for each pr_or_urls in list_pr_or_urls:

if is_list(pr_or_urls):

outlink_list = pr_or_urls

else

pagerank += pr_or_urls

emit(key: [url, pagerank], value: outlink_list)

I Input of the Reduce function

(V1, 0.25/1), (V1, 0.25/2), (V1, [V2, V3, V4])

(V2, 0.25/3), (V2, [V3, V4])

(V3, 0.25/3), (V3, 0.25/2), (V3, 0.25/2), (V3, [V1])

(V4, 0.25/3), (V4, 0.25/2), (V4, [V1, V3])

18 / 61

Page 28: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Reduce (2/2)

I Reduce function

reducer(key: url, value: list_pr_or_urls)

outlink_list = []

pagerank = 0

for each pr_or_urls in list_pr_or_urls:

if is_list(pr_or_urls):

outlink_list = pr_or_urls

else

pagerank += pr_or_urls

emit(key: [url, pagerank], value: outlink_list)

I Output

((V1, 0.37), [V2, V3, V4])

((V2, 0.08), [V3, V4])

((V3, 0.33), [V1])

((V4, 0.20), [V1, V3])

19 / 61

Page 29: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PageRank in MapReduce - Reduce (2/2)

I Reduce function

reducer(key: url, value: list_pr_or_urls)

outlink_list = []

pagerank = 0

for each pr_or_urls in list_pr_or_urls:

if is_list(pr_or_urls):

outlink_list = pr_or_urls

else

pagerank += pr_or_urls

emit(key: [url, pagerank], value: outlink_list)

I Output

((V1, 0.37), [V2, V3, V4])

((V2, 0.08), [V3, V4])

((V3, 0.33), [V1])

((V4, 0.20), [V1, V3])

19 / 61

Page 30: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Problems with MapReduce for Graph Analytics

I MapReduce does not directly support iterative algorithms.• Invariant graph-topology-data re-loaded and re-processed at each iteration is wasting

I/O, network bandwidth, and CPU

I Materializations of intermediate results at every MapReduce iteration harm perfor-mance.

20 / 61

Page 31: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Problems with MapReduce for Graph Analytics

I MapReduce does not directly support iterative algorithms.• Invariant graph-topology-data re-loaded and re-processed at each iteration is wasting

I/O, network bandwidth, and CPU

I Materializations of intermediate results at every MapReduce iteration harm perfor-mance.

20 / 61

Page 32: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Think Like a Vertex

21 / 61

Page 33: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Think Like a Vertex

I Each vertex computes individually its value (in parallel).

I Computation typically depends on the neighbors.

I Also know as graph-parallel processing model.

22 / 61

Page 34: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Think Like a Vertex

I Each vertex computes individually its value (in parallel).

I Computation typically depends on the neighbors.

I Also know as graph-parallel processing model.

22 / 61

Page 35: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Data-Parallel vs. Graph-Parallel Computation

23 / 61

Page 36: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Pregel

24 / 61

Page 37: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Pregel

I Large-scale graph-parallel processing platform developed at Google.

I Inspired by bulk synchronous parallel (BSP) model.

25 / 61

Page 38: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (1/2)

I Applications run in sequence of iterations, called supersteps.

I A vertex in superstep S can:• reads messages sent to it in superstep S-1.• sends messages to other vertices: receiving at superstep S+1.• modifies its state.

I Vertices communicate directly with one another by sending messages.

26 / 61

Page 39: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (1/2)

I Applications run in sequence of iterations, called supersteps.

I A vertex in superstep S can:• reads messages sent to it in superstep S-1.• sends messages to other vertices: receiving at superstep S+1.• modifies its state.

I Vertices communicate directly with one another by sending messages.

26 / 61

Page 40: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (1/2)

I Applications run in sequence of iterations, called supersteps.

I A vertex in superstep S can:• reads messages sent to it in superstep S-1.• sends messages to other vertices: receiving at superstep S+1.• modifies its state.

I Vertices communicate directly with one another by sending messages.

26 / 61

Page 41: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (2/2)

I Superstep 0: all vertices are in the active state.

I A vertex deactivates itself by voting to halt: no further work to do.

I A halted vertex can be active if it receives a message.

I The whole algorithm terminates when:• All vertices are simultaneously inactive.• There are no messages in transit.

27 / 61

Page 42: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (2/2)

I Superstep 0: all vertices are in the active state.

I A vertex deactivates itself by voting to halt: no further work to do.

I A halted vertex can be active if it receives a message.

I The whole algorithm terminates when:• All vertices are simultaneously inactive.• There are no messages in transit.

27 / 61

Page 43: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (2/2)

I Superstep 0: all vertices are in the active state.

I A vertex deactivates itself by voting to halt: no further work to do.

I A halted vertex can be active if it receives a message.

I The whole algorithm terminates when:• All vertices are simultaneously inactive.• There are no messages in transit.

27 / 61

Page 44: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (2/2)

I Superstep 0: all vertices are in the active state.

I A vertex deactivates itself by voting to halt: no further work to do.

I A halted vertex can be active if it receives a message.

I The whole algorithm terminates when:• All vertices are simultaneously inactive.• There are no messages in transit.

27 / 61

Page 45: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Example: Max Value (1/4)

i_val := val

for each message m

if m > val then val := m

if i_val == val then

vote_to_halt

else

for each neighbor v

send_message(v, val)

28 / 61

Page 46: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Example: Max Value (2/4)

i_val := val

for each message m

if m > val then val := m

if i_val == val then

vote_to_halt

else

for each neighbor v

send_message(v, val)

29 / 61

Page 47: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Example: Max Value (3/4)

i_val := val

for each message m

if m > val then val := m

if i_val == val then

vote_to_halt

else

for each neighbor v

send_message(v, val)

30 / 61

Page 48: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Example: Max Value (4/4)

i_val := val

for each message m

if m > val then val := m

if i_val == val then

vote_to_halt

else

for each neighbor v

send_message(v, val)

31 / 61

Page 49: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Example: PageRank

R[i] =∑

j∈Nbrs(i)wjiR[j]

32 / 61

Page 50: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Example: PageRank

Pregel_PageRank(i, messages):

// receive all the messages

total = 0

foreach(msg in messages):

total = total + msg

// update the rank of this vertex

R[i] = total

// send new messages to neighbors

foreach(j in out_neighbors[i]):

sendmsg(R[i] * wij) to vertex j

R[i] =∑

j∈Nbrs(i)wjiR[j]

33 / 61

Page 51: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning

I Edge-cut partitioning

I The pregel library divides a graph into a number of partitions.

I Each partition consists of vertices and all of those vertices’ outgoing edges.

I Vertices are assigned to partitions based on their vertex-ID (e.g., hash(ID)).

34 / 61

Page 52: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning

I Edge-cut partitioning

I The pregel library divides a graph into a number of partitions.

I Each partition consists of vertices and all of those vertices’ outgoing edges.

I Vertices are assigned to partitions based on their vertex-ID (e.g., hash(ID)).

34 / 61

Page 53: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning

I Edge-cut partitioning

I The pregel library divides a graph into a number of partitions.

I Each partition consists of vertices and all of those vertices’ outgoing edges.

I Vertices are assigned to partitions based on their vertex-ID (e.g., hash(ID)).

34 / 61

Page 54: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning

I Edge-cut partitioning

I The pregel library divides a graph into a number of partitions.

I Each partition consists of vertices and all of those vertices’ outgoing edges.

I Vertices are assigned to partitions based on their vertex-ID (e.g., hash(ID)).

34 / 61

Page 55: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

System Model

I Master-worker model.

I The master• Coordinates workers.• Assigns one or more partitions to each worker.• Instructs each worker to perform a superstep.

I Each worker• Executes the local computation method on its vertices.• Maintains the state of its partitions.• Manages messages to and from other workers.

35 / 61

Page 56: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

System Model

I Master-worker model.

I The master• Coordinates workers.• Assigns one or more partitions to each worker.• Instructs each worker to perform a superstep.

I Each worker• Executes the local computation method on its vertices.• Maintains the state of its partitions.• Manages messages to and from other workers.

35 / 61

Page 57: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Fault Tolerance

I Fault tolerance is achieved through checkpointing.• Saved to persistent storage

I At start of each superstep, master tells workers to save their state:• Vertex values, edge values, incoming messages

I Master saves aggregator values (if any).

I When master detects one or more worker failures:• All workers revert to last checkpoint.

36 / 61

Page 58: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Fault Tolerance

I Fault tolerance is achieved through checkpointing.• Saved to persistent storage

I At start of each superstep, master tells workers to save their state:• Vertex values, edge values, incoming messages

I Master saves aggregator values (if any).

I When master detects one or more worker failures:• All workers revert to last checkpoint.

36 / 61

Page 59: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Fault Tolerance

I Fault tolerance is achieved through checkpointing.• Saved to persistent storage

I At start of each superstep, master tells workers to save their state:• Vertex values, edge values, incoming messages

I Master saves aggregator values (if any).

I When master detects one or more worker failures:• All workers revert to last checkpoint.

36 / 61

Page 60: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Fault Tolerance

I Fault tolerance is achieved through checkpointing.• Saved to persistent storage

I At start of each superstep, master tells workers to save their state:• Vertex values, edge values, incoming messages

I Master saves aggregator values (if any).

I When master detects one or more worker failures:• All workers revert to last checkpoint.

36 / 61

Page 61: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Pregel Limitations

I Inefficient if different regions of the graph converge at different speed.

I Runtime of each phase is determined by the slowest machine.

37 / 61

Page 62: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

GraphLab/Turi

38 / 61

Page 63: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

GraphLab

I GraphLab allows asynchronous iterative computation.

I Vertex scope of vertex v: the data stored in v, and in all adjacent vertices and edges.

I A vertex can read and modify any of the data in its scope (shared memory).

39 / 61

Page 64: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

GraphLab

I GraphLab allows asynchronous iterative computation.

I Vertex scope of vertex v: the data stored in v, and in all adjacent vertices and edges.

I A vertex can read and modify any of the data in its scope (shared memory).

39 / 61

Page 65: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

GraphLab

I GraphLab allows asynchronous iterative computation.

I Vertex scope of vertex v: the data stored in v, and in all adjacent vertices and edges.

I A vertex can read and modify any of the data in its scope (shared memory).

39 / 61

Page 66: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Example: PageRank (GraphLab)

GraphLab_PageRank(i)

// compute sum over neighbors

total = 0

foreach(j in in_neighbors(i)):

total = total + R[j] * wji

// update the PageRank

R[i] = total

// trigger neighbors to run again

foreach(j in out_neighbors(i)):

signal vertex-program on j

R[i] =∑

j∈Nbrs(i)wjiR[j]

40 / 61

Page 67: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency (1/5)

I Overlapped scopes: race-condition in simultaneous execution of two update func-tions.

41 / 61

Page 68: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency (1/5)

I Overlapped scopes: race-condition in simultaneous execution of two update func-tions.

41 / 61

Page 69: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency (2/5)

I Full consistency: during the execution f(v), no other function reads or modifies datawithin the v scope.

42 / 61

Page 70: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency (3/5)

I Edge consistency: during the execution f(v), no other function reads or modifiesany of the data on v or any of the edges adjacent to v.

43 / 61

Page 71: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency (4/5)

I Vertex consistency: during the execution f(v), no other function will be applied tov.

44 / 61

Page 72: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency (5/5)

Consistency vs. Parallelism

[Low, Y., GraphLab: A Distributed Abstraction for Large Scale Machine Learning (Doctoral dissertation, University of California), 2013.]

45 / 61

Page 73: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency Implementation

I Distributed locking: associating a readers-writer lock with each vertex.

I Vertex consistency• Central vertex (write-lock)

I Edge consistency• Central vertex (write-lock), Adjacent vertices (read-locks)

I Full consistency• Central vertex (write-locks), Adjacent vertices (write-locks)

I Deadlocks are avoided by acquiring locks sequentially following a canonical order.

46 / 61

Page 74: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency Implementation

I Distributed locking: associating a readers-writer lock with each vertex.

I Vertex consistency• Central vertex (write-lock)

I Edge consistency• Central vertex (write-lock), Adjacent vertices (read-locks)

I Full consistency• Central vertex (write-locks), Adjacent vertices (write-locks)

I Deadlocks are avoided by acquiring locks sequentially following a canonical order.

46 / 61

Page 75: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency Implementation

I Distributed locking: associating a readers-writer lock with each vertex.

I Vertex consistency• Central vertex (write-lock)

I Edge consistency• Central vertex (write-lock), Adjacent vertices (read-locks)

I Full consistency• Central vertex (write-locks), Adjacent vertices (write-locks)

I Deadlocks are avoided by acquiring locks sequentially following a canonical order.

46 / 61

Page 76: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency Implementation

I Distributed locking: associating a readers-writer lock with each vertex.

I Vertex consistency• Central vertex (write-lock)

I Edge consistency• Central vertex (write-lock), Adjacent vertices (read-locks)

I Full consistency• Central vertex (write-locks), Adjacent vertices (write-locks)

I Deadlocks are avoided by acquiring locks sequentially following a canonical order.

46 / 61

Page 77: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Consistency Implementation

I Distributed locking: associating a readers-writer lock with each vertex.

I Vertex consistency• Central vertex (write-lock)

I Edge consistency• Central vertex (write-lock), Adjacent vertices (read-locks)

I Full consistency• Central vertex (write-locks), Adjacent vertices (write-locks)

I Deadlocks are avoided by acquiring locks sequentially following a canonical order.

46 / 61

Page 78: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning

I Edge-cut partitioning.

I Two-phase partitioning:

1. Convert a large graph into a small meta-graph2. Partition the meta-graph

47 / 61

Page 79: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Fault Tolerance - Synchronous

I The systems periodically signals all computation activity to halt.

I Then synchronizes all caches, and saves to disk all data which has been modifiedsince the last snapshot.

I Simple, but eliminates the systems advantage of asynchronous computation.

48 / 61

Page 80: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Fault Tolerance - Synchronous

I The systems periodically signals all computation activity to halt.

I Then synchronizes all caches, and saves to disk all data which has been modifiedsince the last snapshot.

I Simple, but eliminates the systems advantage of asynchronous computation.

48 / 61

Page 81: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Fault Tolerance - Synchronous

I The systems periodically signals all computation activity to halt.

I Then synchronizes all caches, and saves to disk all data which has been modifiedsince the last snapshot.

I Simple, but eliminates the systems advantage of asynchronous computation.

48 / 61

Page 82: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Fault Tolerance - Asynchronous

I Based on the Chandy-Lamport algorithm.

I The snapshot function is implemented as a function in vertices.• It takes priority over all other update functions.

49 / 61

Page 83: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Fault Tolerance - Asynchronous

I Based on the Chandy-Lamport algorithm.

I The snapshot function is implemented as a function in vertices.• It takes priority over all other update functions.

49 / 61

Page 84: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

GraphLab2/Turi (PowerGraph)

50 / 61

Page 85: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

PowerGraph

I Factorizes the local vertices functions into the Gather, Apply and Scatter phases.

51 / 61

Page 86: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Programming Model

I Gather-Apply-Scatter (GAS)

I Gather: accumulate information from neighborhood.

I Apply: apply the accumulated value to center vertex.

I Scatter: update adjacent edges and vertices.

52 / 61

Page 87: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (1/2)

I Initially all vertices are active.

I It executes the vertex-program on the active vertices until none remain.• Once a vertex-program completes the scatter phase it becomes inactive until it is

reactivated.• Vertices can activate themselves and neighboring vertices.

I PowerGraph can execute both synchronously and asynchronously.

53 / 61

Page 88: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (1/2)

I Initially all vertices are active.

I It executes the vertex-program on the active vertices until none remain.• Once a vertex-program completes the scatter phase it becomes inactive until it is

reactivated.• Vertices can activate themselves and neighboring vertices.

I PowerGraph can execute both synchronously and asynchronously.

53 / 61

Page 89: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (2/2)

I Synchronous scheduling like Pregel.• Executing the gather, apply, and scatter in order.• Changes made to the vertex/edge data are committed at the end of each step.

I Asynchronous scheduling like GraphLab.• Changes made to the vertex/edge data during the apply and scatter functions are

immediately committed to the graph.• Visible to subsequent computation on neighboring vertices.

54 / 61

Page 90: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Execution Model (2/2)

I Synchronous scheduling like Pregel.• Executing the gather, apply, and scatter in order.• Changes made to the vertex/edge data are committed at the end of each step.

I Asynchronous scheduling like GraphLab.• Changes made to the vertex/edge data during the apply and scatter functions are

immediately committed to the graph.• Visible to subsequent computation on neighboring vertices.

54 / 61

Page 91: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Example: PageRank (PowerGraph)

PowerGraph_PageRank(i):

Gather(j -> i):

return wji * R[j]

sum(a, b):

return a + b

// total: Gather and sum

Apply(i, total):

R[i] = total

Scatter(i -> j):

if R[i] changed then activate(j)

R[i] =∑

j∈Nbrs(i)wjiR[j]

55 / 61

Page 92: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning (1/2)

I Vertx-cut partitioning.

I Random vertex-cuts: randomly assign edges to machines.

I Completely parallel and easy to distribute.

I High replication factor.

56 / 61

Page 93: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning (1/2)

I Vertx-cut partitioning.

I Random vertex-cuts: randomly assign edges to machines.

I Completely parallel and easy to distribute.

I High replication factor.

56 / 61

Page 94: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning (1/2)

I Vertx-cut partitioning.

I Random vertex-cuts: randomly assign edges to machines.

I Completely parallel and easy to distribute.

I High replication factor.

56 / 61

Page 95: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning (1/2)

I Vertx-cut partitioning.

I Random vertex-cuts: randomly assign edges to machines.

I Completely parallel and easy to distribute.

I High replication factor.

56 / 61

Page 96: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning (2/2)

I Greedy vertex-cuts

I A(v): set of machines that vertex v spans.

I Case 1: If A(u) ∩ A(v) 6= ∅, then the edge (u, v) should be assigned to a machine inthe intersection.

I Case 2: If A(u) ∩ A(v) = ∅, then the edge (u, v) should be assigned to one of themachines from the vertex with the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, then choose a machinefrom the assigned vertex.

I Case 4: If A(u) = A(v) = ∅, then assign the edge (u, v) to the least loaded machine.

57 / 61

Page 97: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning (2/2)

I Greedy vertex-cuts

I A(v): set of machines that vertex v spans.

I Case 1: If A(u) ∩ A(v) 6= ∅, then the edge (u, v) should be assigned to a machine inthe intersection.

I Case 2: If A(u) ∩ A(v) = ∅, then the edge (u, v) should be assigned to one of themachines from the vertex with the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, then choose a machinefrom the assigned vertex.

I Case 4: If A(u) = A(v) = ∅, then assign the edge (u, v) to the least loaded machine.

57 / 61

Page 98: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning (2/2)

I Greedy vertex-cuts

I A(v): set of machines that vertex v spans.

I Case 1: If A(u) ∩ A(v) 6= ∅, then the edge (u, v) should be assigned to a machine inthe intersection.

I Case 2: If A(u) ∩ A(v) = ∅, then the edge (u, v) should be assigned to one of themachines from the vertex with the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, then choose a machinefrom the assigned vertex.

I Case 4: If A(u) = A(v) = ∅, then assign the edge (u, v) to the least loaded machine.

57 / 61

Page 99: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning (2/2)

I Greedy vertex-cuts

I A(v): set of machines that vertex v spans.

I Case 1: If A(u) ∩ A(v) 6= ∅, then the edge (u, v) should be assigned to a machine inthe intersection.

I Case 2: If A(u) ∩ A(v) = ∅, then the edge (u, v) should be assigned to one of themachines from the vertex with the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, then choose a machinefrom the assigned vertex.

I Case 4: If A(u) = A(v) = ∅, then assign the edge (u, v) to the least loaded machine.

57 / 61

Page 100: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Graph Partitioning (2/2)

I Greedy vertex-cuts

I A(v): set of machines that vertex v spans.

I Case 1: If A(u) ∩ A(v) 6= ∅, then the edge (u, v) should be assigned to a machine inthe intersection.

I Case 2: If A(u) ∩ A(v) = ∅, then the edge (u, v) should be assigned to one of themachines from the vertex with the most unassigned edges.

I Case 3: If only one of the two vertices has been assigned, then choose a machinefrom the assigned vertex.

I Case 4: If A(u) = A(v) = ∅, then assign the edge (u, v) to the least loaded machine.

57 / 61

Page 101: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Summary

58 / 61

Page 102: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Summary

I Think like a vertex• Pregel: BSP, synchronous parallel model, message passing, edge-cut• GraphLab: asynchronous model, shared memory, edge-cut• PowerGraph: synchronous/asynchronous model, GAS, vertex-cut

59 / 61

Page 103: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

References

I G. Malewicz et al., “Pregel: a system for large-scale graph processing”, ACM SIG-MOD 2010

I Y. Low et al., “Distributed GraphLab: a framework for machine learning and datamining in the cloud”, VLDB 2012

I J. Gonzalez et al., “Powergraph: distributed graph-parallel computation on naturalgraphs”, OSDI 2012

60 / 61

Page 104: Large Scale Graph Processing - Pregel and GraphLab · Large Scale Graph Processing - Pregel and GraphLab Amir H. Payberah payberah@kth.se 01/10/2018

Questions?

61 / 61