【问题标题】:How much faster is redis than Postgres?redis 比 Postgres 快多少?
【发布时间】:2014-05-04 07:45:16
【问题描述】:

经过一些在线研究,我找不到两者之间的基准比较。我确实找到了一个 redis vs mongodb:(How much faster is Redis than mongoDB?)。

根据我以下极其不科学的测试,在 rails 中运行两个简单的不相等代码,我猜写入大致相同,但 redis 的读取速度大约快 2 倍。考虑到我的视图通常为 50 毫秒~150 毫秒,速度优势并没有我预期的那么大。

我的问题是,是否还有其他基准可以让我对这两者有一个“粗略”的想法?使用两者的约定配置,甚至可以针对 heroku 基本 dyno 及其 postgres 服务对其进行测试?谢谢!

##NOTICE: #follow is implemented with Redis. #public is just a postgres ActiveRecord property.
[93] pry(main)> Benchmark.measure{ 100.times { c.public = !c.public; c.save; c.public = !c.public; c.save}}
=> #<Benchmark::Tms:0x007faeb3c814f0
 @cstime=0.0,
 @cutime=0.0,
 @label="",
 @real=0.743117,
 @stime=0.03000000000000025,
 @total=0.6000000000000005,
 @utime=0.5700000000000003>
[94] pry(main)> Benchmark.measure{ 100.times { u.unfollow! u2; u.follow! u2 }}
=> #<Benchmark::Tms:0x007faeb1409c20
 @cstime=0.0,
 @cutime=0.0,
 @label="",
 @real=0.988483,
 @stime=0.14000000000000057,
 @total=0.8800000000000026,
 @utime=0.740000000000002>
[95] pry(main)> Benchmark.measure{ 100.times { u.follows? u2 }}
=> #<Benchmark::Tms:0x007faeb2f22ea8
 @cstime=0.0,
 @cutime=0.0,
 @label="",
 @real=0.045072,
 @stime=0.009999999999999787,
 @total=0.06000000000000405,
 @utime=0.05000000000000426>
[96] pry(main)> Benchmark.measure{ 100.times { Course.first.public? }}
=> #<Benchmark::Tms:0x007faeac97b8c0
 @cstime=0.0,
 @cutime=0.0,
 @label="",
 @real=0.11811,
 @stime=0.0,
 @total=0.09000000000000341,
 @utime=0.09000000000000341>

【问题讨论】:

  • 如果我给你一个关于 Postgres 与 Redis 对象存储基准的链接,会有帮助吗?
  • @Pavan,是的,这会很有帮助!
  • 除非是这个:gist.github.com/NateBarnes/3001890 套装快 2 倍,快 1 倍...

标签: ruby-on-rails postgresql heroku redis benchmarking


【解决方案1】:

Redis 是一个键值存储数据库,Postgres 是一个 RDBMS。键值数据库允许数据存储在无模式但不是关系数据库。

这两种方法各有利弊。如需进一步阅读,您可以查看这个现有的 stackoverflow post

【讨论】:

    猜你喜欢
    • 2018-08-19
    • 2010-09-13
    • 2011-04-17
    • 2018-04-10
    • 1970-01-01
    • 1970-01-01
    • 2019-11-18
    • 2011-05-30
    相关资源
    最近更新 更多