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
700
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
61
Rancher Harvester and KubeVirt HCI operator
naototty
0
390
ODC2020; "Rocky 8", Rocky Linux 8 story
naototty
0
520
2020/07/25 OSC Niigata/Online LT; about xlsx2csv-go-CLI
naototty
1
690
私とOSC Hokkaido Love (私のOSC Hokkaido参加の振り返り)
naototty
1
470
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
360
Use ubuntu canonical's multipass command
naototty
0
350
Bifrost Ironic Standalone deep dive for GPU baremetal cloud
naototty
0
300
Other Decks in Programming
See All in Programming
#QiitaBash MCPのセキュリティ
ryosukedtomita
1
1.4k
脱Riverpod?fqueryで考える、TanStack Queryライクなアーキテクチャの可能性
ostk0069
0
270
AIエージェントはこう育てる - GitHub Copilot Agentとチームの共進化サイクル
koboriakira
0
600
RailsGirls IZUMO スポンサーLT
16bitidol
0
190
AIプログラマーDevinは PHPerの夢を見るか?
shinyasaita
1
230
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
2
640
AI コーディングエージェントの時代へ:JetBrains が描く開発の未来
masaruhr
1
190
チームで開発し事業を加速するための"良い"設計の考え方 @ サポーターズCoLab 2025-07-08
agatan
1
440
新メンバーも今日から大活躍!SREが支えるスケールし続ける組織のオンボーディング
honmarkhunt
5
7.7k
状態遷移図を書こう / Sequence Chart vs State Diagram
orgachem
PRO
1
130
Google Agent Development Kit でLINE Botを作ってみた
ymd65536
2
260
코딩 에이전트 체크리스트: Claude Code ver.
nacyot
0
700
Featured
See All Featured
Unsuck your backbone
ammeep
671
58k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Why You Should Never Use an ORM
jnunemaker
PRO
58
9.4k
The Language of Interfaces
destraynor
158
25k
It's Worth the Effort
3n
185
28k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
The Cult of Friendly URLs
andyhume
79
6.5k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Scaling GitHub
holman
460
140k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
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ごとに⼀回削除して、作り直してもすぐに復帰してた • コンテナの運⽤性も良さそうだ