69
Big Data Infrastructure Week 11: Analyzing Graphs, Redux (1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States See http://creativecommons.org/licenses/by-nc-sa/3.0/us/ for details CS 489/698 Big Data Infrastructure (Winter 2017) Jimmy Lin David R. Cheriton School of Computer Science University of Waterloo March 21, 2017 These slides are available at http://lintool.github.io/bigdata-2017w/

Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Big Data Infrastructure

Week 11: Analyzing Graphs, Redux (1/2)

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United StatesSee http://creativecommons.org/licenses/by-nc-sa/3.0/us/ for details

CS 489/698 Big Data Infrastructure (Winter 2017)

Jimmy LinDavid R. Cheriton School of Computer Science

University of Waterloo

March 21, 2017

These slides are available at http://lintool.github.io/bigdata-2017w/

Page 2: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Graph Algorithms, again?(srsly?)

Page 3: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

What makes graphs hard?

Irregular structureFun with data structures!

Irregular data access patternsFun with architectures!

IterationsFun with optimizations!

Page 4: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Characteristics of Graph Algorithms

Parallel graph traversalsLocal computations

Message passing along graph edges

Iterations

Page 5: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Given page x with inlinks t1…tn, whereC(t) is the out-degree of ta is probability of random jumpN is the total number of nodes in the graph

X

t1

t2

tn…

PR(x) = ↵

✓1

N

◆+ (1� ↵)

nX

i=1

PR(ti)

C(ti)

PageRank: Defined

Page 6: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

n5 [n1, n2, n3]n1 [n2, n4] n2 [n3, n5] n3 [n4] n4 [n5]

n2 n4 n3 n5 n1 n2 n3n4 n5

n2 n4n3 n5n1 n2 n3 n4 n5

n5 [n1, n2, n3]n1 [n2, n4] n2 [n3, n5] n3 [n4] n4 [n5]

Map

Reduce

PageRank in MapReduce

Page 7: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Map

Reduce

PageRank BFS

PR/N d+1

sum min

PageRank vs. BFS

Page 8: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

reduce

map

HDFS

HDFS

Convergence?

BFS

Page 9: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Convergence?reduce

map

HDFS

HDFS

map

HDFS

PageRank

Page 10: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

MapReduce Sucks

Java verbosity

Hadoop task startup time

Stragglers

Needless graph shuffling

Checkpointing at each iteration

Page 11: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Characteristics of Graph Algorithms

Parallel graph traversalsLocal computations

Message passing along graph edges

Iterations

Page 12: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

reduce

HDFS

map

HDFS

reduce

map

HDFS

reduce

map

HDFS

Let’s Spark!

Page 13: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

reduce

HDFS

map

reduce

map

reduce

map

Page 14: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

reduce

HDFS

map

reduce

map

reduce

map

Adjacency Lists PageRank Mass

Adjacency Lists PageRank Mass

Adjacency Lists PageRank Mass

Page 15: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

join

HDFS

map

join

map

join

map

Adjacency Lists PageRank Mass

Adjacency Lists PageRank Mass

Adjacency Lists PageRank Mass

Page 16: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

join

join

join

HDFS HDFS

Adjacency Lists PageRank vector

PageRank vector

flatMap

reduceByKey

PageRank vector

flatMap

reduceByKey

Page 17: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

join

join

join

HDFS HDFS

Adjacency Lists PageRank vector

PageRank vector

flatMap

reduceByKey

PageRank vector

flatMap

reduceByKey

Cache!

Page 18: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

PageRank'Performance'

171&

80&

72&

28&

0&20&40&60&80&100&120&140&160&180&

30& 60&

Tim

e'per'Iteration'(s)'

Number'of'machines'

Hadoop&

Spark&

Source: http://ampcamp.berkeley.edu/wp-content/uploads/2012/06/matei-zaharia-part-2-amp-camp-2012-standalone-programs.pdf

MapReduce vs. Spark

Page 19: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Characteristics of Graph Algorithms

Parallel graph traversalsLocal computations

Message passing along graph edges

Iterations

Even faster?

Page 20: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Big Data Processing in a Nutshell

Partition

Replicate

Reduce cross-partition communication

Page 21: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Simple Partitioning Techniques

Hash partitioning

Range partitioning on some underlying linearizationWeb pages: lexicographic sort of domain-reversed URLs

Social networks: sort by demographic characteristicsGeo data: space-filling curves

Page 22: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

“Best Practices”

Lin and Schatz. (2010) Design Patterns for Efficient Graph Algorithms in MapReduce.

PageRank over webgraph(40m vertices, 1.4b edges)

How much difference does it make?

Page 23: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

+18%1.4b

674m

Lin and Schatz. (2010) Design Patterns for Efficient Graph Algorithms in MapReduce.

PageRank over webgraph(40m vertices, 1.4b edges)

How much difference does it make?

Page 24: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

+18%

-15%

1.4b

674m

Lin and Schatz. (2010) Design Patterns for Efficient Graph Algorithms in MapReduce.

PageRank over webgraph(40m vertices, 1.4b edges)

How much difference does it make?

Page 25: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

+18%

-15%

-60%

1.4b

674m

86m

Lin and Schatz. (2010) Design Patterns for Efficient Graph Algorithms in MapReduce.

PageRank over webgraph(40m vertices, 1.4b edges)

How much difference does it make?

Page 26: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Schimmy Design Pattern

Basic implementation contains two dataflows:Messages (actual computations)

Graph structure (“bookkeeping”)

Schimmy: separate the two dataflows, shuffle only the messagesBasic idea: merge join between graph structure and messages

Lin and Schatz. (2010) Design Patterns for Efficient Graph Algorithms in MapReduce.

S T

both relations sorted by join key

S1 T1 S2 T2 S3 T3

both relations consistently partitioned and sorted by join key

Page 27: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

join

join

join

HDFS HDFS

Adjacency Lists PageRank vector

PageRank vector

flatMap

reduceByKey

PageRank vector

flatMap

reduceByKey

Page 28: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

+18%

-15%

-60%

1.4b

674m

86m

Lin and Schatz. (2010) Design Patterns for Efficient Graph Algorithms in MapReduce.

PageRank over webgraph(40m vertices, 1.4b edges)

How much difference does it make?

Page 29: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

+18%

-15%

-60%-69%

1.4b

674m

86m

Lin and Schatz. (2010) Design Patterns for Efficient Graph Algorithms in MapReduce.

PageRank over webgraph(40m vertices, 1.4b edges)

How much difference does it make?

Page 30: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Simple Partitioning Techniques

Hash partitioning

Range partitioning on some underlying linearizationWeb pages: lexicographic sort of domain-reversed URLs

Social networks: sort by demographic characteristicsGeo data: space-filling curves

Page 31: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Ugander et al. (2011) The Anatomy of the Facebook Social Graph.

Analysis of 721 million active users (May 2011)

54 countries w/ >1m active users, >50% penetration

12

ID PH LK AU NZ

TH MY

SG HK

TW US

DO

PR MX

CA

VE CL

AR UY

CO

CR

GT

EC PE BO ES GH

GB

ZA IL JO AE KW DZ

TN IT MK

AL RS

SI BA HR

TR PT BE FR HU

IE DK

NO

SE CZ

BG GR

GRBGCZSENODKIEHUFRBEPTTRHRBASIRSALMKITTNDZKWAEJOILZAGBGHESBOPEECGTCRCOUYARCLVECAMXPRDOUSTWHKSGMYTHNZAULKPHID

Figure 9. Normalized country adjacency matrix. Matrix of edges between countries with > 1million users and > 50% Facebook penetration shown on a log scale. To normalize, we divided eachelement of the adjacency matrix by the product of the row country degree and column country degree.

country, and the data shows that 84.2% percent of edges are within countries. So the network divides fairlycleanly along country lines into network clusters or communities. This mesoscopic-scale organization isto be expected as Facebook captures social relationships divided by national borders. We can furtherquantify this division using the modularity Q [37] which is the fraction of edges within communitiesminus the expected fraction of edges within communities in a randomized version of the network thatpreserves the degrees for each individual [38], but is otherwise random. In this case, the communitiesare the countries. The computed value is Q = 0.7486 which is quite large [39] and indicates a stronglymodular network structure at the scale of countries. Especially considering that unlike numerous studiesusing the modularity to detect communities, we in no way attempted to maximize it directly, and insteadmerely utilized the given countries as community labels.

We visualize this highly modular structure in Fig. 9. The figure displays a heatmap of the numberof edges between the 54 countries where the active Facebook user population exceeds one million usersand is more than 50% of the internet-enabled population [40]. To be entirely accurate, the shown matrixcontains each edge twice, once in both directions, and therefore has twice the number of edges in diagonalelements. The number of edges was normalized by dividing the ijth entry by the row and column sums,equal to the product of the degrees of country i and j. The ordering of the countries was then determinedvia complete linkage hierarchical clustering.

Country Structure in Facebook

Page 32: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Simple Partitioning Techniques

Hash partitioning

Range partitioning on some underlying linearizationWeb pages: lexicographic sort of domain-reversed URLs

Social networks: sort by demographic characteristicsGeo data: space-filling curves

Page 33: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Aside: Partitioning Geo-data

Page 34: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Geo-data = regular graph

Page 35: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Space-filling curves: Z-Order Curves

Page 36: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Space-filling curves: Hilbert Curves

Page 37: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Simple Partitioning Techniques

Hash partitioning

Range partitioning on some underlying linearizationWeb pages: lexicographic sort of domain-reversed URLs

Social networks: sort by demographic characteristicsGeo data: space-filling curves

But what about graphs in general?

Page 38: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Source: http://www.flickr.com/photos/fusedforces/4324320625/

Page 39: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

General-Purpose Graph Partitioning

Recursive bisectionGraph coarsening

Page 40: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

MULTILEVEL GRAPH PARTITIONING 363

GG

1

projected partitionrefined partition

Coa

rsen

ing

Phas

eUncoarsening Phase

Initial Partitioning Phase

Multilevel Graph Bisection

G

G3

G2

G1

O

G

2G

O

4

G3

Fig. 1. The various phases of the multilevel graph bisection. During the coarsening phase, thesize of the graph is successively decreased; during the initial partitioning phase, a bisection of thesmaller graph is computed; and during the uncoarsening phase, the bisection is successively refined asit is projected to the larger graphs. During the uncoarsening phase the light lines indicate projectedpartitions, and dark lines indicate partitions that were produced after refinement.

Formally, a multilevel graph bisection algorithm works as follows: consider aweighted graph G0 = (V0, E0), with weights both on vertices and edges. A multilevelgraph bisection algorithm consists of the following three phases.

Coarsening phase. The graph G0 is transformed into a sequence of smallergraphs G1, G2, . . . , Gm

such that |V0| > |V1| > |V2| > · · · > |Vm

|.Partitioning phase. A 2-way partition P

m

of the graph Gm

= (Vm

, Em

) iscomputed that partitions V

m

into two parts, each containing half the verticesof G0.

Uncoarsening phase. The partition Pm

of Gm

is projected back to G0 by goingthrough intermediate partitions P

m�1, Pm�2, . . . , P1, P0.

3. Coarsening phase. During the coarsening phase, a sequence of smallergraphs, each with fewer vertices, is constructed. Graph coarsening can be achieved invarious ways. Some possibilities are shown in Figure 2.

In most coarsening schemes, a set of vertices of Gi

is combined to form a singlevertex of the next level coarser graph G

i+1. Let V v

i

be the set of vertices of Gi

combined to form vertex v of Gi+1. We will refer to vertex v as a multinode. In order

for a bisection of a coarser graph to be good with respect to the original graph, the

Karypis and Kumar. (1998) A Fast and High Quality Multilevel Scheme for Partitioning Irregular Graphs.

General-Purpose Graph Partitioning

Page 41: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Karypis and Kumar. (1998) A Fast and High Quality Multilevel Scheme for Partitioning Irregular Graphs.

364 GEORGE KARYPIS AND VIPIN KUMAR

1

1

2

2

1

1

1

1

11

11

1 1

1

1

1

1

111

1

1

1

11

1

5

3

33

2

21

1

4

4

44

4

1 1

1

11

1

2

5

1

1

1

2

2

1

111

1

2

22

2

5

2

22

Fig. 2. Di↵erent ways to coarsen a graph.

weight of vertex v is set equal to the sum of the weights of the vertices in V v

i

. Also,in order to preserve the connectivity information in the coarser graph, the edges ofv are the union of the edges of the vertices in V v

i

. In the case where more than onevertex of V v

i

contains edges to the same vertex u, the weight of the edge of v is equalto the sum of the weights of these edges. This is useful when we evaluate the qualityof a partition at a coarser graph. The edge-cut of the partition in a coarser graphwill be equal to the edge-cut of the same partition in the finer graph. Updating theweights of the coarser graph is illustrated in Figure 2.

Two main approaches have been proposed for obtaining coarser graphs. The firstapproach is based on finding a random matching and collapsing the matched verticesinto a multinode [4, 26], while the second approach is based on creating multinodesthat are made of groups of vertices that are highly connected [7, 19, 20, 10]. Thelater approach is suited for graphs arising in VLSI applications, since these graphshave highly connected components. However, for graphs arising in finite elementapplications, most vertices have similar connectivity patterns (i.e., the degree of eachvertex is fairly close to the average degree of the graph). In the rest of this sectionwe describe the basic ideas behind coarsening using matchings.

Given a graph Gi

= (Vi

, Ei

), a coarser graph can be obtained by collapsingadjacent vertices. Thus, the edge between two vertices is collapsed and a multinodeconsisting of these two vertices is created. This edge collapsing idea can be formallydefined in terms of matchings. A matching of a graph is a set of edges no two ofwhich are incident on the same vertex. Thus, the next level coarser graph G

i+1 isconstructed from G

i

by finding a matching of Gi

and collapsing the vertices beingmatched into multinodes. The unmatched vertices are simply copied over to G

i+1.Since the goal of collapsing vertices using matchings is to decrease the size of the graphG

i

, the matching should contain a large number of edges. For this reason, maximalmatchings are used to obtain the successively coarse graphs. A matching is maximalif any edge in the graph that is not in the matching has at least one of its endpointsmatched. Note that depending on how matchings are computed, the number of edges

Graph Coarsening

Page 42: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Graph Coarsening Challenges

Difficult to identify dense neighborhoods in large graphsLocal methods to the rescue?

Page 43: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Partition

Page 44: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Partition

Page 45: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

What’s the issue?The fastest current graph algorithms combine

smart partitioning with asynchronous iterations

Partition + Replicate

Page 46: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Source: Wikipedia (Waste container)

Graph Processing Frameworks

Page 47: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

join

join

join

HDFS HDFS

Adjacency Lists PageRank vector

PageRank vector

flatMap

reduceByKey

PageRank vector

flatMap

reduceByKey

Cache!

Page 48: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Pregel: Computational Model

Based on Bulk Synchronous Parallel (BSP)Computational units encoded in a directed graphComputation proceeds in a series of supersteps

Message passing architecture

Each vertex, at each superstep:Receives messages directed at it from previous superstep

Executes a user-defined function (modifying state)Emits messages to other vertices (for the next superstep)

Termination:A vertex can choose to deactivate itselfIs “woken up” if new messages received

Computation halts when all vertices are inactive

Page 49: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

superstep t

superstep t+1

superstep t+2

Source: Malewicz et al. (2010) Pregel: A System for Large-Scale Graph Processing. SIGMOD.

Page 50: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Pregel: Implementation

Master-Worker architectureVertices are hash partitioned (by default) and assigned to workers

Everything happens in memory

Processing cycle:Master tells all workers to advance a single superstep

Worker delivers messages from previous superstep, executing vertex computationMessages sent asynchronously (in batches)

Worker notifies master of number of active vertices

Fault toleranceCheckpointing

Heartbeat/revert

Page 51: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

class ShortestPathVertex : public Vertex<int, int, int> {void Compute(MessageIterator* msgs) {

int mindist = IsSource(vertex_id()) ? 0 : INF;for (; !msgs->Done(); msgs->Next())

mindist = min(mindist, msgs->Value());if (mindist < GetValue()) {

*MutableValue() = mindist;OutEdgeIterator iter = GetOutEdgeIterator();for (; !iter.Done(); iter.Next())

SendMessageTo(iter.Target(),mindist + iter.GetValue());

}VoteToHalt();

}};

Source: Malewicz et al. (2010) Pregel: A System for Large-Scale Graph Processing. SIGMOD.

Pregel: SSSP

Page 52: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

class PageRankVertex : public Vertex<double, void, double> {public:

virtual void Compute(MessageIterator* msgs) {if (superstep() >= 1) {

double sum = 0;for (; !msgs->Done(); msgs->Next())

sum += msgs->Value();*MutableValue() = 0.15 / NumVertices() + 0.85 * sum;

}

if (superstep() < 30) {const int64 n = GetOutEdgeIterator().size();SendMessageToAllNeighbors(GetValue() / n);

} else {VoteToHalt();

}}

};

Source: Malewicz et al. (2010) Pregel: A System for Large-Scale Graph Processing. SIGMOD.

Pregel: PageRank

Page 53: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

class MinIntCombiner : public Combiner<int> {virtual void Combine(MessageIterator* msgs) {

int mindist = INF;for (; !msgs->Done(); msgs->Next())

mindist = min(mindist, msgs->Value());Output("combined_source", mindist);

}

};

Source: Malewicz et al. (2010) Pregel: A System for Large-Scale Graph Processing. SIGMOD.

Pregel: Combiners

Page 54: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike
Page 55: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Giraph Architecture

Master – Application coordinatorSynchronizes supersteps

Assigns partitions to workers before superstep begins

Workers – Computation & messagingHandle I/O – reading and writing the graph

Computation/messaging of assigned partitions

ZooKeeperMaintains global application state

Page 56: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Part 0

Part 1

Part 2

Part 3

Compute / Send

Messages

Wor

ker

1

Compute / Send

Messages

Mas

ter

Wor

ker

0

In-memory graph

Send stats / iterate!

Compute/Iterate

2

Wor

ker

1W

orke

r 0 Part 0

Part 1

Part 2

Part 3

Output format

Part 0

Part 1

Part 2

Part 3

Storing the graph

3

Split 0

Split 1

Split 2

Split 3

Wor

ker

1

Mas

ter

Wor

ker

0

Input format

Load / Send

Graph

Load / Send

Graph

Loading the graph

1

Split 4

Split

Giraph Dataflow

Page 57: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Active Inactive

Vote to Halt

Received Message

Vertex Lifecycle

Giraph Lifecycle

Page 58: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Output

All Vertices Halted?

InputCompute Superstep

No

Master halted?

No

Yes

Yes

Giraph Lifecycle

Page 59: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Giraph Example

Page 60: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

5

15

2

5

5

25

5

5

5

5

1

2

Processor 1

Processor 2

Time

Execution Trace

Page 61: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

join

join

join

HDFS HDFS

Adjacency Lists PageRank vector

PageRank vector

flatMap

reduceByKey

PageRank vector

flatMap

reduceByKey

Cache!

Page 62: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Source: Wikipedia (Waste container)

Graph Processing Frameworks

Page 63: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

GraphX: Motivation

Page 64: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

GraphX = Spark for Graphs

Integration of record-oriented and graph-oriented processing

Extends RDDs to Resilient Distributed Property Graphs

Supported operationsMap operations over views of the graph (vertices, edges, triplets)

Pregel-like computationsNeighborhood aggregations

Join graph with RDDs

Page 65: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Property Graph: Example

Page 66: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Property Graphs in SparkX

class Graph[VD, ED] {val vertices: VertexRDD[VD]val edges: EdgeRDD[ED]

}

Page 67: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Underneath the Covers

Page 68: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

join

join

join

HDFS HDFS

Adjacency Lists PageRank vector

PageRank vector

flatMap

reduceByKey

PageRank vector

flatMap

reduceByKey

Cache!

Page 69: Big Data Infrastructure - GitHub PagesBig Data Infrastructure Week 11: Analyzing Graphs, Redux(1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike

Source: Wikipedia (Japanese rock garden)

Questions?