Optimizing for resource
Diagnostic guide for high CPU, memory, or destination-cost usage: symptom table, tuning order, and Iceberg-load memory/volume guidance.
Use this guide when a pipeline runs correctly but consumes too much CPU, memory, or destination capacity.
Resource symptoms
Memory spikes during extraction
Pages or batches are too large for the data shape.
Reduce page_size; inspect nested or wide columns.
Memory spikes during load
Loader batches are too large or DATA_WRITER__FILE_MAX_BYTES is set too high for the table shape.
Reduce loader_file_size or lower DATA_WRITER__FILE_MAX_BYTES; review nested fields.
CPU is high and throughput is high
The pipeline may simply be busy.
Check whether runtime is acceptable before tuning.
CPU is high and throughput is low
Backpressure, expensive normalization, or retries.
Check logs and stage-level metrics.
Destination cost rises
File count, partitions, clustering, or write strategy may be inefficient.
Review Optimize sink datasets.
Tuning order
Lower
page_sizebefore increasing memory limits.Lower
extract_parallelismif parallel reads overwhelm memory or source limits.Lower
loader_file_sizeorDATA_WRITER__FILE_MAX_BYTESif individual load batches are too large.Reduce nested expansion with
max_table_nestingwhen the source emits wide nested records.Confirm
incremental_strategyis appropriate. Rewriting a large table on every run is expensive.Scale compute only after config-level changes are understood.
Resource Sizing Checklist
The configured memory limit should be higher than the observed peak with a practical buffer.
CPU limits should not throttle a run that is otherwise healthy.
Scheduled pipelines should not overlap unless concurrency is intended.
Destination write capacity should match the configured load concurrency.
Lakehouse / Iceberg loads: when resource optimization is safe
Running Lakehouse (Iceberg) loads entirely on Nilus defaults gives the lowest memory footprint, but the time penalty depends heavily on table shape:
Wide tables (100+ columns): The default config is almost as fast as a fully time-tuned run. It is only ~3–11 minutes slower and saves meaningful memory. Resource optimization is a good default here.
Narrow tables (few columns, very high row count): The penalty is severe. Defaults can run 34 minutes to nearly two hours slower than a time-tuned run. Do not resource-optimize narrow tables unless time genuinely does not matter.
If a Lakehouse load is being OOMKilled, attach a persistent volume for writable scratch space via spec.use.volumes rather than only shrinking buffers. See Tuning Large Lakehouse (Iceberg) Loads for benchmarked configurations.
Knob reference
The following settings reduce peak memory and CPU usage. For throughput tuning, see Optimizing for time.
page_size (source)
source.options
50000 (rows per page)
integer
Controls the in-memory writer buffer (rows held before flush). The dominant memory consumer during extraction. Despite the name, it does not control source-side pagination for SQL sources. It controls the writer buffer.
Pipeline is OOMKilled
Lower page_size (try 25000 or 10000)
Smaller buffer per page.
Source is hammered with too many small queries
Raise page_size (try 100000+)
Fewer, larger reads.
Wide rows (1 KB+) blow the runtime memory
Lower page_size
Page memory bound is roughly page_size x row_bytes.
Tuning range: 10000 to 150000 is normal.
Raise page_size toward 100000 or more only when the source is chunky and memory is ample.
extract_parallelism (source)
source.options
5
integer
Number of concurrent extraction workers per pipeline. Each worker holds its own page buffer. Lower this first if memory spikes during extraction or the source throttles. For throughput tuning, see Optimizing for time.
Tuning range: 2 to 8 for most pipelines.
loader_file_size (sink)
sink.options
100000 (rows per file)
integer
Very large files cut commit overhead but raise peak memory on the load side, especially for Lakehouse/Iceberg, where the runtime buffers each file before committing the snapshot. If load-phase memory spikes, lower it, but watch the small-file trade-off.
LOAD__WORKERS (env var)
spec.use.projection.projections.envVars
engine default (typically 5)
integer
More loader workers means more concurrent write buffers in memory. Lower it on tight pod budgets or shared runtimes. (Throughput angle in Optimizing for Time.)
Sampling to cut width and startup cost
For testing and validation, limiting the columns extracted can significantly reduce memory and startup time.
sql_exclude_columns is unset by default and accepts a comma-separated list. It drops specific columns during extraction. Use it to remove large blob or debug columns that are not needed downstream:
sql_reflection_level: controls how thoroughly Nilus reflects the source schema before extraction.
source.options
full
minimal, full, full_with_precision
minimalreflects column names and nullability. Nilus infers types from the data. Use it for the fastest startup and lowest schema-metadata memory.fullreflects column names, nullability, and data types, but not precision or scale.full_with_precisionalso reflects type precision, scale, and length, such asNUMERIC(10,2)andVARCHAR(255).
Use minimal for very wide source tables with 1,000 or more columns. It reduces startup work and memory, but type inference is less precise. Set type_hints for columns that need exact typing.
Related docs
Last updated
Was this helpful?