2014-03-26 28 views
1

經過一些在線研究,我找不到兩者之間的基準比較。我確實發現了一個redis vs mongodb:(How much faster is Redis than mongoDB?)。redis比Postgres快了多少?

根據我的以下非常不科學的測試,在rails中運行兩個簡單的不相等的代碼,我猜測寫入大致相同,但redis的讀取速度大約快兩倍。考慮到我的觀點通常爲50ms〜150ms,速度並不像我想象的那麼大。

我的問題是,有沒有其他的基準可以給我關於這兩個「粗略」的想法?通過兩種慣例配置,甚至可以對照heroku基本測功機及其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> 
+0

如果我給你一個關於Postgres vs Redis Object Storage Benchmarks的鏈接,它會有幫助嗎? – Pavan

+0

@Pavan,是的,這將有所幫助! – randomor

+0

除非是這個:https://gist.github.com/NateBarnes/3001890這個集合快了大約2倍,速度提高了1倍...... – randomor

回答

0

Redis是一個鍵值存儲數據庫,Postgres是一個RDBMS。鍵值數據庫允許將數據存儲爲無模式,而不是關係數據庫。

這兩種方法各有利弊。爲了進一步閱讀,你可以查看這個現有的計算器post