Data-Intensive Computing with MapReduce

Similar documents
University of Maryland. Tuesday, March 2, 2010

Jordan Boyd-Graber University of Maryland. Thursday, March 3, 2011

Graph Algorithms. Revised based on the slides by Ruoming Kent State

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2017)

Graph Data Processing with MapReduce

Link Analysis in the Cloud

Data-Intensive Distributed Computing

COSC 6339 Big Data Analytics. Graph Algorithms and Apache Giraph

Map-Reduce Applications: Counting, Graph Shortest Paths

MapReduce Patterns. MCSN - N. Tonellotto - Distributed Enabling Platforms

Map-Reduce Applications: Counting, Graph Shortest Paths

Lecture 11: Graph algorithms! Claudia Hauff (Web Information Systems)!

TI2736-B Big Data Processing. Claudia Hauff

with MapReduce The ischool University of Maryland JHU Summer School on Human Language Technology Wednesday, June 17, 2009

Graph Algorithms using Map-Reduce. Graphs are ubiquitous in modern society. Some examples: The hyperlink structure of the web

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2016)

Data-Intensive Distributed Computing

Data-Intensive Distributed Computing

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2017)

MapReduce Design Patterns

Graphs (Part II) Shannon Quinn

Developing MapReduce Programs

Data-Intensive Distributed Computing

Chapter 4. Distributed Algorithms based on MapReduce. - Applications

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2017)

Graph Algorithms. Chapter 5

Centralities (4) By: Ralucca Gera, NPS. Excellence Through Knowledge

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2016)

Laboratory Session: MapReduce

CS6200 Information Retreival. The WebGraph. July 13, 2015

Mining Web Data. Lijun Zhang

Data-Intensive Computing with MapReduce

Data-Intensive Computing with MapReduce

Link Analysis. CSE 454 Advanced Internet Systems University of Washington. 1/26/12 16:36 1 Copyright D.S.Weld

Lecture 7: MapReduce design patterns! Claudia Hauff (Web Information Systems)!

CS246: Mining Massive Datasets Jure Leskovec, Stanford University

TI2736-B Big Data Processing. Claudia Hauff

Distributed computing: index building and use

Algorithms for MapReduce. Combiners Partition and Sort Pairs vs Stripes

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2017)

Big Data Management and NoSQL Databases

Data-Intensive Distributed Computing

CS 347 Parallel and Distributed Data Processing

CS 347 Parallel and Distributed Data Processing

Introduction To Graphs and Networks. Fall 2013 Carola Wenk

INTRODUCTION TO DATA SCIENCE. Link Analysis (MMDS5)

Unit VIII. Chapter 9. Link Analysis

MapReduce Algorithm Design

Scalable Big Graph Processing in Map Reduce

COMP5331: Knowledge Discovery and Data Mining

G(B)enchmark GraphBench: Towards a Universal Graph Benchmark. Khaled Ammar M. Tamer Özsu

University of Maryland. Tuesday, March 23, 2010

CC PROCESAMIENTO MASIVO DE DATOS OTOÑO Lecture 7: Information Retrieval II. Aidan Hogan

CS249: SPECIAL TOPICS MINING INFORMATION/SOCIAL NETWORKS

MapReduce Algorithms

Administrative. Web crawlers. Web Crawlers and Link Analysis!

CS224W: Social and Information Network Analysis Jure Leskovec, Stanford University

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2017)

Overview of this week

Challenges in large-scale graph processing on HPC platforms and the Graph500 benchmark. by Nkemdirim Dockery

Big Data Management and NoSQL Databases

Databases 2 (VU) ( / )

World Wide Web has specific challenges and opportunities

Graph Data Management

How to organize the Web?

CS246: Mining Massive Datasets Jure Leskovec, Stanford University

CS224W: Social and Information Network Analysis Jure Leskovec, Stanford University

Algorithms and Data Structures

Always start off with a joke, to lighten the mood. Workflows 3: Graphs, PageRank, Loops, Spark

Graphs and Graph Algorithms. Slides by Larry Ruzzo

