Search code examples
google-cloud-platformredisredis-cluster

Could Redis benefit from having more than one core for its RDB backup process?


I have a Redis cluster with multiple nodes and wonder if each Redis node within the cluster would benefit from having more than one vCPU on GCP VM.

I understand that each Redis node is single-threaded due to its event-loop based design. However, it is also mentioned in the official doc that Redis forks a child process whenever it persists RDB snapshot to disk. Would the forked child process be able to leverage on a separate core if >1 CPU is provisioned for each node?


Solution

  • To answer your question, number of CPU might leverage in forked child process, but child process is more of a memory consuming process.

    Redis background saving schema relies on the copy-on-write semantic of fork in modern operating systems: Redis forks (creates a child process) that is an exact copy of the parent. The child process dumps the DB on disk and finally exits.

    In theory the child should use as much memory as the parent being a copy, but actually thanks to the copy-on-write semantic implemented by most modern operating systems the parent and child process will share the common memory pages.

    However, to maximize CPU usage you can start multiple instances of Redis in the same box and treat them as different servers. At some point a single box may not be enough anyway, so if you want to use multiple CPUs you can start thinking of some way to shard earlier.

    It's not very frequent that CPU becomes your bottleneck with Redis, as usually Redis is either memory or network bound.

    You also might want to check out Redis hardware requirements link, Redis already listed the recommended hardware set up per function.