1

I am using Redis on virtual machines and having trouble deciding how many cores should I assign to them.

I know that Redis uses single thread to serve requests, but documentation also states that some tasks performed in background by different threads/processes.

I can assign more cores than needed without wasting resources, but I don't like the idea of going over theoretical limit, which I assume exists in this case.

So far I came up with this:

Did I miss something, are there any other tasks where Redis can utilize additional cores? Perhaps replication or streams?

Dave M
  • 4,514
  • 22
  • 31
  • 30
chimmi
  • 111
  • 1
  • 4

3 Answers3

1

Redis is, mostly, a single-threaded server from the POV of commands execution (actually modern versions of Redis use threads for different things). Please go through below links. How fast is Redis?. There is also one same post on stackoverflow - Redis is single-threaded, then how does it do concurrent I/O?

sanjayparmar
  • 633
  • 8
  • 19
  • Im sorry but it seems like you didnt read my post past the title. I know that Redis is single threaded and I know that it can perform different things in separate threads. The question is - "what things?" And neither your answer nor the links you provide has any information on that. – chimmi Apr 26 '19 at 11:16
  • if i am correct, you want total number of cpus, redis can use ? we can use multi thread redis. – sanjayparmar Apr 26 '19 at 12:15
  • https://stackoverflow.com/questions/21304947/redis-performance-on-a-multi-core-cpu/21305073 – sanjayparmar Apr 26 '19 at 12:21
1

Please check this url https://redis.io/topics/benchmarks,

"Redis is not designed to benefit from multiple CPU cores. People are supposed to launch several Redis instances to scale out on several cores if needed. It is not really fair to compare one single Redis instance to a multi-threaded data store."

"CPU is another very important factor. Being single-threaded, Redis favors fast CPUs with large caches and not many cores. At this game, Intel CPUs are currently the winners. It is not uncommon to get only half the performance on an AMD Opteron CPU compared to similar Nehalem EP/Westmere EP/Sandy Bridge Intel CPUs with Redis. When client and server run on the same box, the CPU is the limiting factor with redis-benchmark."

asktyagi
  • 2,860
  • 2
  • 8
  • 25
-2

Just use single-core VMs. Redis won't use extra cores.

Max Malysh
  • 97
  • 1
  • 1
  • 2
  • That is simply wrong. Please read the question beyond its title. – chimmi Aug 07 '22 at 13:35
  • @chimmi it looks like you have tested your setup already. Could you tell more about it, please? Did it work out? Was the CPU usage optimal? – Max Malysh Aug 07 '22 at 13:43
  • 1
    This question stemmed from a problem we had, when a periodic task (bunch of pipelined calls to a lua script), that was utilizing 100% CPU on one core, was overlapping with RDB, which also used a lot of CPU (on a different process, since RDB uses fork). This problem was fixed by simply bumping up cores to 2. As for the question: I quickly got tired of arguing with the “just use one core” mob, and abandoned it. – chimmi Aug 07 '22 at 13:58