Any good for build multiple database in a single Redis instance?

284 views
Skip to first unread message

Zhuo Song

unread,
Dec 6, 2012, 1:36:21 PM12/6/12
to redi...@googlegroups.com
Hi,

The default number of databases in a single Redis instance is 16. I heard some people said that there is a performance penalty to have multiple databases built in. I'm not sure how true it is. I have 64 independent databases. I'm considering how to distribute them on a single machine. Is it better to set them in 4(Redis with different ports)*16(db) or 8*8 or just 64 * 1? The rational to split it to databases is that I want speed up random read performance.

Thanks 

Josiah Carlson

unread,
Dec 6, 2012, 4:41:17 PM12/6/12
to redi...@googlegroups.com
Multiple database performance issues only matter if you are using
expiration with a lot of keys. Generally, Redis will expire keys that
should be expired when they are accessed, and it will occasionally
randomly probe the keys. If it finds a lot of keys that should be
expired, it spends time expiring them. Otherwise, it just gets rid of
the handful of keys that should be expired. For each database with
keys with expiration times, Redis will perform the random probing.
That's where the performance concern comes in.

Now, if you are looking to improve random read performance, using
databases won't help you. Redis will still only use a single thread
for reading from all databases in the same process.

Regards,
- Josiah
> --
> You received this message because you are subscribed to the Google Groups
> "Redis DB" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/redis-db/-/GB0ZixdKNj0J.
> 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.

Yiftach Shoolman

unread,
Dec 7, 2012, 7:45:24 AM12/7/12
to redi...@googlegroups.com
Just create a dedicate Redis process per each DB. If you don't do it and instead use multiple DBs on the same Redis process, whenever you use one DB all others are stalled. 

--

Yiftach Shoolman
+972-54-7634621

Marc Gravell

unread,
Dec 7, 2012, 3:23:07 PM12/7/12
to redi...@googlegroups.com, redi...@googlegroups.com
We have many many more databases than 16 in a single process. I don't have the number to hand, but: don't *assume* this is a problem until you've tried it. That said, I've spent the last day of two thinning out some of my library code to make each individual connection cheaper - for our usage, the most obvious sharding technique would be to split databases between processes. But: it works just fine in many cases with high database counts. YMMV.

Marc
Reply all
Reply to author
Forward
0 new messages