Redis Bitmap Memory Calculator

Give the highest bit offset you will set and see what it costs. Redis strings are not sparse, so the highest offset decides the allocation whatever the density.

Paste below, or drop a file anywhere on this panel

Or drop a file anywhere on this panel. Nothing is uploaded: the analysis runs in this tab.

The answer appears here

Paste on the left and press Calculate. Nothing leaves this tab.

Examples

Real input you can load into the tool above. Each one shows a different thing going wrong, because that is what the tool is for.

A sparse bitmap

Five thousand bits set across a million offsets, where a set is far smaller

highest-bit: 1000000
set-bits: 5000

Daily active users

One bitmap per day for a month, at a realistic density

highest-bit: 1000000
set-bits: 400000
keys: 30

Common mistakes

These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.

  1. Using a bitmap for sparse ids

    The allocation is decided by the highest id, so one user with id 50 million costs 6 MB on its own.

    Instead:Use a set below roughly 1 in 64 density, or remap ids to a dense range.

  2. Assuming SETBIT is cheap on a new key

    It allocates the whole string up to that offset in one go, which on a large offset is a noticeable pause on the main thread.

    Instead:Pre-size deliberately, or avoid very large offsets.

  3. Forgetting BITCOUNT is O(N)

    It scans the whole string. On a 100 MB bitmap that blocks the server for the duration.

    Instead:Use the range form, or keep a counter alongside.