Skip to content

Monitor index memory allocation

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

Each namespace stores its primary index, secondary index, and set index in a separate memory pool, called an arena. Each arena grows in fixed-size chunks, called stages, and reserves a whole stage at a time. Aerospike fills each stage from start to end, and the allocation point is the position where the next new entry goes. Aerospike Database 8.2.0 reports three figures for each arena: allocated bytes for stages reserved, used bytes for live index elements, and tail bytes for unused space in the newest stage. Use them together to explain the asd process footprint and to predict when an arena reserves another stage. The gap between allocated and used memory can be several GiB.

Applies to: Aerospike Database 8.2.0 and later. Allocation metrics for the primary and secondary indexes require Aerospike Database Enterprise Edition, because index-type and sindex-type are configurable only in Enterprise Edition. set_index_alloc_bytes, process_rss_bytes, and the control group (cgroup) metrics are available in both editions.

Audience: Operators and SREs sizing nodes, setting memory alerts, or investigating asd memory use against a configured budget.

The three numbers

For each index arena, the server reports up to three values.

ValueMetricMeaning
Allocated*_alloc_bytesTotal memory the arena has reserved: number of stages multiplied by stage size.
Used*_used_bytesMemory holding live index elements.
Tail*_tail_bytesUnused space in the newest stage: how much can still be allocated before another stage is reserved.

Record deletion frees space behind the allocation point. Calculate that reusable space as:

reusable space = alloc - used - tail

The following diagram shows where each value lives in an arena with three stages.

stage 0 stage 1 stage 2 (newest)
+-----------------+-----------------+-----------------+
| live | reusable | live | reusable | live | | tail |
+-----------------+-----------------+-----------------+
^
allocation point
<----------- alloc = stage count * stage size ------->

Each new stage is reserved after the previous stage is full. Earlier stages sit entirely behind the allocation point, so only the newest stage has a tail.

Metrics by arena

ArenaAllocatedUsedTail
Primary index, shmemindex_shmem_alloc_bytesindex_used_bytesindex_shmem_tail_bytes
Primary index, pmemindex_pmem_alloc_bytesindex_used_bytesindex_pmem_tail_bytes
Primary index, flashindex_flash_alloc_bytesindex_used_bytesNot reported
Secondary index, shmemsindex_shmem_alloc_bytessindex_used_bytessindex_shmem_tail_bytes
Secondary index, pmemsindex_pmem_alloc_bytessindex_used_bytessindex_pmem_tail_bytes
Secondary index, flashsindex_flash_alloc_bytessindex_used_bytessindex_flash_tail_bytes
Set indexset_index_alloc_bytesset_index_used_bytesNot reported

A namespace reports the allocation metrics that match its configured backing type. For example, index-type shmem reports index_shmem_alloc_bytes.

Flash primary index and set index allocate as follows:

  • Flash primary index. A flash-backed primary index allocates by 4 KiB chunk within a stage. index_flash_alloc_bytes reports the sum of those allocated chunks, so it is a different quantity from the shmem and pmem stage-footprint metrics. Remaining unused space is spread across chunks. The secondary index arena allocates from one allocation point, so a flash-backed secondary index reports a tail.
  • Set index. A namespace holds one set-index arena per data-bearing partition tree per indexed set, and each arena has its own allocation point. set_index_alloc_bytes already includes a 4 KiB stage floor per arena, and remaining per-arena unused space is small next to that floor.

How the budget relates to allocation

Eviction and stop-writes act on used bytes. The eviction supervisor (nsup) compares the combined RAM index usage against indexes-memory-budget using the same numerator as indexes_memory_used_pct, and evict-indexes-memory-pct acts on that value.

*_alloc_bytes reports the larger stage footprint. That allocated figure can sit above indexes-memory-budget while indexes_memory_used_pct remains below 100, because the budget is evaluated against used bytes.

Predict arena growth from the tail

Index stages default to 1 GiB (index-stage-size), so index growth happens in 1 GiB steps. The tail shows how much of the current stage remains.

  • A tail above 0 means the current stage still has unused space. Allocation at the allocation point consumes the tail, and the arena reserves another stage only after the current stage is full. A namespace with 2 GiB of primary index tail absorbs 2 GiB of new index elements, roughly 33 million records at 64 bytes each, before growing.
  • A tail of 0 means the next allocation may reuse deleted space or reserve a new stage. The primary index arena keeps 64 independent free lists. Allocation selects one in round-robin order, and frees return elements to a list determined by element ID, so an allocation can find its list empty and reserve a new stage while the other 63 lists still hold reusable elements.

Read the two values together:

TailCalculated reusable space (alloc - used - tail)ReadingAction
Trending to 0, used still climbingAnyAnother stage is imminentProvision for alloc plus one index-stage-size
FlatGrowingDeletes are landing and being recycledNone. The footprint stays at the highest level reached
Near a full stageAnyA stage was just reservedRoughly 16.7 million records of capacity added per 1 GiB stage
0LargeCapacity exists, but an individual insert can miss its free listAlert. Other measures can still look fine

How reusable the freed space is differs by arena

Freed space is reused differently in each arena.

ArenaFree-list structureWhen reusable space prevents a new stage
Secondary indexOne free list, one allocation pointAlways. Reusable space is interchangeable with tail, so the derived number is usable free space.
Primary index64 free lists; allocation selects round-robin, frees return by element IDWhile the tail is above 0, reusable space absorbs bulk growth. After the tail reaches 0, an individual allocation can miss its free list.
Set indexOne free list per arena, up to one arena per partition tree per indexed setWithin one partition tree and set. A delete in partition 7 creates free space for inserts into that same tree.

Accuracy of the calculated reusable space value

For the primary index, reusable space = alloc - used - tail overstates true space freed by deletes slightly:

  • The allocation point advances in batches of 512 elements, and the remainder of each batch is pushed onto a free list before it is handed out. Across 64 free lists this accounts for at most 64 × 512 × 64 bytes, or about 2 MiB per namespace, which is negligible against a 1 GiB stage.
  • Element 0 is reserved and never allocated, so it counts as one element of reusable space.

For the secondary index arena, use reusable space = alloc - used - tail as an estimate. The arena reserves element zero (about 4 KiB), which the formula counts as reusable space, and alloc, used, and tail are independent unlocked snapshots.

Memory after deletes

After a mass delete against the primary index, index_{shmem,pmem}_alloc_bytes stays at its highest level reached. Freed elements go onto free lists and remain available for reuse up to the previous used value.

The three arenas free space at different times:

ArenaHow space is freedConsequence for the metric
Primary indexFreed elements go onto one of 64 free listsindex_{shmem,pmem}_alloc_bytes only increases and stays at the highest level reached. index_flash_alloc_bytes can decrease when partition trees are destroyed and chunks are freed. index_*_tail_bytes only shrinks between stage additions for shmem and pmem, because the allocation point only moves forward
Secondary indexEvery stage is released when the last element is freedsindex_*_alloc_bytes can drop to 0 in one step, and sindex_*_tail_bytes goes to 0 with it
Set indexStages return when the tree is destroyed, which happens when the set index is removed or the partition stops holding dataset_index_alloc_bytes follows partition ownership in steps. It drops on rebalance or removal

Behavior across a warm restart

The three arenas behave differently across a warm restart:

  • Primary index and secondary index stages are reattached, so index_*_alloc_bytes and sindex_*_alloc_bytes continue from their pre-restart values. The primary index highest level reached, including its accumulated reusable space, survives.
  • Set index stages are heap allocations rebuilt during warm restart before the info service starts, so metrics scrapes do not show a drop to 0 or a climb during resume. The post-restart set_index_alloc_bytes and set_index_used_bytes values can differ from pre-restart values.

Expect the set index graphs to be discontinuous across a warm restart where the other two are continuous.

Reconcile against process RSS

process_rss_bytes reports the resident memory of the asd process. For container capacity, compare cgroup_memory_used_bytes with cgroup_memory_limit_bytes; the control group’s total includes page cache and any other processes in the group, so it can exceed asd’s RSS. The heap_*_kbytes metrics report the allocator’s view and omit shared memory segments and memory-mapped data.

A value of 0 for process_rss_bytes means /proc/self/statm could not be read or parsed. Treat 0 as a failed read.

Control group limits

cgroup_memory_used_bytes and cgroup_memory_limit_bytes report the kernel’s raw usage and limit when the server finds a usable control group with a finite limit. cgroup-mem-tracking controls whether system_free_mem_pct and system_free_mem_kbytes use control-group-aware arithmetic for stop-writes and free-memory reporting.

Expressing allocation as a percentage

The allocation and tail metrics are byte counts. index_flash_alloc_pct is the allocation percentage the server reports. To express another allocation figure as a fraction of a budget, divide by indexes-memory-budget or the relevant mount budget. Both are available through get-config.

indexes_memory_used_pct uses the same denominator and used bytes as its numerator.

View allocation with asadm

Tools 13.1.0 (asadm 5.1.0) and later display these metrics without manual arithmetic:

  • info namespace usage adds an Alloc column to the Primary Index and Secondary Index groups, next to Used, from the allocation metric that matches each namespace’s backing type.
  • info memory -v shows allocated and used bytes for the memory-backed primary, secondary, and set index arenas of each node, next to host memory, cgroup memory, and process heap.

The Alloc% column in info memory is a percentage of the node’s memory capacity, not of indexes-memory-budget.

Next steps