SlideShare a Scribd company logo
1 of 13
Download to read offline
Apache Kafka 
分散システムのツアー #3 
Chris 
2014/10/15 
#m3dev 
https://github.com/m3dev/distrib-systems-tour
Kafka 
● PubSubメッセージ・キュー 
● LinkedIn発 
● 売り 
○ パフォーマンス 
○ スケーラビリティ 
○ 永続性 
○ 柔軟な配布モデル:コンシューマ・グループ 
● Scala実装、多言語のクライアント
アーキテクチャ 
Producer Producer Producer Producer 
Kafka cluster 
Broker Broker Broker 
Consumer Group 1 Consumer Group 2 
Consumer Consumer Consumer Consumer 
ZooKeeper 
HDD HDD HDD
コンシューマ・グループ 
● 全てのメッセージを全てのconsumer group(の 
consumerのいずれか)に配布する 
● 例) 
○ メッセージ 1, 2, 3, 4 
○ コンシューマグループ A, B 
○ Aにコンシューマ2台:A1, A2 
○ Bにコンシューマ2台:B1, B2 
Group A Group B 
A1 A2 B1 B2 
① ③ ② ④ ③ ④ ① ②
コンシューマ・グループ 
● スペシャルケース 
○ 全てのコンシューマが同じグループに所属 
■ 普通のキュー 
○ コンシューマはそれぞれ別グループ 
■ 普通のPub-Sub
(とある consumer group の中の話です) 
パーティション 
● トピックを複数の partition に分ける 
● Producer が message ⇔ partition の振り分け 
を決める 
● Kafka broker が partition ⇔ consumer の振り 
分けを決める 
● 制限:Consumer数 ≦ Partition数 
Producer 
Producer 
Partition 1 
Partition 2 
Consumer 
Partition 3 
Consumer
永続性 
● Brokerはメッセージをファイルに書き込む 
● Consumerがメッセージを消費しても、一定期間 
brokerに残る 
● Consumerが自身の経過を管理するので、巻き 
戻して再読み込みができる
パフォーマンス 
$ brew install kafka 
$ cd /usr/local/opt/kafka 
$ bin/start-zookeeper-server.sh libexec/config/zookeeper.properties & 
$ bin/kafka-server-start.sh libexec/config/server.properties & 
$ bin/kafka-topics.sh --create --zookeeper localhost:2181  
--replication-factor 1 --partitions 1  
--topic test 
$ bin/kafka-producer-perf-test.sh --broker-list localhost:9092  
--topics test --messages 1000000 
結果:49,568 messages/sec 
(Late 2011 MBP, 100 byte msgs)
スケーラビリティ 
LinkedIn社で1千億メッセージ/日! 
https://twitter.com/jaykreps/status/479749975853641729
使い所:リアルタイム通知
使い所:レポーティング
使い所:多目的イベント活用
ハンズオン! 
OSX: brew install kafka 
or, AWS上に稼働中のKafka を使う 
192.168.51.119:9092 
https://github.com/m3dev/distrib-systems-tour

More Related Content

Similar to Tour of Distributed Systems 3 - Apache Kafka

OpenBSD/luna88k on LUNA-88K2, at OSC 2013 Nagoya
OpenBSD/luna88k on LUNA-88K2, at OSC 2013 NagoyaOpenBSD/luna88k on LUNA-88K2, at OSC 2013 Nagoya
OpenBSD/luna88k on LUNA-88K2, at OSC 2013 NagoyaKenji Aoyama
 
Docker ComposeでMastodonが必要なものを梱包する話
Docker ComposeでMastodonが必要なものを梱包する話Docker ComposeでMastodonが必要なものを梱包する話
Docker ComposeでMastodonが必要なものを梱包する話Masahito Zembutsu
 
SaaS/クラウドコンピューティングでのオープンソース活用とセキュリティ
SaaS/クラウドコンピューティングでのオープンソース活用とセキュリティSaaS/クラウドコンピューティングでのオープンソース活用とセキュリティ
SaaS/クラウドコンピューティングでのオープンソース活用とセキュリティKuniyasu Suzaki
 
Kubernetesを触ってみた
Kubernetesを触ってみたKubernetesを触ってみた
Kubernetesを触ってみたKazuto Kusama
 
NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成
NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成
NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成Izumi Tsutsui
 
Akkaとは。アクターモデル とは。
Akkaとは。アクターモデル とは。Akkaとは。アクターモデル とは。
Akkaとは。アクターモデル とは。Kenjiro Kubota
 

Similar to Tour of Distributed Systems 3 - Apache Kafka (7)

OpenBSD/luna88k on LUNA-88K2, at OSC 2013 Nagoya
OpenBSD/luna88k on LUNA-88K2, at OSC 2013 NagoyaOpenBSD/luna88k on LUNA-88K2, at OSC 2013 Nagoya
OpenBSD/luna88k on LUNA-88K2, at OSC 2013 Nagoya
 
