Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Cassandraの活用事例とパフォーマンス特性
Tomohiro Hashidate
June 04, 2019
Technology
3
670
Cassandraの活用事例とパフォーマンス特性
Repro Tech LT発表資料
Tomohiro Hashidate
June 04, 2019
Tweet
Share
More Decks by Tomohiro Hashidate
See All by Tomohiro Hashidate
ReproのImport/Exportを支えるサーバーレスアーキテクチャ
joker1007
1
680
Ruby on Rails on Lambda
joker1007
13
6.7k
Sidekiq to Kafka ストリームベースのmicro services
joker1007
3
7.7k
令和時代のRails運用
joker1007
33
12k
TracePointから学ぶRubyVM
joker1007
0
1.1k
What a cool Ruby-2.7 is !
joker1007
2
430
How to extend TracePoint
joker1007
2
180
†Ruby黒魔術経典†
joker1007
13
5.1k
Pragmatic Monadic Programming in Ruby
joker1007
4
10k
Other Decks in Technology
See All in Technology
Scrum Fest Niigata 2022 開発エンジニアに聞いてみよう!
moritamasami
1
670
Data Warehouse or Data Lake, which one do I choose?
ahana
0
150
XRを取り巻く技術の正体と未来
kajiken_meson
0
170
數據的多重宇宙 @ LINE Taiwan
line_developers_tw
PRO
0
970
Puny to Powerful PostgreSQL Rails Apps
andyatkinson
PRO
0
410
Oracle Cloud Infrastructure:2022年5月度サービス・アップデート
oracle4engineer
PRO
0
150
プロダクトの理想と現実はなぜ乖離しがち?プロダクト作りに潜む問題を考える
suzukentaro
0
260
Oracle Content Management サービス概要 (2022年5月版)
oracle4engineer
PRO
0
130
Kubernetesの上に作る、統一されたマイクロサービス運用体験
tkuchiki
1
1.3k
Poolにおける足を止めないシステム基盤構築
winebarrel
3
1.2k
KubeCon Recap -Platform migration at Scale-
inductor
0
120
2022年最新版 GatsbyJS + TypeScript + microCMS でブログを作る。
hanetsuki
1
750
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
56
5.2k
Building Flexible Design Systems
yeseniaperezcruz
310
33k
Automating Front-end Workflow
addyosmani
1351
200k
Why You Should Never Use an ORM
jnunemaker
PRO
47
5.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
212
20k
Rebuilding a faster, lazier Slack
samanthasiow
62
7.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
56
2.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
638
52k
It's Worth the Effort
3n
172
25k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
181
15k
KATA
mclloyd
7
8.6k
Product Roadmaps are Hard
iamctodd
34
6.1k
Transcript
Cassandra の活⽤事例とパフォーマンス特性 joker1007 (Repro inc. CTO)
self.inspect @joker1007 Ruby/Rails/fluentd/presto/infra ⼤体アーキテクト業 今はkafka とkudu に興味がある
話すこと Repro でのCassandra の活⽤⽬的 Cassandra の選定理由 Cassandra のパフォーマンス特性と設計時の注意 話さないこと 運⽤時の細かな注意点
何のために 端末情報記録 ユーザープロフィール情報 イベント実⾏回数 / user リアルタイムで更新される情報の保持がメイン
何故Cassandra を選択したか 書き込み回数が⾮常に多い かつ読み込み時に100 万件単位で取得しJOIN する必要がある 組み合わせる対象として、数⼗⽇分の⾏動ログを含む。 書き込みがスケールし、当時からセグメンテーションに利⽤していたpresto と連携が 可能で、読み込みもある程度分散できるデータストアが必要。
→ Cassandra を採⽤。
Cassandra のパフォーマンス特性
書き込みの概要 Client Client R2 R2 R3 R3 1 1 2
3 4 4 5 6 7 8 9 10 11 12 R1 R1 Write response Chosen node Coordinator node https://docs.datastax.com/ja/cassandra- jajp/3.0/cassandra/dml/dmlClientRequestsWrite.html
書き込みの概要 https://docs.datastax.com/ja/cassandra- jajp/3.0/cassandra/dml/dmlHowDataWritten.html
書き込みパフォーマンス特性 パーティション対象の決定とmemtable 、transaction log が書ければOK 。 最終的なテーブルファイルは不変なので、書き出しがシンプル。 パーティションさえ均等なら割と簡単にスケールする ⼀件単位の書き込みは、ほぼ100 マイクロ秒以下
現時点で20000/sec ぐらいの書き込みがある 整合性を保ってカウントアップする処理は重い 複数ノードを跨いでCAS やロックが必要になる
読み込みの概要 Client Client R2 R2 R3 R3 1 1 2
3 4 4 5 6 7 8 9 10 11 12 R1 R1 replica node failed coodinator node resends after timeout Chosen node Coordinator node https://docs.datastax.com/ja/cassandra- jajp/3.0/cassandra/dml/dmlClientRequestsRead.html
読み込みの概要 https://docs.datastax.com/ja/cassandra-jajp/3.0/cassandra/dml/dmlAboutReads.html
読み込みパフォーマンス特性 ⼀件単位の読み込みに向いている 多くのデータをまとめて取得するには不向き 取得対象のパーティションとノード特定にCPU を使う クラスタのノード間でデータの通信が多く発⽣する パーティション毎のdigest 要求 read repair
presto での利⽤は本来は不向き パーティション数とノード数でバランスを取ることで 何とか⽬的のパフォーマンスを維持
テーブル設計の重要性 読み込みワークロードに合わせてテーブルを設計する、でないとまともにパフォ ーマンスが出ない。 ユースケース毎にテーブルがあり、データの重複は覚悟する。 とにかくパーティションキー以外を条件にクエリしないこと。
まとめ 読み込みパターンに合わせたテーブル設計をすること ⽤途が適切ならかなりのパフォーマンスが出せる パーティション数とデータの分散度合いのコントロールが重要
その他のTips CPU 、ディスクI/O 、ネットワークそれぞれかなり影響があるのでメトリックをち ゃんと取得しておくこと ホットデータはオンメモリで読み書きするのでメモリは多く セカンダリインデックスは基本使えない