NoSQL with MySQL in Ruby - Friendly
friendlyorm.com
friendlyorm.com
One should note thought that more modern NoSQL databases aren't only key-value stores. For example, Redis offers KEYS command which can scan the store by a pattern. Tokyo Tyrant (another "key-value" store) offers Lua scripting.
-- Return keys with a given prefix for a particular node where there are a
-- known total of nodes. Uses the reamainder of the keys' hash values to
-- segment the keys.
function slice(prefix, index_and_total)
local args = _split(index_and_total, "\t")
if #args ~= 2 then
return nil
end
local index = tonumber(args[1])
local total = tonumber(args[2])
local res = {}
local keys = _fwmkeys(prefix)
for i = 1, #keys do
local key = keys[i]
local url = string.sub(
key,
string.find(key, ":", string.find(key, ":", 1, true) + 1, true) + 1
)
local modulo = tonumber(string.sub(_hash("md5", url), 1, 10), 16) % total
if modulo == index then
table.insert(res, key)
end
end
if #res == 0 then
return nil
end
return table.concat(res, "\t")
endI wonder why do you think so? Here's a sample test of plain and memcached mysql vs tokyo tyrant (http://www.mysqlperformanceblog.com/2009/10/19/mysql_memcach...) It was done without the additional inserts for the index table... I don't see how it can be anywhere close to the TT's performance for example. While mysql's replication is very easy, TT's replication is trivial. Backup is probably comparable - just flush and snapshot...
Unless you're comparing it to mysql+MC. Then yes - mysql's performance at 99.8% hits to MC can be ignored. We're left comparing MC with something else. Things might change dramatically if you have a write-heavy application. Or when you have more data than ram. Author's benchmarks will always show great results - let's wait for some real-world data.
It actually happens to be quite a write-intensive workload. We have definitely seen a slow down on writes, but the speed up on reads has more than compensated for it.
We do have more data than RAM. But, most of the data that actually gets read is fresh, so it's hot in cache.
Of course Friendly isn't going to be right for everybody. But, I just want to make it clear that my data isn't from synthetic benchmarks. It's from production.
I agree that replication in Tokyo Tyrant is generally good, but MySQL's is much more mature and one can get help more easily. It should be stated that I am the author of LightCloud (a distributed db built on top of TT) and I am running big installations of both TT and MySQL, so I speak from experience.
Friendly looks especially good in MySQL shops - otherwise I would suggest taking a good look at MongoDB (or Redis, CouchDB, Cassandra, etc.)