> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/cdf/4.2/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/cdf/4.2/recommendation.md).

# Recommended resource requirements

You can tune the performance of CDF Sender and CDF Receiver by applying proper configuration, for example adjusting available CPU and RAM. Both components store CDRs in NATS, so NATS must be properly configured to handle the expected load and resource usage.

## CDR size

The content of CDRs is mostly optional and the configuration of SMC decides how many of these optional items are present.
With a load generator, as SMC in the SLO test, this is 1.8 kB per CDR.

## CPU

The Helm chart has a CPU limit of 0.1 and this value can lead to such slow starts that Kubernetes heartbeat will believe the pod is dead.

### CDF Receiver

A typical Kubernetes resource recommendation for CDF Receiver is 1 CPU, which is sufficient to handle around 1,000 incoming charging records per second. With 1.5 CPU, CDF Receiver can process up to 2,000 CDRs per second. Performance scales linearly when multiple CDF Receivers are added.

### CDF Sender

In the CDF architecture, there is only one CDF Sender. A typical resource requirement is 1 CPU, which is enough to send around 1,000 CDRs per second. In performance tests, the CDF Sender used less than 6 CPUs to handle 8,000 CDRs per second.

### Influence of NATS stream configuration

In case of a lost connection to charging gateway function (CGF), NATS tries to deliver **nats_create.consumer.max_ack_pending** CDRs every **nats_create.consumer.ack_wait** second.
If **max_ack_pending** is high and **ack_wait** is short, it could create a lot of network traffic and CPU usage.

## RAM

Based on the performed tests, CDF Receiver uses less than 0.5 Gi RAM when it handles 2,000 incoming charging records per second.

CDF Sender must have enough RAM for **sender.cdr_limit_per_cgf** (maximum number of processes that can send CDRs to a CGF at the same time).
Based on the performed tests, CDF Sender uses less than 1.0 Gi RAM when **cdr_limit_per_cgf** is 1,000, which is enough for 8,000 CDR/s sent out.

## Disk space

CDF Sender and CDF Receiver use NATS for storage.
A small part, less than 1 kB, is used for values that need to persist during a restart.
Most storage is for CDRs that must be stored safely until they can be transferred to a CGF.
The optional archive can be as large as desired.

### Generated CDRs

The KPI value for CDF Sender and CDF Receiver is 1,800,000 sessions.
The number of CDRs generated depends on the interim interval.
SMC in production sends charging data every 30 minutes per session.
1,800,000 sessions generating a CDR twice per hour makes 1,000 CDRs per second.

If sessions are not constant, a CDR is created every time a session is released.

### NATS stream

The NATS stream must be able to store CDRs for several days in case the connection to the CGF is lost. For example, if you need to store 1,000 CDRs per second for one day, you must set **nats_create.stream.max_bytes** to 160 GB. Alternatively, if you want to retain data based on time instead of size, set **nats_create.stream.max_age** to 86,400,000,000,000 nanoseconds (one day), and do not set **max_bytes**, as it would limit the storage size.

When configuring the NATS stream using the NATS CLI, you can also enable compression to save storage space. The CLI lets you specify time-to-live (TTL) in units other than nanoseconds for convenience.

## Tuning

Performance-related configuration parameters are described in the [CDF Sender](https://docs.cennso.com/components/cdf/4.2/configuration/ext_sender.md) and [CDF Receiver](https://docs.cennso.com/components/cdf/4.2/configuration/ext_receiver.md) documents.

For the SLO measurements, the only non-default parameter was **receiver.transportOptions.receiveBuffer**, which was set to 1,048,576.
