Posted 6 months ago. Visible to the public.

How to fix parallel_tests with Redis on powerful machines

When you have a powerful machine with many CPU cores, you might run into an error like

Copy
ERR DB index is out of range (Redis::CommandError)

This is because Redis defaults to at most 16 databases (0 to 15) and running tests in parallel might exceed that (your tests might run on databases 1..n or 2..(n+1)).

You can increase that limit:

  1. Get number of CPUs of your machine.

    Copy
    nproc --all
  2. Open up Redis configuration file.

    Copy
    sudo vim /etc/redis/redis.conf
  3. Find databases row and increase it, e.g. set to CPU count + 2:

    Copy
    databases 18
  4. Save and close config file, then restart Redis:

    Copy
    sudo service redis-server restart
  5. Confirm your configuration has been updated. The following command should return "OK".

    Copy
    redis-cli select `nproc --all`

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Daniel Straßner
Last edit:
5 months ago
by Arne Hartherz
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Daniel Straßner to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more