Docker ComposeでMastodonが必要なものを梱包する話
Docker ComposeでMastodonが必要なものを梱包する話Docker ComposeでMastodonが必要なものを梱包する話
Docker ComposeでMastodonが必要なものを梱包する話
 
SaaS/クラウドコンピューティングでのオープンソース活用とセキュリティ
SaaS/クラウドコンピューティングでのオープンソース活用とセキュリティSaaS/クラウドコンピューティングでのオープンソース活用とセキュリティ
SaaS/クラウドコンピューティングでのオープンソース活用とセキュリティ
 
Kubernetesを触ってみた
Kubernetesを触ってみたKubernetesを触ってみた
Kubernetesを触ってみた
 
NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成
NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成
NetBSDのクロスビルドのしくみとインストール済みLive Imageの作成
 
Akkaとは。アクターモデル とは。
Akkaとは。アクターモデル とは。Akkaとは。アクターモデル とは。
Akkaとは。アクターモデル とは。
 
EditShare システムの紹介
EditShare システムの紹介EditShare システムの紹介
EditShare システムの紹介
 

More from Chris Birchall

Scala.js & friends: SCALA ALL THE THINGS
Scala.js & friends: SCALA ALL THE THINGSScala.js & friends: SCALA ALL THE THINGS
Scala.js & friends: SCALA ALL THE THINGSChris Birchall
 
Tour of distributed systems 2 - Cassandra
Tour of distributed systems 2 - CassandraTour of distributed systems 2 - Cassandra
Tour of distributed systems 2 - CassandraChris Birchall
 
Guess the Country - Playing with Twitter Streaming API
Guess the Country - Playing with Twitter Streaming APIGuess the Country - Playing with Twitter Streaming API
Guess the Country - Playing with Twitter Streaming APIChris Birchall
 
Tour of distributed systems 1 - ZooKeeper
Tour of distributed systems 1 - ZooKeeperTour of distributed systems 1 - ZooKeeper
Tour of distributed systems 1 - ZooKeeperChris Birchall
 
ScalaCache: simple caching in Scala
ScalaCache: simple caching in ScalaScalaCache: simple caching in Scala
ScalaCache: simple caching in ScalaChris Birchall
 
Load testing with gatling
Load testing with gatlingLoad testing with gatling
Load testing with gatlingChris Birchall
 
Debugging and Testing ES Systems
Debugging and Testing ES SystemsDebugging and Testing ES Systems
Debugging and Testing ES SystemsChris Birchall
 
Phone Home: A client-side error collection system
Phone Home: A client-side error collection systemPhone Home: A client-side error collection system
Phone Home: A client-side error collection systemChris Birchall
 
Branching Strategies: Feature Branches vs Branch by Abstraction
Branching Strategies: Feature Branches vs Branch by AbstractionBranching Strategies: Feature Branches vs Branch by Abstraction
Branching Strategies: Feature Branches vs Branch by AbstractionChris Birchall
 

More from Chris Birchall (11)

Scala.js & friends: SCALA ALL THE THINGS
Scala.js & friends: SCALA ALL THE THINGSScala.js & friends: SCALA ALL THE THINGS
Scala.js & friends: SCALA ALL THE THINGS
 
Rust 超入門
Rust 超入門Rust 超入門
Rust 超入門
 
Tour of distributed systems 2 - Cassandra
Tour of distributed systems 2 - CassandraTour of distributed systems 2 - Cassandra
Tour of distributed systems 2 - Cassandra
 
Guess the Country - Playing with Twitter Streaming API
Guess the Country - Playing with Twitter Streaming APIGuess the Country - Playing with Twitter Streaming API
Guess the Country - Playing with Twitter Streaming API
 
Tour of distributed systems 1 - ZooKeeper
Tour of distributed systems 1 - ZooKeeperTour of distributed systems 1 - ZooKeeper
Tour of distributed systems 1 - ZooKeeper
 
ScalaCache: simple caching in Scala
ScalaCache: simple caching in ScalaScalaCache: simple caching in Scala
ScalaCache: simple caching in Scala
 
Hydra
HydraHydra
Hydra
 
Load testing with gatling
Load testing with gatlingLoad testing with gatling
Load testing with gatling
 
Debugging and Testing ES Systems
Debugging and Testing ES SystemsDebugging and Testing ES Systems
Debugging and Testing ES Systems
 
Phone Home: A client-side error collection system
Phone Home: A client-side error collection systemPhone Home: A client-side error collection system
Phone Home: A client-side error collection system
 
Branching Strategies: Feature Branches vs Branch by Abstraction
Branching Strategies: Feature Branches vs Branch by AbstractionBranching Strategies: Feature Branches vs Branch by Abstraction
Branching Strategies: Feature Branches vs Branch by Abstraction
 

Tour of Distributed Systems 3 - Apache Kafka