title: 'Managing Memory Usage' sidebar_label: 'Memory' sidebar_position: 31 description: 'Guidelines and best practices for managing memory usage and optimizing performance in Spice.ai Open Source deployments.' keywords:
Effective memory management is essential for maintaining optimal performance and stability in Spice.ai Open Source deployments. This guide outlines recommendations and best practices for managing memory usage.
Memory requirements vary based on workload characteristics, dataset sizes, query complexity, and refresh modes. Recommended allocations include:
refresh_mode: full: 2.5x dataset size.refresh_mode: append: 1.5x dataset size.refresh_mode: changes: Primarily influenced by CDC event volume and frequency; 1.5x dataset size is a reasonable estimate.When using DuckDB persistent storage and disk-spilling memory requirements can be reduced. See DuckDB Data Accelerator.
Refresh modes affect memory usage as follows:
Spice.ai uses DataFusion as its query execution engine. By default, DataFusion does not enforce strict memory limits, which can lead to unbounded usage. Spice.ai addresses this through:
runtime.query.memory_limit parameter defines the maximum memory available for query execution. Once the memory limit is reached, supported query operations spill data to disk, helping prevent out-of-memory errors and maintain query stability. See Spicepod Configuration for details.runtime.query.spill_compression parameter controls how spill files are compressed during query execution. By default, Spice.ai uses Zstandard (zstd) compression, which offers a high compression ratio and helps reduce disk usage when queries spill intermediate data. See Spicepod Configuration for details.DataFusion supports spilling for several operators, but not all operations are currently supported. Notably, the following operations do not support spilling:
Spice.ai integrates with embedded accelerators like SQLite and DuckDB, each with unique memory considerations:
Configure appropriate memory requests and limits in Kubernetes pod specifications to ensure resource availability:
Use observability tools to monitor and profile memory usage regularly. This helps identify and resolve potential bottlenecks promptly.
By following these guidelines, developers can manage memory resources effectively, ensuring Spice.ai deployments remain performant, stable, and reliable.