mongle
mongle

Reputation: 75

Optimising Redis on multi-threaded dedicated server

I will be running redis on a dedicated server with 6 cores, 12 threads and 32 GB of RAM. I am using redis as the primary datastore. Th application has a number of hashes, sets and lists but they all constitue the same app. In order to utilise all the threads, can I start multiple instances of redis on different ports and assign a few redis structures to each. Will this have any issue? I suppose in my client code, I would have to make multiple connections on different ports to read/write the app data..

Thanks

Upvotes: 3

Views: 992

Answers (1)

Didier Spezia
Didier Spezia

Reputation: 73306

Redis being single-threaded, you need to start several instances to leverage the benefit of multiple cores or multiple CPUs. Different ports have to be used, you may also need to change some other parameters in the config files to avoid conflicts:

  • pidfile
  • port
  • unixsocket
  • logfile
  • dbfilename (or alternatively dir)

In the client code, you need at least one connection per Redis instance.

The main issue is once some keys have been added in different instances, you cannot anymore run commands involving several keys without checking first that all the keys are on the same instance (for example you cannot anymore calculate the intersection of sets stored on different Redis instance, at least not with the SINTER command).

Upvotes: 2

Related Questions