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
Introducing Retz
Search
UENISHI Kota
September 06, 2017
Technology
1.3k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introducing Retz
Slides in db tech showcase 2017
UENISHI Kota
September 06, 2017
More Decks by UENISHI Kota
See All by UENISHI Kota
Storage Systems in Preferred Networks
kuenishi
0
92
Metadata Management in Distributed File Systems
kuenishi
2
560
Behind The Scenes: Cloud Native Storage System for AI
kuenishi
2
460
Apache Ozone behind Simulation and AI Industries
kuenishi
0
460
Distributed Deep Learning with Chainer and Hadoop
kuenishi
3
1.3k
A Few Ways to Accelerate Deep Learning
kuenishi
0
1.2k
Introducing Retz and how to develop practical frameworks
kuenishi
3
810
Formalization and Proof of Distributed Systems (ja)
kuenishi
10
6.5k
Mesos Frameworkの作り方 (How to Make Mesos Framework)
kuenishi
7
2.4k
Other Decks in Technology
See All in Technology
白金鉱業Meetup_Vol.24_「AIエージェントは分けるほど良い」は本当か? / Is it true that “the more you divide AI agents, the better”?
brainpadpr
1
280
2026 TECHFRESH 畢業分享會 - 開發日常大解密!從領域驅動到企業級上線
line_developers_tw
PRO
0
740
爆速でマルチプロダクトを立ち上げる時 事業・CTO目線で大事にしたい事
miyatakoji
0
100
LLMにもCAP定理があるという話
harukasakihara
0
290
RAG を使わないという選択肢
tatsutaka
1
170
AIの性能が向上しても未解決な組織の重大問題は何か?/An Unsolved Organizational Problem in the Age of AI
moriyuya
3
610
AGENTS.mdとSkillsで始めるAIエージェント活用
sonoda_mj
2
190
Dario Amodi『Policy on the AI Exponential』を理解する
nagatsu
0
210
How Timee Delivers Day 1 Production Ready LLM Features
tomoyks
0
110
スキルと MCP ツール、責務をどう分けるか? AI が迷わないインターフェース設計の戦略
cdataj
1
930
Bucharest Tech Week 2026 - Reinventing testing practices in the AI era
edeandrea
PRO
1
140
JSAI2026 オーガナイズドセッションOS-27「不動産とAI」趣旨説明 / JSAI2026 Organized Session OS-27 “Real Estate and AI”: Statement of Purpose
ykiyota
0
230
Featured
See All Featured
Automating Front-end Workflow
addyosmani
1370
210k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
200
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
280
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
230
Writing Fast Ruby
sferik
630
63k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
720
The Curious Case for Waylosing
cassininazir
1
380
4 Signs Your Business is Dying
shpigford
187
22k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Transcript
Copyright © 2017 Nautilus Technologies, Inc. All rights reserved. NAUTILUS
Introducing Retz 2017/9/6 db tech showcase 2017 Kota Uenishi 株式会社ノーチラス・テクノロジーズ http://www.nautilus-technologies.com/ mailto:
[email protected]
Tel: 03-6712-0636 Fax: 03-6712-0664 Visit https://goo.gl/B7qhtE for online slides
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 2
はじめに ▪これは分散スケジューラMesosの紹介という、dbts 2016での発表 の続編です ▪バッチジョブのよいスケジューラがない問題を解決するRetzという Mesos Frameworkを開発し、OSSとして公開しました ▪Retzの機能と⽬的、事例などを紹介します
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 3
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 © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 4
コードを変更せずにエンジンを切り替える クラウド 分散環境 分散処理フレームワーク 商用ディストリビューション シングルノード 並列環境 並列処理 フレームワーク &実行基盤 M3BP クラウドサービス Amazon EMR Azure HDInsight データフロー DSL / コンパイラ インフラ ストラクチャ 並列・分散処理 ミドルウェア 開発 フレームワーク リファレンス実装 オンプレミス ユースケースに合わせて必要な性能特性を持ったエンジンを利用する
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 5
Asakusa on M3BP開発の背景 ▪単体コンピュータの性能が上がってきた – NUMA時代: RAMは 512GB ~ 2TB – 2ソケット、22コア、HTT が当たり前に ▪ e.g. Xeon E7-8894 v4 は 24コア(48 w/ HTT) – データが全てメモリに乗る規模なら、マルチコアを使いこなせばスケー ルアップでバッチ処理の性能向上が簡単にできる時代に – バスの通信はDC内のネットワーク通信よりも1000倍速い ▪重要なバッチ処理のうち、少なくない割合がビッグデータではない ▪個別対応ではなくフレームワークでの対応が望ましい – アプリケーションを書き換えるのは難しい – Spark local modeはJVM – バスがネックになるレベルだと JVMはGC と reference hellが… – Asakusaならエンジンを付け替えるだけでアプリの変更は不要
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 6
スケジューラがない! ▪リソーススケジューラ(ジョブスケジューラ)がないとリソース利 ⽤率が上がらない≒常に余剰リソースを抱えることになる ▪Jenkins – 柔軟性が⾼くプラグインも豊富 – ジョブキューとしては不⼗分 ▪YARN (Apache Hadoop) – よくも悪くもHadoop系プロダクトがプライマリターゲット ▪Apache Mesos – 完成度が⾼い、⾃由度も⾼い – エコシステムも発達 – ⾃分でスケジューラ作らないといけない
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 7
Apache Mesosは何をしてくれるの? ▪リソース管理 – 管理下の全てのマシンがどのような計算資源を持っているかを把握 ▪ ⾃動認識 and ⼿動で指定 – 各種計算資源の抽象化、数字化 ▪ e.g., CPU=24, mem=128gb, disk=1024gb, gpu=4, … – 管理下のマシン(=計算資源)の死活監視 ▪スケジューリング – アプリケーションに計算資源を割り当てる (Offer) – アプリケーションが利⽤を宣⾔(Accept)した計算資源上でタスクを起動 – タスクのざっくりとした状態監視、成否の通知(Status update)
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 8
タスク起動の仕組み 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 © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 9
Mesos Framework API の基本的な使い⽅ ▪Scheduler Interface でMesosからの通知を受け取る – Offerが来た – タスクが始まった / 終わった / 失敗した – Mesosと切れた – Agentが死んだ ▪Scheduler Driver でMesosにリクエストを送る – Offerを Accept / Decline する – Mesosとの接続を切る Framework Scheduler Driver Scheduler Interface callback
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 10
Retz ( github.com/retz ) ▪いわゆる「ジョブキュー」 ▪ジョブを渡す→リソースが空い たら順番に実⾏してくれる ▪Mesos を使いやすくする – ⾮同期なScheduler APIを独⾃の同期APIに変換 – Mesos API と UI の完全隠蔽を⽬指す – 業務⽤ジョブスケジューラのための実⽤性 ▪機能 – ジョブの登録、削除、⼀覧 – マルチユーザー対応(Mesosのユーザー追加は⼤げさ…) – ジョブ優先制御、カスタムスケジューリング実装のプラグイン – GPUリソース、カスタム attributes 指定 – Dockerコンテナ上での実⾏(Docker Volumesも) – 障害時の⾃動再実⾏
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 11
RetzとMesosの関係 ▪MesosはいわゆるMulti-layer scheduler ▪カーネルとアプリケーション(ライブラリ)の関係に似ている Linux Kernel Apache Mesos Userland Program Mesos Framework Computer Computers CPU scheduling, Memory allocation Etc… Mesos Framework API POSIX API System calls
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 12
Retz の基本的な使い⽅ ▪CUI / ライブラリを使ってAPIを同期的に呼び出す – ジョブ実⾏依頼 – ジョブステータス確認 – ジョブ強制終了 – ジョブ結果取得 User program POST /job GET /job/12 GET /job/12/file
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 13
マルチユーザー ▪Retzに対するアクセス権(クラスタのリソース使⽤権)を正しく管 理することが⽬的 ▪User Name / Access Secret のペアでユーザーを管理 ▪他⼈のジョブの内容や結果などは⾒せない ▪リソース分離をする ▪AWSっぽいAPI 認証 – HTTP Authorizationヘッダを利⽤ – Authorization: Retz-auth-v1 AccessKey:Signature – Signature = Base64( HMAC-SHA1( YourAccessSecret, UTF- 8-Encoding-Of( StringToSign ) ) ); – StringToSign = HTTP-Verb + "\n" + Content-MD5 + "\n" + Date + "\n" + Resource; ▪認可はまだない
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 14
カスタマイズ可能なスケジューリング ▪デフォルトはFIFO – retz.planner.name = fifo ▪優先制御も可能 – ジョブに優先度を指定するフィールドがある – retz.planner.name = priority ▪複雑なスケジューリングアルゴリズムをプラグイン可能 – 実装例: Github.com/retz/retz-random-planner – retz.planner.name = com.example.your.own.MyPlanner – retz.classpath = /opt/path/to/your/classes ▪ビルトインのスケジューリングアルゴリズムを増やしていきたい
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 15
GPUリソース、カスタムリソース ▪NVIDIA GPUはMesosがネイティブ対応 – CLIでは --gpu 2 などとして指定するだけ – ジョブ内では指定した本数しか⾒えなくなる ▪カスタムリソースはMesos AgentにAttributeとして都度定義する – Java API では利⽤可能 – CLIでは未実装 (0.4.0~) – 組み込みのPlannerでは利⽤不可 – カスタムPlannerで利⽤⽅法を⾃前で記述
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 16
障害時の⾃動的な再実⾏ ▪基本的にRetzが⾃動的に再実⾏ – ジョブ実⾏中にMesos Agentが故障した場合 – 実⾏中にMesos Master などが故障した場合 – Retzが故障した場合 ▪ Retzを再起動した時点でジョブの状態確認が⾛る ▪可能な限り⼆重実⾏を防ぐようにしているが、どうしても避けられ ないケースがあるのでアプリ側でも注意が必要 ▪再実⾏されないケース – ジョブが終了したが⾮0を返した場合 – ジョブがOOM等で終了した場合 Master Failure Reschedule
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 17
事例
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 18
Retz@さくらインターネット様 (1/2) ▪データセンターの原価計算システム [1] – ⽣データ 500GB / day – ⽇次で数百ジョブ、⽉次で数百ジョブ ▪ Asakusa on Spark から Asakusa on M3BP に移⾏ – 全てのジョブがインメモリで処理できる程度にコンピュータの性能が向 上してきた – YARNのようなスケジューラーがないのでMesos – いざというときもMesos上でSparkを⾛らせることができる – Sparkだと数⼗分かかるジョブもあった •MapR FS •YARN (Apache Hadoop) •Asakusa on Spark •Jenkins •MapR FS •Retz / Apache Mesos •Asakusa on M3BP •Digdag [1] http://knowledge.sakura.ad.jp/event/3766/
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 19
Retz@さくらインターネット様 (2/2) ▪サーバー台数 – 20台以上 => 5台以下 ▪⼀⽇のジョブ数 – 最⼤で2000程度 ▪ジョブの実⾏待ち時間 – 多くが10~20分程度、中央値約8.2分 ▪ジョブの実⾏時間 – ほとんどが3分以内、中央値15.0秒
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 20
Retz & Mesos @ Preferred Networks ▪社内⽤の実験環境 ▪ハードウェア環境とソフトウェア・パッケージの組み合わせを指定 したDockerの中で実験⽤プログラムを実⾏ ▪Mesos の複雑なAPIを隠蔽してシンプルなジョブスケジューリング をしてくれる ▪耐障害性も担保されていて、タスクが失敗しても、ノードが故障し ても⾃動的にRetzが再実⾏してくれる ▪⾃分たちの環境に合わせた独⾃のPlannerを作ってプラグインして いる ▪Retzに多くのコントリビューションをしてくれています
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 21
最後にひとつ: Retz Digdag Plugin ▪DigdagのワークフローをRetz経由でMesos上で実⾏する – RetzのJavaクライアントでプログラミングしなくてよい – RetzのCLIを覚える必要がない – 結局ワークフローにして運⽤するので ▪こんな感じでワークフローに組み込める +simple_app: retz_run>: /opt/app/simple-app.sh +heavy_batch: retz_run>: /opt/app/heavy-batch.sh ${session_date} cpu: 8 mem: 16g priority: 1 timeout: 30 https://github.com/retz/retz-digdag-plugin
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 22
まとめ ▪バッチジョブスケジューラRetzの機能と事例を紹介 ▪1台のマシンで動くジョブ:バッチ処理サーバーが m:n で沢⼭ある 場合に⾼可⽤にジョブを実⾏できる ▪Asakusa / Spark / Digdag / Mesos の相性が⾮常によい 【宣伝】ノーチラス・テクノロジーズでは • バッチ処理およびHadoopやSparkなど周辺システムのコンサルティ ング、受託開発、運用 • Asakusa Frameworkの開発と運用の商用サポート • RetzおよびApache Mesosの商用サポート などを行っています。お気軽にお問い合わせ下さい
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 23
QUESTIONS?
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 24
APPENDIX
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 25
Roadmap (必要に応じて) ▪⾼可⽤性、耐障害性 ▪Fair scheduling ▪DCOSパッケージ化
Copyright © 2017Nautilus Technologies, Inc. All rights reserved. NAUTILUS 26
Retz & Mesosのプロセス構成 Master Agent Executor Executor Executor Executor Agent Executor Executor Executor Executor Agent Executor Executor Executor Executor •…....... Framework Scheduler (Marathon) Retz ZooKeeper ZooKeeper ZooKeeper