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
so this is KeyDB! So what.
Search
Naoto Gohko
April 17, 2021
Programming
1
710
so this is KeyDB! So what.
redisの代わりにkeydbを使ってみた話
OSunC 2021/04/17 Spring/Onlineより
Naoto Gohko
April 17, 2021
Tweet
Share
More Decks by Naoto Gohko
See All by Naoto Gohko
asks Canonical about Ubuntu support and starts using Ubuntu
naototty
0
66
Rancher Harvester and KubeVirt HCI operator
naototty
0
400
ODC2020; "Rocky 8", Rocky Linux 8 story
naototty
0
540
2020/07/25 OSC Niigata/Online LT; about xlsx2csv-go-CLI
naototty
1
700
私とOSC Hokkaido Love (私のOSC Hokkaido参加の振り返り)
naototty
1
480
GTB2020; Introduction to virtualization technology on GMO Tech Bootcamp
naototty
0
240
OSS Forum in Tokyo/Winter: Around the OpenStack world in 2019.
naototty
0
370
Use ubuntu canonical's multipass command
naototty
0
360
Bifrost Ironic Standalone deep dive for GPU baremetal cloud
naototty
0
300
Other Decks in Programming
See All in Programming
Kiroで始めるAI-DLC
kaonash
2
570
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
120
Rancher と Terraform
fufuhu
2
230
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
430
テストカバレッジ100%を10年続けて得られた学びと品質
mottyzzz
2
490
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
380
モバイルアプリからWebへの横展開を加速した話_Claude_Code_実践術.pdf
kazuyasakamoto
0
310
Honoアップデート 2025年夏
yusukebe
1
920
AIでLINEスタンプを作ってみた
eycjur
1
230
AIコーディングAgentとの向き合い方
eycjur
0
260
Flutter with Dart MCP: All You Need - 박제창 2025 I/O Extended Busan
itsmedreamwalker
0
140
時間軸から考えるTerraformを使う理由と留意点
fufuhu
14
4.5k
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
Scaling GitHub
holman
463
140k
The Pragmatic Product Professional
lauravandoore
36
6.9k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
53
2.9k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
BBQ
matthewcrist
89
9.8k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.5k
Producing Creativity
orderedlist
PRO
347
40k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.8k
How GitHub (no longer) Works
holman
315
140k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Transcript
KeyDBですが、なにか? So this is the ”KeyDB”, so what? DB alternative探訪シリーズ
part 3 forked redis OSunC 2021 Online Spring / 2021-04-17 @naoto_gohko
LT presenter(Itʼs me) • Naoto Gohko / 郷古 直仁 (@naoto_gohko)
• Cloud Service development divistion, GMO Internet Inc., • OpenStackでpublic cloudサービス • 最近の活動主体 • Japan OpenStack user会 / OSC onlineお⼿伝い(Zoom修⾏) • 最近 • 最近とある製品のre: brandにより、美雲あんずは ConoHaショップ店⻑になったらしい @MikumoConoHa @MikumoAnzu
暖かくなってきました。 皆様 お出かけしたいですね …… そんな中、とある仕事 でのweb APIをpython で作る案件で
古きVM構成と冗⻑とローカリティ • Python flask(rest API) + celery + redis +
mongodb構成 • 低コスト(3 VM : node)で冗⻑性について考えてみる • redis : Celeryのbroker store (MQ) • mongodb : APIの処理の結果を永続保存 • flaskでのrest APIをceleryでfront(API) + celery(worker)に分離する • node A : • node B : どうはいちする? • node C : • docker/container じゃない
その時のredisについて考える • Redis 3.0から : Redis clusterにてmulti-master対応 • è 普通にmult-masterならとくに問題ない
• 2020/10⽉ぐらい • è Redis 6.0 branch (v5.9.103) 以降 redis6 multithread I/Oが⼊ってきている その少し前 • redis 5X時のゴタゴタ • バンドの⽅向性の違い è MultiThreadの実装の⽅向性
redis v5.x後半のゴタゴタとは • CPU Coreあたりの処理能⼒が上限になりつつあった2019年 • クロックはあまり上がらず、Core数が増える時代 • Intel より
AMD がマルチ・ダイでマルチコアの効率化 • その時のredisの⽅向性 • redis clusterでshardして、処理インスタンスあたりのCore割当を分散 する • è shardするover headも⼤きい • KeyDBを考えた⼈たち • è そんなことより、単⼀インスタンスあたりの性能をマルチスレッド 化で ⾼めて、shardなんて複雑化しないでover head減らそう
⽅向性の違い è fork : KeyDB 5.x Faster : 5倍 早いだとぉぉ
(当時) Oct. 2019 : Redis v5.0.9⽐較
None
None
今のKeyDB and Redis • Redis 6.2.x (latest) • 結局はmultithread I/O
を受け⼊れる • default 1 thread • CONF: io-threads {INT} • CPU Core数 ‒ 1 と⼿動設定 • KeyDB 6.0.16 (latest) : 設定細かい • 標準thread対応 • default 1 thread • CONF: server-threads {INT} ## 2とかにすると良い CONF: server-thread-affinity true ## なるべくCPUpinする(defautl)
benchmark取るときには、設 定もチューニング必要 ゆっくり考えてね
で、結局どうしたのか : KeyDB node C node B node A keydb
keydb keydb py py mongod arbiter mongod primary mongod secondary • KeyDB multi-master è 普通に使えますね • Pythonからは、localhostでアクセス • KVSとしてはデータローカリティ • haproxyはtcp socketでprimary判定check haproxy haproxy haproxy haproxy haproxy 192.168.1.5 192.168.1.6 192.168.1.7
たまには良いけど、アプリ ケーションサービスのメッ シュを⼿動で組むとか今どき じゃないね 皆さんは、dockerなり、kubernetesとか使いましょう haproxyいれて、⼿動でメッシュしても、きっとどこか抜けている!!
KeyDB multi-master (example • /etc/keydb/keydb.conf 変更点 (node A : 192.168.1.5)
replica-read-only no ## yes を noに変更 cluster-node-timeout 5000 ## peerが切れたら諦めろ multi-master yes active-replica yes replicaof 192.168.1.6 6379 ## node B peer replicaof 192.168.1.7 6379 ## node C peer • node B, node Cはpeer nodeのIPを書き換えておく
KeyDB multi master start • あとは起動 • # systemctl enable
keydb • # systemctl start keydb
status • # systemctl status keydb • • keydb.service -
Advanced key-value store • Loaded: loaded (/usr/lib/systemd/system/keydb.service; enabled; vendor preset: disabled) • Drop-In: /etc/systemd/system/keydb.service.d • └─limit.conf • Active: active (running) since ⼟ 2021-04-17 00:27:21 UTC; 6s ago • Docs: https://docs.keydb.dev, • man:keydb-server(1) • Process: 11922 ExecStart=/usr/bin/keydb-server /etc/keydb/keydb.conf (code=exited, status=0/SUCCESS) • Main PID: 11927 (keydb-server) • CGroup: /system.slice/keydb.service • └─11927 /usr/bin/keydb-server 0.0.0.0:16379 • 4⽉ 17 00:27:21 iso-man11012.g1.tyo1.v4.internal-gmo systemd[1]: Starting Advanced key-value store... • 4⽉ 17 00:27:21 iso-man11012.g1.tyo1.v4.internal-gmo systemd[1]: PID file /var/run/keydb/keydb-server.pid not readable (yet?) after start. • 4⽉ 17 00:27:21 iso-man11012.g1.tyo1.v4.internal-gmo systemd[1]: Started Advanced key-value store.
KeyDB 失敗談 • KeyDBでclusterで⾏こうとしたけど、失敗 • keydb-cli --cluster create \ 192.168.1.5:6379
\ 192.168.1.6:6379 \ 192.168.1.7:6379 --cluster-replicas 1 • replica 1だと、6 node(or instance)必要
node A write / read node A # keydb-cli -p
16379 Message of the day: Join the KeyDB community! https://community.keydb.dev/ 127.0.0.1:6379> set k2 2 OK 127.0.0.1:6379> get k2 "2" 127.0.0.1:6379> exit
node B read node B check # keydb-cli -h 192.168.1.6
-p 6379 Message of the day: Join the KeyDB community! https://community.keydb.dev/ 192.168.1.6 :6379> get k2 "2" 192.168.1.6 :6379> exit
node C read node C check # keydb-cli -h 192.168.1.7
-p 6379 Message of the day: Join the KeyDB community! https://community.keydb.dev/ 192.168.1.7 :6379> get k2 "2" 192.168.1.7 :6379> exit
KeyDB普通に使えるね by multi-master Operationはredisと同じ、 Configは違いもあるけど、楽な点も多い
benchmarkについては、 今回の⽤途では頑張る必要なし • まとめ • 冗⻑でローカリティアクセスのredisをKeyDB multi-masterでできた • cluster構成は3 nodeで失敗
(replica設定 1) è 6 node必要みたい • KeyDBかんたん、悪くないかも • reidis : BSD-3 or commercial license available • KeyDB : BSD-3 (community version and Enterprise version) • nodeごとに⼀回削除して、作り直してもすぐに復帰してた • コンテナの運⽤性も良さそうだ