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
550
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
37
Rancher Harvester and KubeVirt HCI operator
naototty
0
240
ODC2020; "Rocky 8", Rocky Linux 8 story
naototty
0
410
2020/07/25 OSC Niigata/Online LT; about xlsx2csv-go-CLI
naototty
1
530
私とOSC Hokkaido Love (私のOSC Hokkaido参加の振り返り)
naototty
1
370
GTB2020; Introduction to virtualization technology on GMO Tech Bootcamp
naototty
0
180
OSS Forum in Tokyo/Winter: Around the OpenStack world in 2019.
naototty
0
290
Use ubuntu canonical's multipass command
naototty
0
290
Bifrost Ironic Standalone deep dive for GPU baremetal cloud
naototty
0
160
Other Decks in Programming
See All in Programming
Sementic Kernelのネイティブ関数について
tomokusaba
0
780
TokyoR#111_ANOVA
kilometer
1
710
20240301_cocone_EMゆるミートアップvol6_LT資料
cocone
0
250
syndicationd LT
ymgyt
0
110
「Hono遍歴」と「HonoXでブログ作成」
yasu551
0
170
マイ隙間家具OSSたちのご紹介
karupanerura
2
120
軽率にVue 3で リアルタイム3Dアプリを作れる ライブラリを作ってみた/vue-with-3d-app
drumath2237
3
1.1k
So You Think You Know Git - Part 2
schacon
PRO
0
1.3k
PHPアプリケーションのスケーラビリティと 信頼性を革新する nginx+ngx_mrubyとGoの融合
pyama86
2
220
Next.js で SPA を構築する際の辛み
hayatow
0
220
シェルの履歴とイクンリメンタル検索を使う
naoya
7
2.3k
人口ダッシュボード作成講座資料
jo76shin
0
170
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
14
1.3k
Building Applications with DynamoDB
mza
88
5.5k
Git: the NoSQL Database
bkeepers
PRO
421
63k
Optimising Largest Contentful Paint
csswizardry
7
2.3k
The World Runs on Bad Software
bkeepers
PRO
60
6.6k
The Cost Of JavaScript in 2023
addyosmani
13
3.7k
How GitHub Uses GitHub to Build GitHub
holman
467
290k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
11
1.4k
Web development in the modern age
philhawksworth
201
10k
What's new in Ruby 2.0
geeforr
335
31k
Keith and Marios Guide to Fast Websites
keithpitt
407
22k
Infographics Made Easy
chrislema
237
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ごとに⼀回削除して、作り直してもすぐに復帰してた • コンテナの運⽤性も良さそうだ