Rakuten tech conf

15
Jrubyで実現する 分散並列処理フレームワーク Hadoop Papyrus and more... 2010/10/16 楽天テクノロジーカンファレンス2010 日本JRubyユーザ会/ハピルス株式会社 藤川幸一 FUJIKAWA Koichi @fujibee

description

Rakuten Technology Conference 2010

Transcript of Rakuten tech conf

Page 1: Rakuten tech conf

Jrubyで実現する分散並列処理フレームワーク

Hadoop Papyrusand more...

2010/10/16楽天テクノロジーカンファレンス2010

日本JRubyユーザ会/ハピルス株式会社藤川幸一 FUJIKAWA Koichi @fujibee

Page 2: Rakuten tech conf

JRubyユーザ会

・2010年5月に設立・Jrubyユーザの交流の場として、勉強会などを 行っている・第0回 設立準備会・第1回 Google AppEngine with JRuby

・第2回 JRubyユーザ会 in RubyKaigi2010

・第3回 <今ココ>・参加希望はML(Google Group)へ登録! http://groups.google.com/group/jruby-users-jp

Page 3: Rakuten tech conf

Hadoop Papyrus

Page 4: Rakuten tech conf

Hadoopとは?

大規模データ並列分散処理フレームワークGoogle MapReduceのオープンソースクローンテラバイトレベルのデータ処理に必要

標準的なHDDがRead 50MB/sとして400TB(Webスケール)のReadだけで2000時間

分散ファイルシステムと分散処理フレームワークが必要

Page 5: Rakuten tech conf

Hadoop Papyrus

HadoopジョブをRubyのDSLで実行できるオープンソースフレームワーク

本来HadoopジョブはJavaで記述する Javaだと複雑な記述がほんの数行で書ける

IPA未踏本体2009年上期のサポートHudson上でジョブを記述/実行が可能

Page 6: Rakuten tech conf

Step.1JavaではなくRubyで記述

Page 7: Rakuten tech conf

Step.2RubyによるDSLでMapReduceをシンプルに

Map Reduce JobDescription

Log AnalysisDSL

Page 8: Rakuten tech conf

Step.3Hadoopサーバ構成を容易に利用可能に

Page 9: Rakuten tech conf

package org.apache.hadoop.examples;

import java.io.IOException;import java.util.StringTokenizer;

import org.apache.hadoop.conf.Configuration ;import org.apache.hadoop.fs.Path ;import org.apache.hadoop.io.IntWritable ;import org.apache.hadoop.io.Text ;import org.apache.hadoop.mapreduce.Job ;import org.apache.hadoop.mapreduce.Mapper ;import org.apache.hadoop.mapreduce.Reducer ;import org.apache.hadoop.mapreduce.lib.input.FileInputFormat ;import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat ;import org.apache.hadoop.util.GenericOptionsParser ;

public class WordCount {

public static class TokenizerMapper extendsMapper<Object, Text, Text, IntWritable> {

private final static IntWritable one = new IntWritable(1);private Text word = new Text();

public void map(Object key, Text value, Context context)throws IOException, InterruptedException {StringTokenizer itr = new StringTokenizer(value.toString());while (itr.hasMoreTokens()) {word.set(itr.nextToken());context.write(word, one);}}}

public static class IntSumReducer extendsReducer<Text, IntWritable, Text, IntWritable> {private IntWritable result = new IntWritable();

public void reduce(Text key, Iterable<IntWritable> values,Context context) throws IOException, InterruptedException {int sum = 0;for (IntWritable val : values) {sum += val.get();}result.set(sum);context.write(key, result);}}

public static void main(String[] args) throws Exception {Configuration conf = new Configuration();String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();if (otherArgs.length != 2) {System.err.println("Usage: wordcount <in> <out>");System.exit(2);}Job job = new Job(conf, "word count");job.setJarByClass(WordCount.class);job.setMapperClass(TokenizerMapper.class);job.setCombinerClass(IntSumReducer.class);job.setReducerClass(IntSumReducer.class);job.setOutputKeyClass(Text.class);job.setOutputValueClass(IntWritable.class);FileInputFormat.addInputPath(job, new Path(otherArgs[0]));FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));System.exit(job.waitForCompletion(true) ? 0 : 1);}}

同様な処理がJavaでは70行必要だが、HadoopPapyrusだと10行に!

dsl 'LogAnalysis‘

from ‘test/in‘to ‘test/out’

pattern /\[\[([^|\]:]+)[^\]:]*\]\]/column_name :link

topic "link num", :label => 'n' do count_uniq column[:link]end

Java

Hadoop Papyrus

Page 10: Rakuten tech conf

Javaで書く必要があるMap/Reduce処理内で、JRubyを利用してRubyスクリプトを呼び出す

Hadoop Papyrus 詳細

Page 11: Rakuten tech conf

さらに、処理したい内容(ログ分析など)を記述したDSLを用意しておき、Map処理、Reduce処理でそれぞれ異なる動きをさせることで1枚のDSL記述でMapReduce処理を行うことができる。

Hadoop Papyrus 詳細 (続き)

Page 12: Rakuten tech conf

Hapyrus について

Page 13: Rakuten tech conf

Hapyrus (ハピルス)・HapyrusはHadoop処理などの大量並列分散処理のベストプラクティスを共有・実行するサービス・Amazon EC2上に構築されHadoopをサービスとして利用できる・内部的にJRubyを利用

– HadoopとRuby(RoR利用)の接続として・2010年10月からハピルス株式会社として開発開始・鋭意開発中!・年末にはアルファ版公開予定

ご期待ください!

Page 14: Rakuten tech conf

Client<JRuby>

Client<JRuby>

HadoopJobTracker

<Java>

HadoopJobTracker

<Java>

JRubyでHadoopにアクセス

Hadoop IPC

Hadoop内のオブジェクトデータに直接アクセス可能!

Page 15: Rakuten tech conf

ありがとうございました

Twitter ID: @fujibee