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.4k
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
Storage Systems in Preferred Networks
kuenishi
0
30
Metadata Management in Distributed File Systems
kuenishi
2
510
Behind The Scenes: Cloud Native Storage System for AI
kuenishi
2
400
Apache Ozone behind Simulation and AI Industries
kuenishi
0
370
Distributed Deep Learning with Chainer and Hadoop
kuenishi
3
1.2k
A Few Ways to Accelerate Deep Learning
kuenishi
0
1.1k
Introducing Retz
kuenishi
5
1.1k
Introducing Retz and how to develop practical frameworks
kuenishi
3
730
Formalization and Proof of Distributed Systems (ja)
kuenishi
10
6.4k
Other Decks in Technology
See All in Technology
サイバーエージェントグループのSRE10年の歩みとAI時代の生存戦略
shotatsuge
4
940
[SRE NEXT] ARR150億円_エンジニア140名_27チーム_17プロダクトから始めるSLO.pdf
satos
5
2.6k
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
3
18k
Introduction to Bill One Development Engineer
sansan33
PRO
0
260
助けて! XからWaylandに移行しないと新しいGNOMEが使えなくなっちゃう 2025-07-12
nobutomurata
2
170
データ戦略部門 紹介資料
sansan33
PRO
1
3.3k
第64回コンピュータビジョン勉強会「The PanAf-FGBG Dataset: Understanding the Impact of Backgrounds in Wildlife Behaviour Recognition」
x_ttyszk
0
230
[ JAWS-UG千葉支部 x 彩の国埼玉支部 ]ムダ遣い卒業!FinOpsで始めるAWSコスト最適化の第一歩
sh_fk2
2
150
TLSから見るSREの未来
atpons
2
280
伴走から自律へ: 形式知へと導くSREイネーブリングによる プロダクトチームの信頼性オーナーシップ向上 / SRE NEXT 2025
visional_engineering_and_design
3
260
Delegating the chores of authenticating users to Keycloak
ahus1
0
180
大量配信システムにおけるSLOの実践:「見えない」信頼性をSLOで可視化
plaidtech
PRO
0
350
Featured
See All Featured
Practical Orchestrator
shlominoach
189
11k
The Straight Up "How To Draw Better" Workshop
denniskardys
235
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
How to Ace a Technical Interview
jacobian
278
23k
Code Review Best Practice
trishagee
69
19k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
BBQ
matthewcrist
89
9.7k
Facilitating Awesome Meetings
lara
54
6.5k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
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 /