Expire cost to Redis

243 views
Skip to first unread message

Tute

unread,
Feb 9, 2011, 12:38:50 PM2/9/11
to redi...@googlegroups.com
Im going to move an odd mechanism from mysql to redis and I want to use
the expire command. Its expensive to Redis have a few thousands of key
running with an expire of 172800 seconds ?


Pieter Noordhuis

unread,
Feb 9, 2011, 12:45:40 PM2/9/11
to redi...@googlegroups.com
If you group certain keys into a hash, that will be cheaper. See:
http://redis.io/topics/memory-optimization

Note that you can only group string values in a hash.

Cheers,
Pieter

On Wed, Feb 9, 2011 at 6:41 PM, Tute <tute....@gmail.com> wrote:
> What is less expensive to Redis to have? A big hash or a lot of keys ?
>
> --
> 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.
>
>

Jay A. Kreibich

unread,
Feb 9, 2011, 12:48:39 PM2/9/11
to redi...@googlegroups.com
On Wed, Feb 09, 2011 at 02:38:50PM -0300, Tute scratched on the wall:

> Im going to move an odd mechanism from mysql to redis and I want to use
> the expire command. Its expensive to Redis have a few thousands of key
> running with an expire of 172800 seconds ?

If you're worried about some type of timer or garbage collector, it
isn't a big deal. From <http://redis.io/topics/expire>:

Enhanced Lazy Expiration algorithm

Redis does not constantly monitor keys that are going to be
expired. Keys are expired simply when some client tries to access a
key, and the key is found to be timed out.

Of course this is not enough as there are expired keys that will
never be accessed again. This keys should be expired anyway, so
once every second Redis test a few keys at random among keys with
an expire set. All the keys that are already expired are deleted
from the keyspace.


-j

--
Jay A. Kreibich < J A Y @ K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
but showing it to the wrong people has the tendency to make them
feel uncomfortable." -- Angela Johnson

Tute

unread,
Feb 9, 2011, 12:41:59 PM2/9/11
to redi...@googlegroups.com

Pieter Noordhuis

unread,
Feb 9, 2011, 12:40:37 PM2/9/11
to redi...@googlegroups.com
Not all all. There's a little bookkeeping necessary to store the
timeouts, but when you're dealing with only a couple thousand expiring
keys, you're looking at less than 1MB of memory.

Cheers,
Pieter

Dvir Volk

unread,
Feb 9, 2011, 4:10:09 PM2/9/11
to redi...@googlegroups.com
Does VM take into account expired values when swapping into VM?

Reply all
Reply to author
Forward
0 new messages