Operations · Engineering

Running on a 1 GB VM without pretending

Profiles, map size, memory peaks, backups, and the workloads that still do not fit on a tiny host.

A small database can run on a small VM. That does not mean every workload can. The useful question is which part of the footprint is bounded and which part grows with the query.

NonoDB is designed to keep an idle process small and push large memory use into the queries that need it. On a 1 GB host, that distinction decides whether the deployment is comfortable or miserable.

Start with a profile

On a 512 MB–2 GB VM, start with NONODB_PROFILE=small or tiny. The profile fills only variables that are not already set:

Terminal window
NONODB_PROFILE=small
Setting small tiny
Blocking threads 8 4
Open LMDB environments 8 4
Read-cache entries 128 64
Max cached result 64 KiB 32 KiB
Scan workers 2 1
Backfill workers 1 1
Aggregate workers 1 1
TTL sweep interval 10 s 15 s
TTL sweep limit 128 64

Use small on a 1–2 GB VM. Use tiny on 512 MB–1 GB, or when the daemon shares the host with an application.

Explicit environment variables always win over the profile. The profile does not change NONODB_MAP_SIZE.

Map size is not RAM

NONODB_MAP_SIZE is the maximum size of the memory-mapped database. It is an address-space reservation, not a disk allocation and not a RAM reservation.

  • The file grows as data is written.
  • RSS grows with pages actually touched.
  • Virtual size includes the whole reservation; that is not a leak.

The default is 1GiB. If the database reaches the map limit, writes fail. Grow it online:

Terminal window
nonodb-cli map
nonodb-cli resize 4GiB

resize_map waits for active transactions and briefly blocks new ones. It does not restart the daemon or rewrite data. It can only grow the map, and the size must be page-aligned.

What idle actually costs

Representative measurements on the benchmark host:

State RSS PSS
1,000 documents, 3 indexes, idle ~5.1–5.4 MB ~2.6–3.0 MB
1M documents, 3 indexes, idle after restart ~5.1 MB ~2.9 MB
1M documents, after a few reads ~6.4 MB ~4.0 MB
1M documents, after a full scan + sort ~278 MB ~276 MB
1M documents, peak during parallel index backfill ~552 MB —
100k text/fuzzy documents up to ~788 MB peak —

The large numbers are mostly mapped pages and page cache, not Rust heap. A restart drops process RSS to a few MB; the OS may keep pages cached.

On a 1 GB VM, the idle numbers are comfortable. The peak numbers are not. A full scan plus sort, a large index backfill, or a text-index build can consume most of the host.

What fits on 1 GB

Comfortable:

  • a small collection set with indexed reads and writes;
  • time-series ingestion with bounded buckets;
  • a few thousand search documents with small segments;
  • a replica serving reads;
  • a low-traffic API with backups to object storage.

Possible, but measure:

  • 1M documents with a few indexes, if you avoid large sorts and full scans;
  • vector search with a modest index and sq8 quantization;
  • text search with a small corpus;
  • aggregation with a bounded group cardinality.

Not comfortable:

  • parallel index backfill on a large collection;
  • full scans with large sorts;
  • a large text index build;
  • many open databases and high concurrency;
  • running a JVM or another heavy service on the same host.

Tuning for a small host

  • Set NONODB_PROFILE=small or tiny.
  • Reduce NONODB_CACHE_MAX_BYTES if cached results are large.
  • Lower NONODB_AGGREGATE_MAX_DOCS for group-heavy queries.
  • Use find_cursor/aggregate_cursor for large result sets.
  • Avoid deep skip on sorted full scans.
  • Serialize index builds; do not run several at once.
  • Keep NONODB_MAP_SIZE just above the expected high-water mark, then grow online.
  • Leave disk for a compacted backup copy.

Backups on a small disk

A compacted backup is usually smaller than the live file, but it still needs free space. On a 30 GB volume, leave room for:

  • the live database;
  • one compacted copy;
  • Docker images and the OS;
  • snapshots and WAL if PITR is enabled;
  • search and vector sidecars.

Copy backups off the host. A backup on the same small disk is not protection against disk exhaustion.

Swap and the OOM killer

A small VM may swap. Swapping a memory-mapped database is slow but not automatically corrupting. The OOM killer is a bigger risk: it can kill the daemon mid-write.

LMDB is designed so committed transactions survive and interrupted writes do not corrupt the environment. Still, an OOM kill is an unclean shutdown. Check /healthz, logs, counts, and an indexed query after restart.

Disable core dumps for the daemon, or they may fill the disk during a crash.

The honest summary

NonoDB’s idle footprint is small. Its peak footprint depends on the query and the index build. A 1 GB VM is a good fit for a small application, a read replica, or a low-traffic service with indexed access. It is not a fit for large analytical scans, big text indexes, or parallel backfills.

Measure the workload on the host you will actually use. Do not size from an idle RSS number alone.

The operations guide, free-tier guide, and operations guide cover profiles, memory, and capacity.

All engineering notes →Read the docs