Hi speedy,
interesting thoughts. Keep in mind that the AOF (and BGSAVE too) writes
sequentially to the disk, so you should get pretty good disk performance
with both HDDs and SSDs. Updating a counter (or similar) doesn't
generate that much data in the AOF, so it may not be a practical problem
that every single update is logged. I don't think you will be able to
max out your hard drive by running lots of INCR for example. It looks
like my computer is limited by the CPU long before that happens (and
it's running a lot of queries per second by then!).
Another way to achieve something like what you're talking about would be
for Redis to keep a queue of things to write to the AOF, do the writes
asynchronously and compact/rewrite the queue when new updates were
added. That way, if the disk couldn't keep up completely we would
probably be able to merge some changes in the queue before they were
written to disk and thereby improving performance (e.g. several updates
of a single counter would be merged into one). If we don't want it to
use the disk more than necessarily, we could even delay the writing a
bit so that we got more chances to merge updates...
I think that would be a very interesting improvement. I've been thinking
a bit about something like that before. Do note, though, that writes to
the AOF are done synchronously right now so the idea above would require
quite a few changes. I don't think it would make much difference in many
cases either. It should be useful for frequently updated counters at least.
Also see earlier discussions about asynchronous AOF I/O if you're
interested in that aspect.
Cheers,
Hampus
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To post to this group, send email to redi...@googlegroups.com.
To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
That said, it's also entirely possible that Redis isn't the right
solution. Twitter has had a need for a huge number of counters in a
distributed system, and developed a set of patches on top of Cassandra
to make them work in a reliable and fast way:
http://www.slideshare.net/mubarakss/cassandra-at-twitter-distributed-counters
. I've not looked into it as my need for counters is a couple orders
of magnitude smaller than yours, but it may be the right solution for
you.
Regards,
- Josiah
P.S. If you are really looking to work the Redis angle, here is a way
of offering rolling data syncs:
1. Whenever you increment a counter, also perform "SADD known_keys
<key>" inside a MULTI/EXEC call.
2. Have a daemon perform the following sequence of operations as fast
as possible:
v = SRANDMEMBER known_keys
if v is not null:
MULTI
SREM known_keys <v>
data = GET <v>
EXEC
# store v and data in something like Amazon SimpleDB, RDS, etc.
else:
sleep(1)
If you want to make counters save faster (and smaller), store your
counters in sub-keys of hashes, with a target size of roughly 128-1024
entries (updating the hash-max-zipmap-entries and
hash-max-zipmap-value config entries appropriately), which should
reduce round-trips between Redis, and whatever data store you are
using. You can also perform something up to 1024 SRANDMEMBER calls,
dedupe, and perform fetch on those keys to get data for a large chunk
of keys, which should allow for pretty reasonable streaming to
SimpleDB, RDS, etc.
You don't get point in time persistence, you do rely on your own code
being proper (never mind another Amazon service not going down), but
you can run more than one backup process against each Redis if one is
not able to keep up (with a little work, Redis scripting makes it a
lot easier), never mind various opportunities to further scale a
single backup process per Redis (I offered a couple above).
On Mon, Jul 18, 2011 at 10:04 AM, speedy <u...@trustedopinion.com> wrote: