Native Bucket Inventory (NBI)
Native Bucket Inventory (NBI)
Native bucket inventory (NBI) lets AIS create and serve a local snapshot of a remote bucket namespace.
It is designed for very large, read-mostly buckets - for example, training and inference datasets - where repeatedly listing the remote backend is expensive, slow, and operationally noisy.
Native bucket inventory (NBI) was introduced in v4.3 and is stable as of 4.4.
Inventories are currently created manually: AIS does not yet provide built-in periodic refresh or automatic resynchronization.
This document occasionally references Go types and constants from the AIS codebase. For SDK usage, see the Go API and Python SDK documentation.
Table of Contents
- Motivation
- Supported buckets
- Overview
- System bucket
- Creating an inventory
- Monitoring inventory creation
- Showing inventories
- Listing via inventory
- Inventory metadata
- Small buckets and empty local inventories
- Limitations and validation
- Examples
- Performance
Motivation
NBI replaces the older S3-specific inventory path.
Compared to that legacy approach, NBI is:
- AIS-native: created and consumed via AIS API, CLI, and xactions
- backend-agnostic: works with remote buckets generally, not only S3
- format-independent: does not depend on provider-generated inventory formats such as CSV, ORC, or Parquet
- operationally simpler: does not require provider-specific scripts or external tooling
In practice, NBI turns repeated remote listing into a two-step workflow:
- create a reusable snapshot once
- serve subsequent listings from that stored snapshot
Supported buckets
NBI applies to remote buckets only: cloud buckets (S3, GCS, Azure, OCI) and remote AIS buckets.
It is not currently supported for in-cluster ais:// buckets. The main reason is simple: NBI exists to avoid the latency and repeated backend traffic of remote listing. For local AIS buckets, namespace metadata is already local and served at native AIS speed, so an additional inventory layer would bring little practical benefit.
A point-in-time snapshot of an in-cluster bucket may still be a valid future use case, but that is not part of the current implementation.
Overview
At a high level, NBI has two phases:
- create a reusable inventory snapshot for a remote bucket
- list from that snapshot instead of re-walking the remote backend
The key design point is that inventories are stored as a flat, lexicographically ordered snapshot of object names plus selected properties. Listing behavior is derived from that stored snapshot.
Create path
When a user creates an inventory:
- The proxy initiates a distributed two-phase operation across all targets.
- During the Begin phase, each target validates the request, checks capacity, ensures that no other
create-inventoryjob is running for the same bucket, and enforces the current one-inventory-per-bucket limit. - If
--forceis specified, any existing inventory for the bucket is removed first. - During Commit, each target runs a
create-inventoryxaction: it lists the remote bucket, keeps only the object names that belong to it under the current cluster map, and writes them locally as inventory chunks.
In the current implementation, all targets independently list the remote backend. A future optimization may designate a single target to list once and distribute the results.
Listing path
When a user lists with --inventory, AIS serves the request from NBI.
The flow is:
- The request arrives at the proxy as a normal list-objects operation.
- AIS sets the
LsNBIflag internally and switches to the inventory-backed path. - The proxy broadcasts the request to all targets.
- Each target reads its local inventory chunks and returns its portion.
- The proxy merges the per-target responses into a single sorted result.
The result is a normal AIS list response, but without walking the remote backend on every call.
S3-compatible clients may also request NBI-backed listing by sending the
Ais-Bucket-Inventory: trueheader;Ais-Inv-Namemay be used to select a specific inventory.
Example
The same ais ls without --inventory produces the same namespace view but re-walks the remote backend each time.
System bucket
Inventories are stored as chunked objects in a designated system bucket - a special AIS bucket whose name starts with a dot (.).
System buckets are AIS infrastructure and are not intended for direct user access. The dot-prefix naming convention (
.sys-*) is reserved. For details on naming rules, visibility, and future plans, see System Buckets.
The first and currently only system bucket is:
It is created automatically on the first inventory creation request. There is no need to create it manually.
Creating an inventory requires admin permissions. When AIStore is deployed with the Authentication Server (AuthN), the operation requires admin permissions. Clusters without AuthN do not enforce this check.
Creating an inventory
Use ais nbi create to create a native bucket inventory for a remote bucket:
Notes
- Inventory creation is manual.
- Inventory names are optional, but if specified they must be unique for the given bucket.
- When omitted, AIS generates a unique inventory name automatically (for example,
inv-Tp4nR7kWx). --forceremoves any existing inventory for the bucket first and then proceeds with creation.--names-per-chunkis an advanced tuning knob that overrides the default chunk size.
Internally, the control message is:
Defaults and stored properties
Inventory creation validates and normalizes the embedded LsoMsg.
Current behavior includes:
continuation_tokenmust be emptystart_afteris not supported- several list flags are rejected because they do not make sense for inventory creation
LsNoDirsis always set internally
The default stored properties are:
namesizecached
If properties are explicitly requested, AIS still adds cached.
Advanced tunables:
- default
names_per_chunk:2 * MaxPageSizeAIS(20K) - minimum
names_per_chunk:2 - maximum
names_per_chunk:64 * MaxPageSizeAIS(640K)
Monitoring inventory creation
Inventory creation is a distributed xaction, so it appears in regular job monitoring:
Each target stores only the subset of names that belongs to it under the current cluster map. The total is the size of the full bucket namespace captured by the inventory.
Showing inventories
Use ais show nbi to inspect existing inventories.
As with other
ais showsubcommands,ais show nbiis an alias forais nbi show.
Default output shows a compact view, including object count:
Verbose output includes additional metadata:
For example:
Listing via inventory
Once an inventory has been created, use it by adding --inventory to a regular ais ls command:
--inventory now means NBI-backed listing.
This is still a normal list-objects request. The difference is that AIS sets the LsNBI flag internally and serves the request from pre-stored inventory chunks rather than walking the remote backend.
In the Python SDK, the corresponding flag is ListObjectFlag.NBI.
Pagination
When listing via NBI, page size is best-effort and approximate.
Because NBI listing is distributed across targets, each target returns an approximate share of the requested page size, subject to local chunking and minimum bounds. This behavior is intentional: it reduces roundtrips and improves list latency.
How inventory-backed listing works
When inventory-backed listing is requested, AIS serves the request from pre-stored inventory chunks on each target rather than walking the remote backend.
The flow is:
-
A list-objects-page request with
--inventoryarrives at the proxy. -
The proxy broadcasts the request to all targets.
-
Each target seeks to the first inventory name greater than the provided continuation token within its local, lexicographically ordered chunks.
-
Each target returns its next locally sorted batch, together with its own continuation token if more names remain.
-
The proxy merges the returned names into a single sorted stream and applies min-token logic:
- the global continuation token is the minimum non-empty per-target continuation token
- the merged result is truncated to names not greater than that minimum token
Because continuation tokens are literal object names rather than opaque cursors, the process is deterministic, stateless on the proxy, and relatively easy to reason about.
Repeated listing therefore avoids re-walking the remote backend.
Non-recursive listing
Inventory creation always stores a flat snapshot. Non-recursive behavior, when requested during listing, is derived later as a view over that flat snapshot rather than stored as a separate hierarchical inventory format.
That distinction is important:
- creation remains flat and recursive by design
- listing may still present immediate files and subdirectories only
Inventory metadata
AIS stores metadata alongside each inventory:
This metadata is surfaced by ais show nbi, especially in verbose mode.
Small buckets and empty local inventories
When an inventory contains relatively few object names compared with the number of targets, some targets may end up with no local inventory entries.
That is expected. In such cases, a target still stores a valid local inventory object with zero size, zero chunks, and valid NBI metadata. This allows AIS to distinguish between:
- inventory exists but is empty on this target
- inventory does not exist
That distinction matters for correct EOF behavior during distributed listing.
Limitations and validation
NBI is intentionally narrower than general remote listing.
A useful mental model is:
- inventory creation is a snapshot-building job
- inventory listing is a fast read path over that stored snapshot
Those two phases do not accept the same controls.
Why creation is narrower than regular listing
Inventory creation is not an ad hoc ls request. It builds a reusable artifact that must be:
- complete within the requested scope
- deterministic for a given bucket, prefix, property set, and cluster map
- easy to store, merge, and paginate later
- represented as a flat, lexicographically ordered namespace snapshot
That is why several options that make sense for a live list request do not make sense during inventory generation.
Restrictions during inventory creation
Restrictions during inventory-backed listing
In short, NBI is optimized for fast, repeated listing of a previously captured bucket snapshot.
Examples
Create, inspect, and list
Remote AIS bucket
Where inventories are stored
Performance
A latency-vs-scale benchmark comparing NBI listing, regular AIS remote listing, and direct S3 access (boto3) from 1K to 80K objects is available at python/tests/perf/nbi/.