Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Mesos Frameworkの作り方 (How to Make Mesos Framework)
Search
UENISHI Kota
August 04, 2016
Technology
7
2.3k
Mesos Frameworkの作り方 (How to Make Mesos Framework)
Mesos勉強会
http://connpass.com/event/36415/
で発表したスライドです
UENISHI Kota
August 04, 2016
Tweet
Share
More Decks by UENISHI Kota
See All by UENISHI Kota
Metadata Management in Distributed File Systems
kuenishi
2
480
Behind The Scenes: Cloud Native Storage System for AI
kuenishi
2
360
Apache Ozone behind Simulation and AI Industries
kuenishi
0
330
Distributed Deep Learning with Chainer and Hadoop
kuenishi
3
1.2k
A Few Ways to Accelerate Deep Learning
kuenishi
0
1k
Introducing Retz
kuenishi
5
1.1k
Introducing Retz and how to develop practical frameworks
kuenishi
3
700
Formalization and Proof of Distributed Systems (ja)
kuenishi
10
6.3k
分散スケジューラMesosの紹介
kuenishi
2
1.4k
Other Decks in Technology
See All in Technology
PHPで印刷所に入稿できる名札データを作る / Generating Print-Ready Name Tag Data with PHP
tomzoh
0
180
明日からできる!技術的負債の返済を加速するための実践ガイド~『ホットペッパービューティー』の事例をもとに~
recruitengineers
PRO
3
550
脳波を用いた嗜好マッチングシステム
hokkey621
0
240
分解して理解する Aspire
nenonaninu
2
510
エンジニアリング価値を黒字化する バリューベース戦略を用いた 技術戦略策定の道のり
kzkmaeda
4
970
Apache Iceberg Case Study in LY Corporation
lycorptech_jp
PRO
0
200
コンテナサプライチェーンセキュリティ
kyohmizu
1
120
Visualize, Visualize, Visualize and rclone
tomoaki0705
9
72k
データマネジメントのトレードオフに立ち向かう
ikkimiyazaki
6
1.2k
エンジニアが加速させるプロダクトディスカバリー 〜最速で価値ある機能を見つける方法〜 / product discovery accelerated by engineers
rince
4
500
Two Blades, One Journey: Engineering While Managing
ohbarye
2
490
オブザーバビリティの観点でみるAWS / AWS from observability perspective
ymotongpoo
9
1.7k
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
22
1.4k
Rails Girls Zürich Keynote
gr2m
94
13k
We Have a Design System, Now What?
morganepeng
51
7.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
Unsuck your backbone
ammeep
669
57k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
YesSQL, Process and Tooling at Scale
rocio
172
14k
Building a Scalable Design System with Sketch
lauravandoore
461
33k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Transcript
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
Mesos Framework の作り⽅ Mesos勉強会 2016/8/4 株式会社ノーチラス・テクノロジーズ http://www.nautilus-technologies.com/ mailto:
[email protected]
Tel: 03-6712-0636 Fax: 03-6712-0664
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
2 ノーチラス・テクノロジーズ ▪会社紹介をなんか書く ▪Asakusa Frameworkという業務バッチ向けのDSLコンパイラを OSSで開発・提供しています ▪他にもいろいろ開発・提供しようとしています ▪コンパイラに詳しい⼈、データベースに詳しい⼈、分散システムに 詳しい⼈、業務に詳しい⼈、Javaに詳しい⼈などがいます
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
3 Apache Mesos: distributed systems kernel Mesosって何? 分散システムのカーネルだよ! Mesos は Linux カーネルと同じ原則で設計、開発されています。違うのは抽象化されているレベルだけです。 Mesos カーネルはあらゆるマシン上で動作し、 Hadoop, Spark, Kafka, Elastic Search といったアプリケーションに APIを通じて、データセンタ丸ごと、クラウド環境まるごとの上にリソース管理とスケジューリングを提供します。
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
4 カーネルだけでは何もできないよね! ▪⽤途に応じて好きなアプリケーションを作っていいんです ▪他の⼈が作ったライブラリ(フレームワーク)を使うもよし Linux Apache Mesos Userland Program Mesos Framework POSIX API Mesos API Computer Computers CPU scheduling, Memory allocation Etc…
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
5 Apache Mesosは何をしてくれるの? ▪リソース管理 – 管理下の全てのマシンがどのような計算資源を持っているかを把握 ▪ ⾃動認識 and ⼿動で指定 – 各種計算資源の抽象化、数字化 ▪ e.g., CPU=24, mem=128gb, disk=1024gb, gpu=4, … – 管理下のマシン(=計算資源)の死活監視 ▪スケジューリング – アプリケーションに計算資源を割り当てる (Offer) – アプリケーションが利⽤を宣⾔(Accept)した計算資源上でタスクを起動 – タスクのざっくりとした状態監視、成否の通知(Status update)
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
6 Mesosのプロセス構成 Master Agent Executor Executor Executor Executor Agent Executor Executor Executor Executor Agent Executor Executor Executor Executor •…....... Framework Scheduler C Framework Scheduler B Framework Scheduler A
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
7 タスク起動の仕組み Master Agent Executor Agent Executor Framework Scheduler 1. Resource Offer 2. Accept Offer 3. Launch Task 4. Fork & Exec 4. Fork & Exec 5. Status Update 5. Status Update •Executorは daemon でもOK •Executorは ただのコマンドでもOK •Executorは Docker イメージでもOK •Framework SchedulerはMarathonで管理
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
8 Mesos API Master Agent Executor Agent Executor Framework Scheduler 1. Resource Offer 2. Accept Offer 3. Launch Task 4. Fork & Exec 4. Fork & Exec 5. Status Update 5. Status Update Scheduler Driver API Executor Driver API Executor API Scheduler API
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
9
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
10 Spark YARN ▪基幹業務システム向けのモデリング⾔語、DSLとコンパイラなどの 開発環境 ▪基幹バッチ処理に必要なテスト・実⾏環境・運⽤環境 ▪各種データベース、データ形式のドライバも同梱 ▪各種分散処理システム、DAGエンジンに(順次)対応 n MapReduce, Spark 向けコードをAsakusaのコンパイラが⾃動⽣成・最適化 •データモデル定義 •外部システム連携 •Asakusa DSL •Operator DSL •自動テスト •バッチ実行ツール •Flow DSL •Batch DSL • MapReduce •コンパイラ •DMDL •DMDL •コンパイラ •TestDriver •ThunderGate •WindGate •Direct I/O •YAESS •EXCEL •テンプレート •実行エンジン •スモールジョブ 実行エンジン Apache Hadoop CDH MapR HDP Amazon EMR M3BP コンパイラ Asakusa: 基幹業務向けバッチ開発フレームワーク •Spark •コンパイラ
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
11 コードを変更せずにエンジンをを切り替える クラウド 分散環境 分散処理フレームワーク 商用ディストリビューション シングルノード 並列環境 並列処理 フレームワーク &実行基盤 M3BP クラウドサービス Amazon EMR Azure HDInsight データフロー DSL / コンパイラ インフラ ストラクチャ 並列・分散処理 ミドルウェア 開発 フレームワーク リファレンス実装 オンプレミス ユースケースに合わせて必要な性能特性を持ったエンジンを利用する
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
12
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
13 スケジューラがない! ▪リソーススケジューラ(ジョブスケジューラ)がないとリソース利 ⽤率が上がらない≒常に余剰リソースを抱えることになる ▪Jenkins – お、おぅ… ▪YARN – よくも悪くもHadoop系プロダクトがプライマリターゲット ▪Mesos – 完成度が⾼い、⾃由度も⾼い – エコシステムも発達 – ⾃分でスケジューラ作らないといけない
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
14 Frameworkを作ろう! ▪Frameworkを作らないとMesosを使いきったとはいえない ▪Scheduler クラスを継承してコールバックを実装 ▪Scheduler driverを叩いて命令を伝える ▪Executor クラスを継承してコールバックを実装 ▪Executor driverを叩いて命令を伝える ▪うごかす
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
15 Frameworkできたよ! ▪Retz (れつ) ▪ロゴは仮です(15分で作った) ▪いわゆる「ジョブキュー」 ▪ジョブを渡す→リソースが空いたら順番に実⾏してくれる
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
16 RetzScheduler.java import org.apache.mesos.Scheduler; import org.apache.mesos.SchedulerDriver; class RetzScheduler implements Scheduler { .. @Override public void resourceOffers( SchedulerDriver driver, List<Protos.Offer> offers) { .. // ジョブをノードに割り当てる .. driver.acceptOffers(offerIds, operations, filters); } .. } Mesos Scheduler Driver RetzScheduler Resource offer as Callback Driver call Assigned jobs as tasks JobQueue Fetch jobs
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
17 Protos.Offer ▪どこかの1台のMesos Agentが提供可能なリソース⼀覧 ▪Slave – Slave IDなど ▪Resources – CPU, メモリ, ディスク, ポート番号などAgentで設定したリソースがリ ストになっている – “ public int getCPU() “ などという⽢いメソッドはない ▪IDEの補完で雰囲気を掴もう! ▪データ構造は公式ドキュメントにJSONで掲載(Scheduler API, Executor API, Operator API)のところ
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
18 スケジューラーの起動と停⽌ ▪Driverを new, stop するだけ import org.apache.mesos.MesosSchedulerDriver; import org.apache.mesos.Protos; .. .. Protos.FrameworkInfo fw = buildFrameworkInfo(conf); RetzScheduler scheduler = new RetzScheduler(conf, fw); MesosSchedulerDriver driver = new MesosSchedulerDriver(scheduler, fw, “mesos-master:5050”); driver.start(); driver.join(); .. // ⽌めたいときは driver.stop()
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
19 RetzExecutor.java import org.apache.mesos.Executor; import org.apache.mesos.ExecutorDriver; class RetzExecutor implements Executor{ .. @Override public void launchTask( ExecutorDriver driver, Protos.TaskInfo task) { driver.sendStatusUpdate(taskStartStatus); .. // タスクを同期的に実⾏ driver.sendStatusUpdate(taskEndStatus); } .. } Mesos Executor Driver Executor Job Info as Callback Report task status LocalProcessManager Fork/exec jobs
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
20 やりたいこと ▪Mesos v1 API に対応(先週やっとリリースされてん…) ▪NUMA awareness ▪GPU対応? ▪High Availability ▪DC/OS対応 ▪ジョブの実⾏結果保存
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
21 QUESTIONS?
Copyright © 2016 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
22 内容 (30min) 1. 会社紹介 2. Mesosは スケジューラとリソース管理を分離 (Resource Offer) 1. Scheduler is 何 / リソース管理 is 何 3. ⽤途に合わせてスケジューラを個別に作る 4. Asakusa Frameworkのスケジューラの歴史 … エンジンに依存し ていた 1. MapReduce … JobTracker 2. Spark … YARN 3. M3BP … ??? ▪ Retz: 作りたくないけど作るしかないか… – NUMA awareness / mesos-execute ではダメなのか? ▪ 極めて簡単なジョブキューです ▪ Roadmap: YARN / 各種コンテナ / GPGPU /