2.
Most of our systems are big “Future transformers”
- Marius Eriksen
3.
predictable performance is difficult to achieve. In a predictable system,
worst-case performance is crucial; average performance not so much.
... predictable performance is difficult to achieve.
In a predictable system, worst-case performance
is crucial; average performance not so much.
- Peter Schuller
4.
predictable performance is difficult to achieve. In a predictable system,
worst-case performance is crucial; average performance not so much.
It’s with the intent of modeling a world where the
Twitters, Googles, and Facebooks are no longer
superpowers… just power
- Aurora
22.
計算処理を関数と考える
処理
関数 f
入力 出力
関数の引数 x 関数の返り値 y
y = f(x)
引数の型がAで、その返り値の型がBなら、この処理は
次のような型を持つ関数 f で定義される。
def f(x:A):B
23.
シーケンシャルな処理
処理1
入力 出力
二つの処理 fとgが、シーケンシャルに連続して行われる時、
その処理 h は、関数 f と関数 gの合成になる。これを、
h = g ・ f と表す。
処理2
入力 出力
関数 f
引数 x
返り値
f(x)
関数 g
引数 返り値 y
y = h(x) = g(f(x))
関数 h
24.
シーケンシャルな処理
処理1
入力 出力
シーケンシャルな処理が、f1, f2, ... , fn と連続して行われる時、
その処理 h は、h = fn ・ ... ・ f2 ・ f1 と表わすことができる。。
処理2
入力 出力
y = h(x) = fn(・・・ (f2(f1(x))・・・)
関数 h
処理n
出力
・・・
f1 f2 fn・・・
引数 x 返り値 y
25.
シーケンシャルな処理の特徴
h = fn ・ ... ・ f2 ・ f1
関数の合成で、シーケンシャルな処理が記述できたのだ
が、それだけではシーケンシャルな処理の特徴を捉えたこ
とにはならない。そこには、次のような問題がある。
f1の処理が終わるまで、f2の処理は待たされる。
f2の処理が終わるまで、f3の処理は待たされる。
・・・
fnの処理は、それ以前のすべての処理が終わるまで待た
される。
h = fn ・ ... ・ fi ・ ... ・ f2 ・ f1
待たされるだけではない。途中の処理 fi の一つでも失敗
すれば、その時点で、全体の処理 h は、失敗する。
待つことや、エラーの処理に、うまい方法はないのだろう
か?
26.
出力に時間がかかる場合
f
f
入力 出力
入力 出力がない! 待機!
出力がすぐ返ればいいのだが、処理に時間がかかる
場合には、出力がない状態が生まれる。
27.
非同期処理
f
g
入力 出力がない状態
入力 出力
こうした場合には、出力がない状態で待機せずに、別の
処理に制御を写すのが好ましい。f は、呼び出されると、
出力の有無にかかわらず、すぐに制御を返すのがいい。
非同期処理である。ただ、それには、仕掛けが必要である。
別の処理 g
待機せずに、別の処理に
制御を移す。
30.
Futureと関数の非同期化
f
g
入力
入力
別の処理 g
Futureが返ったら、別の
処理にただちに、制御を移す。
Futureが返る
Futureが返る
h
入力
別の処理 h
Futureが返る
Futureが返ったら、別の
処理にただちに、制御を移す。
もし、関数が
Futureを返
すなら、関数
は、非同期に
できる。
非同期型
def f(x:A):Future[B]
同期型
def f(x:A):B
31.
Futuresの値の取得 get
Futureは、ある種のコンテナーである。 trait Future[A]
それは、empty, full, failedの三つの状態を取る。我々
は、それを待つことができる。その値は getで取得できる。
val f: Future[A]
val result = f()
f.get() match {
case Return(res) => ...
case Throw(exc) => ...
}
ただ、いつ get するのか? せっかく非同期にしたのに、
get の利用は、あまり意味がない
42.
回り道
Collectionのmap
こうしたコンビネーターを、おそらく、毎日使っているかもしれ
ない。例えば、collectionに働く “map” は、コンビネーター
である。
val l = Seq(1,2,3,4)
val mult2 = { x => x*2 }
val l2 = l map mult2
// 次の様にも書ける: l map { x => x*2 }
l2 == Seq(2,4,6,8)
76.
filterの例
与えられたrequestとserviceに対して、それを実行するが、
1秒後にタイムアウトする。
val timeout = {
(req, service) => service(req).within(1.second)
}
requestを認証し、それが成功した時にのみ、サービスを実
行する。
val auth = { (req, service) =>
if (isAuth(req))
service(req)
else
Future.exception(AuthErr)
}
77.
Filterは、積み重ねられる。
val timeout: Filter[…]
val auth: Filter[…]
val service: Service[…]
timeout andThen auth andThen service
def andThen[A](g: (R) ⇒ A): (T1) ⇒ A
Composes two instances of Function1 in a new
Function1, with this function applied first.
def compose[A](g: (A) ⇒ T1): (A) ⇒ R
Composes two instances of Function1 in a new
Function1, with this function applied last.
88.
Manhattan, our real-time,
multi-tenant distributed
database for Twitter scale
April 2, 2014 By Peter Schuller,
Core Storage Team
https://blog.twitter.com/2014/manhattan-
our-real-time-multi-tenant-distributed-
database-for-twitter-scale
抄訳
109.
Storage as a service
既存のデータベースで我々が見てきた共通の問題は、そ
れが、ユースケースのある特別な集まりに対して、設定さ
れ管理されるようにデザインされていることだった。
Twitterの新しい内部サービスが成長するにつれ、我々
が認識したのは、そうしたことは、我々のビジネスには効
率的ではないということだった。
我々のソリューシンは、storage as a serviceという
ものだ。我々は、エンジニアと運用者のチームに、エンジ
ニアをコントロールする、完全なセルフサービスのストレー
ジ・システムを構築することによって、大きな生産性の改
善を提供してきた。
110.
Storage as a service
エンジニアは、彼らのアプリケーションが必要とするもの(
ストレージのサイズ、一秒あたりのクエリー等)を与え、ハ
ードウェアがインストールされスキーマが設定されるのを
待つことなしに、瞬時にストレージの利用を開始すること
ができる。
会社内の顧客は、我々の運用チームが管理するマルチ・
テナントな環境で実行する。セルフサービスとマルチ・テナ
ントのクラスターを管理することは、ある種のチャレンジだ
った。それで、我々は、このサービス層を、第一級の特徴
として扱った。
111.
Storage as a service
我々は顧客に、データと処理を、見える形で提供した。
quotaの機能強化とrate制限を組み込んで、エンジニア
が、彼らの定義された制限を超えた時には警告を受け取る
ようにした。我々のすべての情報は、分析と報告のため
Capacity and Fleet Managementチームに、直接送ら
れる。
エンジニアが新しい特徴をローンチすることを容易にするこ
とで、我々が見たのは、実験が活発に立ち上がり、新しい
ユースケースが急速に増えたということだった。これらをう
まくハンドルするために、これらのデータを、コスト分析に
結びつける内部のAPIを開発した。これによって、どのユー
スケースが最もビジネスにコストをかけ、また、どのユース
ケースがおきそうもないかを決定することができた。
137.
import sys
import time
def main(argv):
SLEEP_DELAY = 10
# Python ninjas - ignore this blatant bug.
for i in xrange(100):
print("Hello world! The time is now: %s. Sleeping for %d secs" % (
time.asctime(), SLEEP_DELAY))
sys.stdout.flush()
time.sleep(SLEEP_DELAY)
if __name__ == "__main__":
main(sys.argv)
hello_world.py
166.
The Mesosphere Datacenter
Operating System
「自分のデータセンターやクラウドを、Mesosphere
データセンター・オペレーティング・システムで、自動
運転させる。時間とお金を節約して、ソフトウェアはよ
り早く配布する。」
https://mesosphere.com/
167.
A New Kind of Operating
System
Mesosphere データセンター・オペレーティング・システ
ム (DCOS)は、新しい種類のオペレーティング・システム
である。それは、物理サーバー、クラウド・ベースのデータ
センターのサーバーをまたいで、その上で、あらゆるバー
ジョンのLinuxが走る。
Killer Apps User Interface Programmable
Datacenter
174.
PaaS and
Long Running Big data processing Batch scheduling Data storage
“Framework on Mesos” https://goo.gl/1oDvTc
175.
Mesos利用の拡大
-- Mesosphere Blog タイトルから --
The Mesosphere Datacenter Operating System
is now generally available
Get Mesos-DNS up and running in under 5
minutes using Docker
Building real-time data flows with Kafka on
Mesos
Cassandra on Mesos: Performance +
Reliability
Deploying Kubernetes on Mesos
It’s easier than ever to scale like Google
without being Google
https://mesosphere.com/blog/
176.
Mesos利用の拡大
-- Mesoshere Blog タイトルから --
Launching thousands of Docker containers
with DCOS on Azure
Join the DCOS public beta on Microsoft Azure
and AWS
Apple details how it rebuilt Siri on Mesos
Making Kubernetes a first-class citizen on the
DCOS
MySQL on Mesos: today’s database meets
tomorrow’s datacenter
https://mesosphere.com/blog/
177.
“Mesosphereは、Googleスケールの計算能力を万
人にもたらす。”
Abdur Chowdhury, Former Chief Scientist, Twitter
“Mesosphereは、クラウド・コンピューティングの避
けられない運命だ。”
Brad Silverberg, Fuel Capital
“Mesosphereは、開発者にとってのブレークスルー
だ。数千のDropletでさえ、一つのコンピュータのよう
に管理するその能力は、とてもエキサイティングなも
のだ。”
Ben Uretsky, CEO and Co-founder of DigitalOcean
179.
MesosとBorg
Mesosは、GoogleのBorgにインスパイアされて生まれ
た、オープンソース・プロジェクトである。
Borgは、以前から、その存在は知られていたが、GFS,
MapReduce, BigTable とは異なって、その技術的詳細
をGoogleが明かすことはなかった。Borgは、Googleの
大規模分散の中核技術であり、ある人は、それを「
Googleの秘密兵器」「Googleの急速な進化の、もっとも
よく保たれた秘密」と呼んでいた。
“Return of the Borg: How Twitter Rebuilt Google‘s
Secret Weapon”http://goo.gl/QyhGjx
"Twitter’s Aurora and How it Relates to Google’s Borg
(Part 1)"http://goo.gl/BRhL7x
180.
Google, Borgの情報公開
今年の4月、Googleは、Borgの情報を初めて公開した。
“Large-scale cluster management at Google
with Borg” https://goo.gl/aN03bI
この発表に対して、Auroraのアーキテクトのコメントを含
む記事が、出ている。“Google Lifts the Veil on
Borg, Revealing Apache Aurora’s
Heritage”http://goo.gl/Nv8ZIQ
僕には謎だったBorgの名前の由来だが、それは、Star Trekに
登場する「宇宙種族のひとつ。蜂や蟻をモチーフにした社会的集
合意識を持っているとされ、中央制御装置としてのQueenがいる
」とのこと。Facebookで友人から教えてもらった。納得。
181.
Google Borg
Google’s Borg system
is a cluster manager
that runs hundreds of
thousands of jobs,
from many thousands
of different applications,
across a number of
clusters each with up
to tens of thousands of
machines
数十万のジョブ
数千のアプリケーション
数万のマシン
212.
Scheduler
resourceOffers
(あるいは、フレームワークが、すでにこれらのリソース
を使ってタスクを起動していたとすれば、これらのタス
クは、TASK_LOSTの状態で失敗するだろう。メッセー
ジを見て欲しい)
def resourceOffers(
driver: SchedulerDriver, offers: JList[Offer]): Unit = {
log.info("Scheduler.resourceOffers")
// print and decline all received offers
offers foreach { offer =>
log.info(offer.toString)
driver declineOffer offer.getId
}
}
213.
Scheduler
offerRescinded
/**
* オファーが、もはや有効でない場合に呼び出される。
* (例えば、スレーブが失われたり、他のフレームワークがリソースを
* オファーにつかった場合とか) どんな理由であれ、オファーが撤回され
* ないならl(メッセージが落ちる、あるいは、フレームワークが失敗する等で)
* フレームワークはost or another framework used resources in the offer). If for
* 妥当ではないオファーを使ってタスクを起動しようとしたフレームワークは、
* このタスクについて、TASK_LOSTステータス更新を受け取る。
*/
def offerRescinded(
driver: SchedulerDriver,
offerId: OfferID): Unit = {
log.info("Scheduler.offerRescinded [%s]" format offerId.getValue)
}
Be the first to comment