# Resource configuration

> Configure NiFi storage and resource requests for optimal performance. Set PVC sizes and resource requests for CPU, memory, and persistent storage.

## Volume storage

By default, a NiFi Stacklet creates five different persistent volume claims for flow files, provenance, database, content and state directories. Depending on the NiFi cluster definition, another PVC for file-based authorization is added.

You can find the default sizes of the PVCs in the [NifiCluster reference docs](https://hub.stackable.tech/crds/nifi.stackable.tech/v1alpha1/nificluster?release=26.11#nodes.config.resources.storage) , it is recommended that you configure these volume requests according to your needs.

Storage requests can be configured at role or group level, for one or more of the persistent volumes as follows:

```yaml
nodes:
  roleGroups:
    default:
      config:
        resources:
          storage:
            filebasedRepo:
              capacity: 12Gi
            flowfileRepo:
              capacity: 12Gi
            provenanceRepo:
              capacity: 12Gi
            databaseRepo:
              capacity: 12Gi
            contentRepo:
              capacity: 12Gi
            stateRepo:
              capacity: 12Gi
```

In the above example, all nodes in the default group request `12Gi` of storage the various directories.

## Resource requests

Stackable operators handle resource requests in a slightly different manner than Kubernetes. Resource requests are defined on [role](https://docs.stackable.tech/home/stable/concepts/stacklet/index.md) or [role group](https://docs.stackable.tech/home/stable/concepts/stacklet/index.md) level. On a role level this means that by default, all workers will use the same resource requests and limits. This can be further specified on role group level (which takes priority to the role level) to apply different resources.

This is an example on how to specify CPU and memory resources using the Stackable [Custom Resources](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/):

```yaml
---
apiVersion: example.stackable.tech/v1alpha1
kind: ExampleCluster
metadata:
  name: example
spec:
  workers: # role-level
    config:
      resources:
        cpu:
          min: 300m
          max: 600m
        memory:
          limit: 3Gi
    roleGroups: # role-group-level
      resources-from-role: # role-group 1
        replicas: 1
      resources-from-role-group: # role-group 2
        replicas: 1
        config:
          resources:
            cpu:
              min: 400m
              max: 800m
            memory:
              limit: 4Gi
```

In this case, the role group `resources-from-role` will inherit the resources specified on the role level, resulting in a maximum of `3Gi` memory and `600m` CPU resources.

The role group `resources-from-role-group` has a maximum of `4Gi` memory and `800m` CPU resources (which overrides the role CPU resources).

> **Important:** For Java products the actual used heap memory is lower than the specified memory limit due to other processes in the Container requiring memory to run as well. Currently, 80% of the specified memory limit is passed to the JVM.

For memory, only a limit can be specified, which will be set as memory request and limit in the container. This is to always guarantee a container the full amount memory during Kubernetes scheduling.

A minimal HA setup consisting of 2 NiFi instances has the following [resource requirements](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/):

-   `1500m` CPU request

-   `5000m` CPU limit

-   `8448Mi` memory request and limit

-   `18432Mi` persistent storage


You can find the default resource configuration values in the [NifiCluster reference docs](https://hub.stackable.tech/crds/nifi.stackable.tech/v1alpha1/nificluster?release=26.11#nodes.config.resources) .

## Content archive retention

When a FlowFile’s content claim is no longer referenced, NiFi moves the file into an `archive/` subdirectory of the content repository rather than deleting it immediately. Archived content is what powers **Replay** and **View Content** in the NiFi provenance UI. The operator configures both a time-based and a size-based purge threshold; the provenance audit trail itself is stored in a separate repository and is not affected by content archive retention.

If the operator defaults don’t fit your workload, for example you need a longer replay window, or you want to disable content archiving entirely, override the relevant `nifi.content.repository.archive.*` properties via [configOverrides](https://docs.stackable.tech/home/stable/nifi/usage_guide/overrides/index.md).
