Redis with n database => multithread?

976 views
Skip to first unread message

Loïc

unread,
Sep 21, 2011, 9:34:55 AM9/21/11
to Redis DB
Hello

I need to have 10 big index (a lot of entries, values may be big) and
4 medium index (less entries and each value is a number).
So I will have 14 instance of redis client object which will access to
a specific index (1 client <=> 1 index).

2 ways to do this:
-redis.conf => databases=14. In my software, each client (jedis) will
make .select(int database) with database = 0,...,13.
-14 redis instance with databases=1. In my software, each client will
make jedis(host,port) with port = 6879,...,6892.

In documentation, I found:
"Redis is single threaded, how can I exploit multiple CPU / cores?
Simply start multiple instances of Redis in different ports in the
same box and treat them as different servers!"

With n databases, a single instance of redis will be mono or
multithread (n thread)?
Is it better to do n redis instance or a redis instance with n
database?
Is it wrong if I mix big database and little database on a redis
instance?

Thanks :-)

pedigree

unread,
Sep 21, 2011, 1:45:42 PM9/21/11
to Redis DB
Still single threaded, this just allows you to not overwrite/conflict
on things like

select 0
set mykey 1
select 1
set mykey 2

select 0
get mykey
$1
select 1
get mykey
$2

pedigree

unread,
Sep 21, 2011, 2:16:03 PM9/21/11
to Redis DB
I have two instances running on my server, one large one (900mb) and
one small one (130mb).

They are for distribution though, I just dont need to replicate the
900mb database whereas I do need to replicate the smaller one.

I think it also comes down to cpu threads. Im not sure I would want
to run 8 instances of redis on a single core server, not that Ive
tried but I think it would scale to that.

I also think that the configuration of your caches depends a lot on
what they are going to provide. Do they serve different needs or
would it just be for load / data balancing?

Loïc

unread,
Sep 22, 2011, 1:04:37 AM9/22/11
to Redis DB
> I think it also comes down to cpu threads.  Im not sure I would want
> to run 8 instances of redis on a single core server, not that Ive
> tried but I think it would scale to that.

Here we have a server with 2 cpu and each cpu has 8 core.
The software design is made to have n thread (for n index).

> I also think that the configuration of your caches depends a lot on
> what they are going to provide.  Do they serve different needs or
> would it just be for load / data balancing?

Different needs. Each big index store it's own data.
So it should be very good to have a thread per index.

If my software has 1 thread for 1 index and each thread use the same
monothread instance of redis, it won't be a good thing.
So I will try to use it with n redis process.
Reply all
Reply to author
Forward
0 new messages