You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何Node.js中DragonflyDB比Redis慢?与官方基准测试不符

问题:DragonflyDB读性能测试远慢于Redis,测试方式哪里出错?

我需要搭建一个读性能尽可能快的数据库,因此考虑了DragonflyDB——它在官方基准测试中宣称远快于Redis。这是2022年推出的内存数据库,与Redis(及Memcached)API几乎完全兼容,我需用它读写哈希或集合类型数据。

我编写了如下基准测试代码(设置N_ITER = 10_000):

Redis测试代码及结果

const Redis = require("ioredis")
const redis = new Redis({
  host: "localhost",
  port: 6380,
  password: "",
})

console.time("1")
const myRedisGetKeys = () =>
  Promise.all(new Array(N_ITER).fill(1).map((_, i) => redis.get(i)))

myRedisGetKeys().then(_ => {
  console.timeEnd("1")
})

测试结果:1: 142.473ms

DragonflyDB测试代码及结果

const Redis = require("ioredis")
const dragonfly = new Redis({
  host: "localhost",
  port: 6379,
  password: "",
})

console.time("2")
const myDragonflyGetKeys = () =>
  Promise.all(new Array(N_ITER).fill(1).map((_, i) => dragonfly.get(i)))

myDragonflyGetKeys().then(_ => {
  console.timeEnd("2")
})

测试结果:2: 728.216ms

可见DragonflyDB读性能比Redis慢5倍,我的测试方式哪里出了问题?

补充:若需,我可提供Python测试代码,该环境下Redis仅比DragonflyDB快20%。


内容的提问来源于stack exchange,提问作者Andrea Nicolai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 20:12:17