Sidekiq: How to check the maximum client Redis database size

Posted . Visible to the public.

You can check the maximum client Redis database size in Sidekiq with this command.

Sidekiq.redis { |redis| puts redis.info.fetch('maxmemory_human') }
#=> 512.00M

If you just want the maximum database size for a known Redis database URL you can use the Redis Ruby client Show archive.org snapshot or the Redis CLI:

Redis database size via Ruby client

irb(main):002> Redis.new(url: 'redis://localhost:16380/1').info.fetch('maxmemory_human')
=> "512.00M"

Redis database size via CLI

$ redis-cli --port 16380 --database 1 INFO memory | grep maxmemory_human
maxmemory_human:512.00M

Memory footprint

If you want to calculate the estimated Redis memory usage of a job, you can measure the consumed memory usage before and after the job was enqueued. For a simple job like Foo.perform_async(1) the memory footprint is around 508 bytes. Here is a short table to get an overview about an estimated memory footprint with many jobs enqueued.

number of jobs 300 byte (small job) 800 bytes (large job)
100 30 kilobyte 80 kilobyte
1.000 300 kilobyte 800 kilobyte
10.000 3 megabyte 8 megabyte
100.000 30 megabyte 80 megabyte
1.000.000 300 megabyte 800 megabyte
Last edit
Emanuel
License
Source code in this card is licensed under the MIT License.
Posted by Emanuel to makandra dev (2025-04-09 05:48)