Algorithm Design (8) Graph Algorithms 1/2

CS224W: Social and Information Network Analysis Jure Leskovec, Stanford University

Mosaic: Processing a Trillion-Edge Graph on a Single Machine

Parallel Breadth First Search

Managing and Mining Billion Node Graphs. Haixun Wang Microsoft Research Asia

Implementing Mapreduce Algorithms In Hadoop Framework Guide : Dr. SOBHAN BABU

& ( D. " mnp ' ( ) n 3. n 2. ( ) C. " n

A New Parallel Algorithm for Connected Components in Dynamic Graphs. Robert McColl Oded Green David Bader

Chapter 10. Fundamental Network Algorithms. M. E. J. Newman. May 6, M. E. J. Newman Chapter 10 May 6, / 33

PageRank and related algorithms

3 announcements: Thanks for filling out the HW1 poll HW2 is due today 5pm (scans must be readable) HW3 will be posted today

MCL. (and other clustering algorithms) 858L

Assignment 3 ITCS-6010/8010: Cloud Computing for Data Analysis

CS 5220: Parallel Graph Algorithms. David Bindel

Counting Triangles & The Curse of the Last Reducer. Siddharth Suri Sergei Vassilvitskii Yahoo! Research

Jure Leskovec Including joint work with Y. Perez, R. Sosič, A. Banarjee, M. Raison, R. Puttagunta, P. Shah

Plan for today. CS276B Text Retrieval and Mining Winter Evolution of search engines. Connectivity analysis

Shark. Hive on Spark. Cliff Engle, Antonio Lupher, Reynold Xin, Matei Zaharia, Michael Franklin, Ion Stoica, Scott Shenker

Lecture Map-Reduce. Algorithms. By Marina Barsky Winter 2017, University of Toronto

n 2 ( ) ( ) + n is in Θ n logn

Advanced Data Management

Goals! CSE 417: Algorithms and Computational Complexity!

Resource and Performance Distribution Prediction for Large Scale Analytics Queries

iihadoop: an asynchronous distributed framework for incremental iterative computations

Hadoop Map Reduce 10/17/2018 1

L22-23: Graph Algorithms

B490 Mining the Big Data. 5. Models for Big Data

COMPARATIVE ANALYSIS OF POWER METHOD AND GAUSS-SEIDEL METHOD IN PAGERANK COMPUTATION

Graphs. The ultimate data structure. graphs 1

Mining Social Network Graphs

Transcription:

Data-Intensive Computing with MapReduce Session 5: Graph Processing Jimmy Lin University of Maryland Thursday, February 21, 2013 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

Today s Agenda Graph problems and representations Parallel breadth-first search PageRank Beyond PageRank and other graph algorithms Optimizing graph algorithms

What s a graph? G = (V,E), where l V represents the set of vertices (nodes) l E represents the set of edges (links) l Both vertices and edges may contain additional information Different types of graphs: l Directed vs. undirected edges l Presence or absence of cycles Graphs are everywhere: l Hyperlink structure of the web l Physical structure of computers on the Internet l Interstate highway system l Social networks

Source: Wikipedia (Königsberg)

Source: Wikipedia (Kaliningrad)

Some Graph Problems Finding shortest paths l Routing Internet traffic and UPS trucks Finding minimum spanning trees l Telco laying down fiber Finding Max Flow l Airline scheduling Identify special nodes and communities l Breaking up terrorist cells, spread of avian flu Bipartite matching l Monster.com, Match.com And of course... PageRank

Graphs and MapReduce A large class of graph algorithms involve: l Performing computations at each node: based on node features, edge features, and local link structure l Propagating computations: traversing the graph Key questions: l How do you represent graph data in MapReduce? l How do you traverse a graph in MapReduce?

Representing Graphs G = (V, E) Two common representations l Adjacency matrix l Adjacency list

Adjacency Matrices Represent a graph as an n x n square matrix M l n = V l M ij = 1 means a link from node i to j 1 2 3 4 1 0 1 0 1 2 1 0 1 1 3 1 0 0 0 4 1 0 1 0 1 4 2 3

Adjacency Matrices: Critique Advantages: l Amenable to mathematical manipulation l Iteration over rows and columns corresponds to computations on outlinks and inlinks Disadvantages: l Lots of zeros for sparse matrices l Lots of wasted space

Adjacency Lists Take adjacency matrices and throw away all the zeros 1 2 3 4 1 0 1 0 1 2 1 0 1 1 3 1 0 0 0 4 1 0 1 0 1: 2, 4 2: 1, 3, 4 3: 1 4: 1, 3

Adjacency Lists: Critique Advantages: l Much more compact representation l Easy to compute over outlinks Disadvantages: l Much more difficult to compute over inlinks

Single-Source Shortest Path Problem: find shortest path from a source node to one or more target nodes l Shortest might also mean lowest weight or cost First, a refresher: Dijkstra s Algorithm

Dijkstra s Algorithm Example 1 10 0 2 3 9 4 6 5 7 2 Example from CLR

Dijkstra s Algorithm Example 10 1 10 0 2 3 9 4 6 5 7 5 2 Example from CLR

Dijkstra s Algorithm Example 8 1 14 10 0 2 3 9 4 6 5 7 5 2 7 Example from CLR

Dijkstra s Algorithm Example 8 1 13 10 0 2 3 9 4 6 5 7 5 2 7 Example from CLR

Dijkstra s Algorithm Example 8 1 9 10 0 2 3 9 4 6 5 7 5 2 7 Example from CLR

Dijkstra s Algorithm Example 8 1 9 10 0 2 3 9 4 6 5 7 5 2 7 Example from CLR

Single-Source Shortest Path Problem: find shortest path from a source node to one or more target nodes l Shortest might also mean lowest weight or cost Single processor machine: Dijkstra s Algorithm MapReduce: parallel breadth-first search (BFS)

Finding the Shortest Path Consider simple case of equal edge weights Solution to the problem can be defined inductively Here s the intuition: l Define: b is reachable from a if b is on adjacency list of a DISTANCETO(s) = 0 l For all nodes p reachable from s, DISTANCETO(p) = 1 l For all nodes n reachable from some other set of nodes M, DISTANCETO(n) = 1 + min(distanceto(m), m M) d 1 m 1 s d 2 m 2 n d 3 m 3

Source: Wikipedia (Wave)

Visualizing Parallel BFS n 0 n 1 n 7 n 3 n 2 n 6 n 5 n 4 n 8 n 9

From Intuition to Algorithm Data representation: l Key: node n l Value: d (distance from start), adjacency list (nodes reachable from n) l Initialization: for all nodes except for start node, d = Mapper: l m adjacency list: emit (m, d + 1) Sort/Shuffle l Groups distances by reachable nodes Reducer: l Selects minimum distance path for each reachable node l Additional bookkeeping needed to keep track of actual path

Multiple Iterations Needed Each MapReduce iteration advances the frontier by one hop l Subsequent iterations include more and more reachable nodes as frontier expands l Multiple iterations are needed to explore entire graph Preserving graph structure: l Problem: Where did the adjacency list go? l Solution: mapper emits (n, adjacency list) as well

BFS Pseudo-Code

Stopping Criterion How many iterations are needed in parallel BFS (equal edge weight case)? Convince yourself: when a node is first discovered, we ve found the shortest path Now answer the question... l Six degrees of separation? Practicalities of implementation in MapReduce

Comparison to Dijkstra Dijkstra s algorithm is more efficient l At each step, only pursues edges from minimum-cost path inside frontier MapReduce explores all paths in parallel l Lots of waste l Useful work is only done at the frontier Why can t we do better using MapReduce?

Single Source: Weighted Edges Now add positive weights to the edges l Why can t edge weights be negative? Simple change: add weight w for each edge in adjacency list l In mapper, emit (m, d + w p ) instead of (m, d + 1) for each node m That s it?

Stopping Criterion How many iterations are needed in parallel BFS (positive edge weight case)? Convince yourself: when a node is first discovered, we ve found the shortest path Not true!

Additional Complexities search frontier 1 n 6 n 7 1 1 r 10 1 n 5 n 8 n 9 n 1 s p q 1 n 2 1 1 1 n 4 n 3

Stopping Criterion How many iterations are needed in parallel BFS (positive edge weight case)? Practicalities of implementation in MapReduce

Source: Wikipedia (Crowd) Application: Social Search

Social Search When searching, how to rank friends named John? l Assume undirected graphs l Rank matches by distance to user Naïve implementations: l Precompute all-pairs distances l Compute distances at query time Can we do better?

All-Pairs? Floyd-Warshall Algorithm: difficult to MapReduce-ify Multiple-source shortest paths in MapReduce: run multiple parallel BFS simultaneously l Assume source nodes {s 0, s 1, s n } l Instead of emitting a single distance, emit an array of distances, with respect to each source l Reducer selects minimum for each element in array Does this scale?

Landmark Approach (aka sketches) Select n seeds {s 0, s 1, s n } Compute distances from seeds to every node: A = [2, 1, 1] B = [1, 1, 2] C = [4, 3, 1] D = [1, 2, 4] l What can we conclude about distances? l Insight: landmarks bound the maximum path length Lots of details: l How to more tightly bound distances l How to select landmarks (random isn t the best ) Use multi-source parallel BFS implementation in MapReduce!

Source: Wikipedia (Wave) <pause/>

Graphs and MapReduce A large class of graph algorithms involve: l Performing computations at each node: based on node features, edge features, and local link structure l Propagating computations: traversing the graph Generic recipe: l Represent graphs as adjacency lists l Perform local computations in mapper l Pass along partial results via outlinks, keyed by destination node l Perform aggregation in reducer on inlinks to a node l Iterate until convergence: controlled by external driver l Don t forget to pass the graph structure between iterations

Random Walks Over the Web Random surfer model: l User starts at a random Web page l User randomly clicks on links, surfing from page to page PageRank l Characterizes the amount of time spent on any given page l Mathematically, a probability distribution over pages PageRank captures notions of page importance l Correspondence to human intuition? l One of thousands of features used in web search (query-independent)

PageRank: Defined Given page x with inlinks t 1 t n, where l C(t) is the out-degree of t l α is probability of random jump l N is the total number of nodes in the graph PR(x) = 1 N +(1 ) nx i=1 PR(t i ) C(t i ) t 1 X t 2 t n

Computing PageRank Properties of PageRank l Can be computed iteratively l Effects at each iteration are local Sketch of algorithm: l Start with seed PR i values l Each page distributes PR i credit to all pages it links to l Each target page adds up credit from multiple in-bound links to compute PR i+1 l Iterate until values converge

Simplified PageRank First, tackle the simple case: l No random jump factor l No dangling nodes Then, factor in these complexities l Why do we need the random jump? l Where do dangling nodes come from?

Sample PageRank Iteration (1) Iteration 1 n 2 (0.2) n 2 (0.166) n 1 (0.2) 0.1 0.1 0.1 n 1 (0.066) 0.1 0.066 0.066 0.066 n 5 (0.2) 0.2 0.2 n 3 (0.2) n 5 (0.3) n 3 (0.166) n 4 (0.2) n 4 (0.3)

Sample PageRank Iteration (2) Iteration 2 n 2 (0.166) n 2 (0.133) n 1 (0.066) 0.033 0.083 0.083 n 1 (0.1) 0.033 0.1 0.1 0.1 n 5 (0.3) 0.3 0.166 n 3 (0.166) n 5 (0.383) n 3 (0.183) n 4 (0.3) n 4 (0.2)

PageRank in MapReduce n 1 [n 2, n 4 ] n 2 [n 3, n 5 ] n 3 [n 4 ] n 4 [n 5 ] n 5 [n 1, n 2, n 3 ] Map n 2 n 4 n 3 n 5 n 4 n 5 n 1 n 2 n 3 n 1 n 2 n 2 n 3 n 3 n 4 n 4 n 5 n 5 Reduce n 1 [n 2, n 4 ] n 2 [n 3, n 5 ] n 3 [n 4 ] n 4 [n 5 ] n 5 [n 1, n 2, n 3 ]

PageRank Pseudo-Code

Complete PageRank Two additional complexities l What is the proper treatment of dangling nodes? l How do we factor in the random jump factor? Solution: l Second pass to redistribute missing PageRank mass and account for random jumps 1 m p 0 = +(1 ) N N + p l p is PageRank value from before, p' is updated PageRank value l N is the number of nodes in the graph l m is the missing PageRank mass Additional optimization: make it a single pass!

PageRank Convergence Alternative convergence criteria l Iterate until PageRank values don t change l Iterate until PageRank rankings don t change l Fixed number of iterations Convergence for web graphs? l Not a straightforward question Watch out for link spam: l Link farms l Spider traps l

Beyond PageRank Variations of PageRank l Weighted edges l Personalized PageRank Variants on graph random walks l Hubs and authorities (HITS) l SALSA

Applications Static prior for web ranking Identification of special nodes in a network Link recommendation Additional feature in any machine learning problem

Other Classes of Graph Algorithms Subgraph pattern matching Computing simple graph statistics l Degree vertex distributions Computing more complex graph statistics l Clustering coefficients l Counting triangles

General Issues for Graph Algorithms Sparse vs. dense graphs Graph topologies

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

MapReduce Sucks Java verbosity Hadoop task startup time Stragglers Needless graph shuffling Checkpointing at each iteration

Iterative Algorithms Source: Wikipedia (Water wheel)

MapReduce sucks at iterative algorithms Alternative programming models (later) Easy fixes (now)

In-Mapper Combining Use combiners l Perform local aggregation on map output l Downside: intermediate data is still materialized Better: in-mapper combining l Preserve state across multiple map calls, aggregate messages in buffer, emit buffer contents at end l Downside: requires memory management buffer setup map cleanup Emit all key-value pairs at once

Better Partitioning Default: hash partitioning l Randomly assign nodes to partitions Observation: many graphs exhibit local structure l E.g., communities in social networks l Better partitioning creates more opportunities for local aggregation Unfortunately, partitioning is hard! l Sometimes, chick-and-egg l But cheap heuristics sometimes available l For webgraphs: range partition on domain-sorted URLs

Schimmy Design Pattern Basic implementation contains two dataflows: l Messages (actual computations) l Graph structure ( bookkeeping ) Schimmy: separate the two dataflows, shuffle only the messages l Basic idea: merge join between graph structure and messages both relations both sorted relations by join consistently key partitioned and sorted by join key S 1 T 1 S 2 T 2 S 3 T 3

Do the Schimmy! Schimmy = reduce side parallel merge join between graph structure and messages l Consistent partitioning between input and intermediate data l Mappers emit only messages (actual computation) l Reducers read graph structure directly from HDFS from HDFS (graph structure) intermediate data (messages) from HDFS (graph structure) intermediate data (messages) from HDFS (graph structure) intermediate data (messages) S 1 T 1 S 2 T 2 S 3 T 3 Reducer Reducer Reducer

Experiments Cluster setup: l 10 workers, each 2 cores (3.2 GHz Xeon), 4GB RAM, 367 GB disk l Hadoop 0.20.0 on RHELS 5.3 Dataset: l First English segment of ClueWeb09 collection l 50.2m web pages (1.53 TB uncompressed, 247 GB compressed) l Extracted webgraph: 1.4 billion links, 7.0 GB l Dataset arranged in crawl order Setup: l Measured per-iteration running time (5 iterations) l 100 partitions

Results Best Practices

Results +18% 1.4b 674m

Results +18% 1.4b 674m -15%

Results +18% 1.4b 674m -15% -60% 86m

Results +18% 1.4b 674m -15% -60% 86m -69%

MapReduce sucks at iterative algorithms Alternative programming models (later) Easy fixes (now) Later, the hammer argument

Today s Agenda Graph problems and representations Parallel breadth-first search PageRank Beyond PageRank and other graph algorithms Optimizing graph algorithms

Questions? Source: Wikipedia (Japanese rock garden)