Cluster Computing with DryadLINQ

68
Cluster Computing with DryadLINQ Mihai Budiu Microsoft Research, Silicon Valley Intel Research Berkeley, Systems Seminar Series October 9, 2008

description

Cluster Computing with DryadLINQ. Mihai Budiu Microsoft Research, Silicon Valley Intel Research Berkeley, Systems Seminar Series October 9, 2008. The Roaring ‘60s. The other ‘60s. Spacewars. PDP/8. ARPANET. Multics. Time-sharing. (defun factorial (n) (if (

Transcript of Cluster Computing with DryadLINQ

Page 1: Cluster Computing with DryadLINQ

Cluster Computing with DryadLINQ

Mihai Budiu Microsoft Research, Silicon Valley

Intel Research Berkeley, Systems Seminar SeriesOctober 9, 2008

Page 3: Cluster Computing with DryadLINQ

3

The other ‘60s

OS/360

Multics

ARPANET

PDP/8

Spacewars

Virtual memory

Time-sharing

(defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))

Page 4: Cluster Computing with DryadLINQ

4

What about us, now?

Page 5: Cluster Computing with DryadLINQ

5

Layers

Networking

Storage

Distributed Execution

Scheduling

Resource Management

Applications

Identity & Security

Caching and Synchronization

Programming Languages and APIs

Ope

ratin

g Sy

stem

Page 6: Cluster Computing with DryadLINQ

6

Pieces of the Global Computer

Page 7: Cluster Computing with DryadLINQ

7

This Work

Page 8: Cluster Computing with DryadLINQ

8

• Introduction• Dryad • DryadLINQ• DryadLINQ Applications

Outline

Page 9: Cluster Computing with DryadLINQ

9

Dryad• Continuously deployed since 2006• Running on >> 104 machines• Sifting through > 10Pb data daily• Runs on clusters > 3000 machines• Handles jobs with > 105 processes each• Platform for rich software ecosystem• Used by >> 100 developers

• Written at Microsoft Research, Silicon Valley

Page 10: Cluster Computing with DryadLINQ

10

Bibliography

DryadLINQ: A System for General-Purpose Distributed Data-Parallel Computing Using a High-Level Language

Yuan Yu, Michael Isard, Dennis Fetterly, Mihai Budiu, Úlfar Erlingsson, Pradeep Kumar Gunda, and Jon Currey

Symposium on Operating System Design and Implementation (OSDI), San Diego, CA, December 8-10, 2008

Dryad: Distributed Data-Parallel Programs from Sequential Building Blocks

Michael Isard, Mihai Budiu, Yuan Yu, Andrew Birrell, and Dennis Fetterly

European Conference on Computer Systems (EuroSys), Lisbon, Portugal, March 21-23, 2007

Page 11: Cluster Computing with DryadLINQ

11

SQL

Software Stack

Windows Server

Cluster Services

Distributed Filesystem (Cosmos)

Dryad

Distributed Shell

PSQL

DryadLINQSQL

server

Windows Server

Windows Server

Windows Server

C++

CIFS/NTFS

legacycode

sed, awk, perl, grep

SSISScope

C#MachineLearning

.Net

Job

queu

eing

, mon

itorin

g

Distributed Data Structures

GraphsData

mining

Applications

Page 12: Cluster Computing with DryadLINQ

12

Goal

Page 13: Cluster Computing with DryadLINQ

13

Design Space

ThroughputLatency

Internet

Privatedata

center

Data-parallel

Sharedmemory

DryadSearch

HPC

Grid

Transaction

Page 14: Cluster Computing with DryadLINQ

14

Data Partitioning

RAM

DATA

DATA

Page 15: Cluster Computing with DryadLINQ

15

2-D Piping• Unix Pipes: 1-D

grep | sed | sort | awk | perl

• Dryad: 2-D grep1000 | sed500 | sort1000 | awk500 | perl50

Page 16: Cluster Computing with DryadLINQ

16

Virtualized 2-D Pipelines

Page 17: Cluster Computing with DryadLINQ

17

Virtualized 2-D Pipelines

Page 18: Cluster Computing with DryadLINQ

18

Virtualized 2-D Pipelines

Page 19: Cluster Computing with DryadLINQ

19

Virtualized 2-D Pipelines

Page 20: Cluster Computing with DryadLINQ

20

Virtualized 2-D Pipelines• 2D DAG• multi-machine• virtualized

Page 21: Cluster Computing with DryadLINQ

21

Dryad Job Structure

grep

sed

sortawk

perlgrep

grepsed

sort

sort

awk

Inputfiles

Vertices (processes)

Outputfiles

ChannelsStage

Page 22: Cluster Computing with DryadLINQ

22

Channels

X

M

Items

Finite streams of items

• distributed filesystem files (persistent)• SMB/NTFS files (temporary)• TCP pipes (inter-machine)• memory FIFOs (intra-machine)

Page 23: Cluster Computing with DryadLINQ

23

Dryad System Architecture

Files, TCP, FIFO, Networkjob schedule

data plane

control plane

NS PD PDPD

V V V

Job manager cluster

Page 24: Cluster Computing with DryadLINQ

Fault Tolerance

Page 25: Cluster Computing with DryadLINQ

25

Policy Managers

R R

X X X X

Stage RR R

Stage X

Job Manager

R managerX ManagerR-X

Manager

Connection R-X

Page 26: Cluster Computing with DryadLINQ

26

• Introduction• Dryad • DryadLINQ• DryadLINQ Applications

Outline

Page 27: Cluster Computing with DryadLINQ

27

LINQ

Dryad

=> DryadLINQ

Page 28: Cluster Computing with DryadLINQ

28

LINQ = .Net+ Queries

Collection<T> collection;bool IsLegal(Key);string Hash(Key);

var results = from c in collection where IsLegal(c.key) select new { Hash(c.key), c.value};

Page 29: Cluster Computing with DryadLINQ

29

LINQ System ArchitectureLocal machine

.Netprogram(C#, VB, F#, etc)

LINQProvider

Execution engine

Query

Objects

•LINQ-to-obj•PLINQ•LINQ-to-SQL•LINQ-to-WS•DryadLINQ•Fickr•Oracle•LINQ-to-XML•Your own

Page 30: Cluster Computing with DryadLINQ

30

Collection<T> collection;bool IsLegal(Key k);string Hash(Key);

var results = from c in collection where IsLegal(c.key) select new { Hash(c.key), c.value};

DryadLINQ = LINQ + Dryad

C#

collection

results

C# C# C#

Vertexcode

Queryplan(Dryad job)Data

Page 31: Cluster Computing with DryadLINQ

31

DryadLINQ Data Model

Partition

Collection

.Net objects

Page 32: Cluster Computing with DryadLINQ

The DryadLINQ Provider

32

DryadLINQClient machine

(11)

Distributedquery plan

.Net

Query Expr

Data center

Output TablesResults

Input TablesInvoke Query

Output DryadTable

Dryad Execution

.Net Objects

Dryad JM

ToCollection

foreach

Vertexcode

Page 33: Cluster Computing with DryadLINQ

33

Demo

Page 34: Cluster Computing with DryadLINQ

34

Example: Histogrampublic static IQueryable<Pair> Histogram( IQueryable<LineRecord> input, int k){ var words = input.SelectMany(x => x.line.Split(' ')); var groups = words.GroupBy(x => x); var counts = groups.Select(x => new Pair(x.Key, x.Count())); var ordered = counts.OrderByDescending(x => x.count); var top = ordered.Take(k); return top;}

“A line of words of wisdom”

[“A”, “line”, “of”, “words”, “of”, “wisdom”]

[[“A”], [“line”], [“of”, “of”], [“words”], [“wisdom”]]

[ {“A”, 1}, {“line”, 1}, {“of”, 2}, {“words”, 1}, {“wisdom”, 1}]

[{“of”, 2}, {“A”, 1}, {“line”, 1}, {“words”, 1}, {“wisdom”, 1}]

[{“of”, 2}, {“A”, 1}, {“line”, 1}]

Page 35: Cluster Computing with DryadLINQ

35

Histogram PlanSelectMany

SortGroupBy+SelectHashDistribute

MergeSortGroupBy

SelectSortTake

MergeSortTake

Page 36: Cluster Computing with DryadLINQ

36

Map-Reduce in DryadLINQ

public static IQueryable<S> MapReduce<T,M,K,S>( this IQueryable<T> input, Expression<Func<T, IEnumerable<M>>> mapper, Expression<Func<M,K>> keySelector, Expression<Func<IGrouping<K,M>,S>> reducer) { var map = input.SelectMany(mapper); var group = map.GroupBy(keySelector); var result = group.Select(reducer); return result;}

Page 37: Cluster Computing with DryadLINQ

37

Map-Reduce Plan

M

R

G

M

Q

G1

R

D

MS

G2

R

static dynamic

X

X

M

Q

G1

R

D

MS

G2

R

X

M

Q

G1

R

D

MS

G2

R

X

M

Q

G1

R

D

M

Q

G1

R

D

MS

G2

R

X

M

Q

G1

R

D

MS

G2

R

X

M

Q

G1

R

D

MS

G2

R

MS

G2

R

map

sort

groupby

reduce

distribute

mergesort

groupby

reduce

mergesort

groupby

reduce

consumer

map

parti

al a

ggre

gatio

nre

duce

S S S S

A A A

S S

T

dynamic

Page 38: Cluster Computing with DryadLINQ

38

Distributed Sorting in DryadLINQ

public static IQueryable<TSource>DSort<TSource, TKey>(this IQueryable<TSource> source,                                  Expression<Func<TSource, TKey>> keySelector,                                  int pcount){            var samples = source.Apply(x => Sampling(x));            var keys = samples.Apply(x => ComputeKeys(x, pcount));            var parts = source.RangePartition(keySelector, keys);            return parts.OrderBy(keySelector);}

Page 39: Cluster Computing with DryadLINQ

39

Distributed Sorting Plan

O

DS

H

D

M

S

DS

H

D

M

S

DS

D

DS

H

D

M

S

DS

D

M

S

M

S

static dynamic dynamic

Page 40: Cluster Computing with DryadLINQ

40

Language Summary

WhereSelectGroupByOrderByAggregateJoinApplyMaterialize

Page 41: Cluster Computing with DryadLINQ

41

Combining Query Providers

PLINQ

Local machine

.Netprogram(C#, VB, F#, etc)

LINQProvider

Execution engines

Query

Objects

SQL Server

DryadLINQ

LINQProvider

LINQProvider

LINQProvider

LINQ-to-obj

Page 42: Cluster Computing with DryadLINQ

42

Using PLINQQuery

DryadLINQ

PLINQ

Local query

Page 43: Cluster Computing with DryadLINQ

43

LINQ to SQL

Using LINQ to SQL Server

Query

DryadLINQ

Query Query Query Query Query

LINQ to SQL

Page 44: Cluster Computing with DryadLINQ

44

Using LINQ-to-objects

Query

DryadLINQ

Local machine

Cluster

LINQ to obj

debug

production

Page 45: Cluster Computing with DryadLINQ

45

• Introduction• Dryad • DryadLINQ• DryadLINQ Applications

Outline

Page 46: Cluster Computing with DryadLINQ

46

Sample applications written using DryadLINQ Class

Distributed linear algebra Numerical

Accelerated Page-Rank computation Web graph

Privacy-preserving query language Data mining

Expectation maximization for a mixture of Gaussians Clustering

K-means Clustering

Linear regression Statistics

Probabilistic Index Maps Image processing

Principal component analysis Data mining

Probabilistic Latent Semantic Indexing Data mining

Performance analysis and visualization Debugging

Road network shortest-path preprocessing Graph

Botnet detection Data mining

Epitome computation Image processing

Neural network training Statistics

Parallel statistical algorithms Statistics

Distributed query caching Optimization

Web indexing structure Web graph

Page 47: Cluster Computing with DryadLINQ

47

Linear Algebra & Machine Learning in DryadLINQ

Dryad

DryadLINQ

Large Vector

Machine learningData analysis

Page 48: Cluster Computing with DryadLINQ

48

Operations on Large Vectors: Map 1

U

T

T Uf

f

f preserves partitioning

Page 49: Cluster Computing with DryadLINQ

49

V

Map 2 (Pairwise)

T Uf

V

U

T

f

Page 50: Cluster Computing with DryadLINQ

50

Map 3 (Vector-Scalar)T U

fV

V

50

U

T

f

Page 51: Cluster Computing with DryadLINQ

Reduce (Fold)

51

U UU

U

f

f f f

fU U U

U

Page 52: Cluster Computing with DryadLINQ

52

Linear Algebra

T U Vnmm ,,=, ,

T

Page 53: Cluster Computing with DryadLINQ

53

Linear Regression

• Data

• Find

• S.t.

mt

nt yx ,

mnA

tt yAx

},...,1{ nt

Page 54: Cluster Computing with DryadLINQ

54

Analytic Solution

X×XT X×XT X×XT Y×XT Y×XT Y×XT

Σ

X[0] X[1] X[2] Y[0] Y[1] Y[2]

Σ

[ ]-1

*

A

1))(( Ttt t

Ttt t xxxyA

Map

Reduce

Page 55: Cluster Computing with DryadLINQ

55

Linear Regression Code

Vectors x = input(0), y = input(1);Matrices xx = x.Map(x, (a,b) => a.OuterProd(b));OneMatrix xxs = xx.Sum();Matrices yx = y.Map(x, (a,b) => a.OuterProd(b));OneMatrix yxs = yx.Sum();OneMatrix xxinv = xxs.Map(a => a.Inverse());OneMatrix A = yxs.Map(xxinv, (a, b) => a.Mult(b));

1))(( Ttt t

Ttt t xxxyA

Page 56: Cluster Computing with DryadLINQ

Expectation Maximization (Gaussians)

56

• 160 lines • 3 iterations shown

Page 57: Cluster Computing with DryadLINQ

57

Probabilistic Index MapsImages

features

Page 58: Cluster Computing with DryadLINQ

Conclusions

58

Visual Studio

LINQ

Dryad

58

=

Page 59: Cluster Computing with DryadLINQ

59

Backup Slides

Page 60: Cluster Computing with DryadLINQ

60

Data-Parallel Computation

Storage

Execution

Application

Parallel Databases

Map-Reduce

GFSBigTable

CosmosNTFS

Dryad

DryadLINQScope,PSQL

Sawzall, Pig

Page 61: Cluster Computing with DryadLINQ

61

Dryad = Execution Layer

Job (application)

Dryad

Cluster

Pipeline

Shell

Machine≈

Page 62: Cluster Computing with DryadLINQ

62

DryadLINQ• Declarative programming • Integration with Visual Studio• Integration with .Net• Type safety• Automatic serialization• Job graph optimizations static dynamic

• Conciseness

Page 63: Cluster Computing with DryadLINQ

X[0] X[1] X[3] X[2] X’[2]

Completed vertices Slow vertex

Duplicatevertex

Dynamic Graph Rewriting

Duplication Policy = f(running times, data volumes)

Page 64: Cluster Computing with DryadLINQ

64

S S S S

A A A

S S

T

S S S S S S

T

# 1 # 2 # 1 # 3 # 3 # 2

# 3# 2# 1

static

dynamic

rack #

Dynamic Aggregation

Page 65: Cluster Computing with DryadLINQ

TT[0-?) [?-100)

Range-Distribution Manager

S

D D D

S S

S S S

Tstatic

dynamic65

Hist

[0-30),[30-100)

[30-100)[0-30)

[0-100)

Page 66: Cluster Computing with DryadLINQ

66

Goal: Declarative Programming

X

T

S

X X

S S

T T T

X

static dynamic

Page 67: Cluster Computing with DryadLINQ

JM code

vertex code

Staging1. Build

2. Send .exe

3. Start JM

5. Generate graph

7. Serializevertices

8. MonitorVertex execution

4. Querycluster resources

Cluster services6. Initialize vertices

Page 68: Cluster Computing with DryadLINQ

68

“What’s the point if I can’t have it?”

• Glad you asked• We’re opening Dryad+DryadLINQ to

a few academic partners• Expect an official announcement soon• Please talk to us if you are interested• Most likely not open-source (for now)