> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/tposs/6.19/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/tposs/6.19/use-cases/load-cases/tposs-hrr.md).

# High request rate

This document describes requirements and configuration needed to achieve a session churn test (sessions setup + sessions termination) with different rates.
All the network interfaces - Diameter Gx, Gy, NASREQ, and RADIUS — are enabled. The load state is stable when on average one million network sessions and `250,000` service sessions are active.

Three different sets of load are described in this document:

- [250 sessions setup and session terminations per second](#250-attachments-per-second)
- [500 sessions setup and session terminations per second](#500-attachments-per-second)
- [1000 sessions setup and session terminations per second](#1000-attachments-per-second)

All the tests described in the document are executed with a similar configuration. The only difference is the number of incoming RADIUS and Diameter requests described above. If there are any differences, they are described in the test descriptions accordingly.

## Test setup

The test represents the `session churn` test with the TPOSS, RADIUS Proxy (RPR), and Diameter Proxy (DPR) components. Three TPOSS instances are used combined into a single cluster. Both RADIUS and Diameter Proxy components are connected to all of them.

The following versions of the components are used:

| Component | Version |
| ---| ---|
| TPOSS | 6.12.0 |
| RPR | 2.1.10 |
| DPR | 1.0.22 |
| MySQL | 8.0.21 |

### TPOSS settings

The test uses TPOSS cluster with 3 instances. The configuration options needed for TPOSS cluster are described in the [high availability](https://docs.cennso.com/components/tposs/6.19/use-cases/availability-cases/tposs-ha.md) document. The generic configuration is described in the [installation](https://docs.cennso.com/components/tposs/6.19/installation/configuration.md) document.

The only features not used during the test are:

  * [TPOSS event hooks](https://docs.cennso.com/components/tposs/6.19/installation/configuration.md#hooks-configuration)
  * [IMEI whitelist](https://docs.cennso.com/components/tposs/6.19/installation/configuration.md#imeisv-whitelist-configuration)

### RPR and DPR settings

Both RPR and DPR proxies are configured to communicate with TPOSS to forward RADIUS and Diameter requests to both sides. For more information on how to configure RADIUS and Diameter relays, go to the [official RPR documentation](https://docs.cennso.com/docs/components/rpr/2.1.10/configuration/proxy-settings) and [official DPR documentation](https://docs.cennso.com/docs/components/dpr/1.0.22/configuration/routing).

If the RADIUS Proxy relay is specified as a hostname, the RADIUS Proxy client tries to resolve it before sending the request. To avoid DNS requests at each RADIUS request, you can use TPOSS Kubernetes [headless service](https://kubernetes.io/docs/concepts/services-networking/service/#headless-services) (`{TPOSS-HELM-RELEASE-NAME}.{NAMESPACE}.svc.cluster-domain.example`) to specify RADIUS Proxy relays towards TPOSS. In general, it is recommended to use the TPOSS Kubernetes headless service to communicate with TPOSS. However, for the purpose of these tests, the IP address of the special TPOSS `{TPOSS-HELM-RELEASE-NAME}-radius` Kubernetes service is used. RPR versions higher than `v2.2.0` already provide support for DNS responses caching. With DNS responses caching, you can continue to use the recommended `tposs-{TPOSS-HELM-RELEASE-NAME}` headless service.

### MySQL settings

MySQL in version `8.0.21` is used without any external plugins. This is the configuration of the MySQL server used during the test:

```
configuration: |-
  [mysqld]
  skip-name-resolve
  max_connections = 151
  wait_timeout=86400
  max_prepared_stmt_count=50000
  table_open_cache=10000
  table_open_cache_instances=64

  # innodb options
  innodb_buffer_pool_size=16G
  innodb_buffer_pool_instances=24
  innodb_log_file_size=2G
  innodb_log_buffer_size=512M
  innodb_flush_log_at_trx_commit=1
  innodb_doublewrite=OFF
  innodb_read_io_threads=8
  innodb_write_io_threads=8
  innodb_flush_method=O_DIRECT
  innodb_change_buffering=none
  innodb_io_capacity=200
  innodb_io_capacity_max=400
  innodb_max_purge_lag_delay=300000
  innodb_max_purge_lag=0
  innodb_page_cleaners=24
  innodb_purge_threads=4
  innodb_adaptive_hash_index=0
  innodb_flush_neighbors=0
  innodb_lru_scan_depth=8192
  innodb_file_per_table=ON
  innodb_max_dirty_pages_pct=90
  innodb_max_dirty_pages_pct_lwm=10

  # partitioning manager
  event_scheduler=ON

  # binlog options
  skip-log-bin
```

`50` database connections at each TPOSS instance are used during the test. Thus, the value of the [**max_connection**](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_connections) MySQL configuration option must be set to at least `151` to connect all TPOSS instances and one extra connection for administrative purposes.

One of the crucial MySQL database option in these tests is [**max_prepared_stmt_count**](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_prepared_stmt_count). Since TPOSS executes each database query as a [prepared statement](https://dev.mysql.com/doc/refman/8.0/en/sql-prepared-statements.html), the MySQL server must be able to create the necessary number of them. The default value of this option is `16382`, but it might not be enough. The required value highly depends on the two following parameters:

- The number of incoming RADIUS and Diameter requests arriving to TPOSS
- The average latency of database queries

The lower latency of the database queries, the more connections from the TPOSS database connection pool is reused. Since the prepared statements are created per database connection, it is worth to increase the default value of the **max_prepared_stmt_count** to `50,000`.

Since only single MySQL instance is used for the tests, the [binary log](https://dev.mysql.com/doc/refman/8.0/en/binary-log.html) is disabled.

## 250 attachments per second

The table presents the number of incoming RADIUS and Diameter requests TPOSS receives during the sessions attachment:

| Request type | requests/s |
| ---| ---|
| RADIUS Access-Request | 250 |
| RADIUS Accounting-Start | 250 |
| Diameter NASREQ-AAR | 250 |
| Diameter Gx-I | 250 |
| Diameter Gy-I | 250 |
| Diameter NASREQ Accounting-Start | 250 |

The table presents the number of incoming RADIUS and Diameter requests TPOSS receives during the sessions update:

| Request type | requests/s |
| ---| ---|
| RADIUS Accounting-Update | 500 |
| Diameter Gy-U | 250 |

The `Validity-Time` (the **scg.diameter.rating_groups_validity_time** configuration option) is set to `900` seconds. The RADIUS Interim-Update requests period is `1800` seconds.

The table presents the number of incoming RADIUS and Diameter requests TPOSS receives during the sessions termination:

| Request type | requests/s |
| ---| ---|
| RADIUS Accounting-Stop | 250 |
| Diameter NASREQ Accounting-Stop | 250 |
| Diameter Gx-T | 250 |
| Diameter Gy-T | 250 |
| Diameter NASREQ Session-Termination-Request | 250 |

The table presents the number of sessions that were active during the test:

| Session type | Number |
| ---| ---|
| Network sessions | 1,000,000 |
| Service sessions | 250,000 |

The table presents the number of database queries executed by TPOSS during the test:

| Read | Write | Update | Delete | Begin/Commit |
|---| ---| ---|---|---|
| ~7460/s | ~2000/s | ~2130/s | ~1500/s | ~3260/s |

The number of `IOPS` on the node with database is around `10,500`.

### Resource usage

Based on the performed test, the following resource usage is expected:

| Component/Resource | Actual usage | Recommended Kubernetes requests/limits |
| ---| ---|---|
| TPOSS CPU | ~2.3 cores (per instance) | 3 |
| MySQL CPU | ~4.2 cores | 5 |
| RPR CPU | ~1.5 cores | 3 |
| DPR CPU | ~2.1 cores | 3 |
| TPOSS memory | ~500MB (per instance) | 1.5G |
| MySQL memory | ~14GB | 18G |
| RPR memory | ~185MB | 500M |
| DPR memory | ~150MB | 500M |

The second column of the table describes resource consumption under normal conditions. The actual resource usage can differ in different environments. One of the main condition that may bring the highest impact is the average latency of database queries. In the case when the normal conditions are violated and any type of edge case happens, TPOSS may require more resources. If the number of incoming requests does not change too much, the CPU usage of TPOSS is stable under any conditions.

If the database queries latency start to grow, the memory consumption of TPOSS start to grow as well. The recommended values are represented in the third column of the table. The values in the third column are presented in the format of the Kubernetes Pod resources definition. For more information, go to the [official Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory).

> [!NOTE]
> MySQL memory usage is conditional and highly depends on the configuration of MySQL in-memory buffers.

## 500 attachments per second

The same setup and configuration of TPOSS and proxies is used in the test for `500` attachments per second.

The only difference in the configuration is the shorter interim period for `update` requests. The `Validity-Time` (the **scg.diameter.rating_groups_validity_time** configuration option) is decreased to `450` seconds. With this value, each service session can receive at least one `update` request. The RADIUS Interim-Update requests period is `900` seconds.

The table presents the number of incoming RADIUS and Diameter requests TPOSS receives during the sessions attachment:

| Request type | requests/s |
| ---| ---|
| RADIUS Access-Request | 500 |
| RADIUS Accounting-Start | 500 |
| Diameter NASREQ-AAR | 500 |
| Diameter Gx-I | 500 |
| Diameter Gy-I | 500 |
| Diameter NASREQ Accounting-Start | 500 |

The table presents the number of incoming RADIUS and Diameter requests TPOSS receives during the sessions update:

| Request type | requests/s |
| ---| ---|
| RADIUS Accounting-Update | 500 |
| Diameter Gy-U | 250 |

The table presents the number of incoming RADIUS and Diameter requests TPOSS receives during the sessions termination:

| Request type | requests/s |
| ---| ---|
| RADIUS Accounting-Stop | 500 |
| Diameter NASREQ Accounting-Stop | 500 |
| Diameter Gx-T | 500 |
| Diameter Gy-T | 500 |
| Diameter NASREQ Session-Termination-Request | 500 |

The table presents the number of database queries executed by TPOSS during the test:

| Read | Write | Update | Delete | Begin/Commit |
|---| ---| ---|---|---|
| ~13700/s | ~4000/s | ~4250/s | ~3000/s | ~3250/s |

The number of `IOPS` on the node with database is around `20,000`.

### Resource usage

Based on the performed test, the following resource usage is expected:

| Component/Resource | Usage | Recommended Kubernetes requests/limits |
| ---| ---|---|
| TPOSS CPU | ~4.3 cores (per instance) | 5 |
| MySQL CPU | ~6.6 cores | 8 |
| RPR CPU | ~2 cores | 4 |
| DPR CPU | ~3.5 cores | 4 |
| TPOSS Memory | ~500MB (per instance) | 1.5G |
| MySQL Memory | ~16GB | 20G |
| RPR Memory | ~200MB | 500M |
| DPR Memory | ~280MB | 500M |

## 1000 attachments per second

The same test was run for `1000` attachments per second but with the increased number of incoming requests.

The only difference in configuration is the shorter interim period for `update` requests. The `Validity-Time` (the **scg.diameter.rating_groups_validity_time** configuration option) is decreased to `225` seconds. With this value, each service session can receive at least one `update` request. The RADIUS Interim-Update requests period is `450` seconds.

The table presents the number of incoming RADIUS and Diameter requests TPOSS receives during the sessions attachment:

| Request type | requests/s |
| ---| ---|
| RADIUS Access-Request | 1000 |
| RADIUS Accounting-Start | 1000 |
| Diameter NASREQ-AAR | 1000 |
| Diameter Gx-I | 1000 |
| Diameter Gy-I | 1000 |
| Diameter NASREQ Accounting-Start | 1000 |

The table presents the number of incoming RADIUS and Diameter requests TPOSS receives during the sessions update:

| Request type | requests/s |
| ---| ---|
| RADIUS Accounting-Update | 1000 |
| Diameter Gy-U | 1000 |

The table presents the number of incoming RADIUS and Diameter requests TPOSS receives during the sessions termination:

| Request type | requests/s |
| ---| ---|
| RADIUS Accounting-Stop | 1000 |
| Diameter NASREQ Accounting-Stop | 1000 |
| Diameter Gx-T | 1000 |
| Diameter Gy-T | 1000 |
| Diameter NASREQ Session-Termination-Request | 1000 |

The table presents the number of database queries executed by TPOSS during the test:

| Read | Write | Update | Delete | Begin/Commit |
|---| ---| ---|---|---|
| ~27500/s | ~8000/s | ~8500/s | ~6000/s | ~3250/s |

The number of `IOPS` on the node with database is around `25,000`.

### Resource usage

Based on the performed test, the following resource usage is expected:

| Component/Resource | Usage | Recommended Kubernetes requests/limits |
| ---| ---|---|
| TPOSS CPU | ~8 cores (per instance) | 9 |
| MySQL CPU | ~16 cores | 20 |
| RPR CPU | ~3.2 cores | 5 |
| DPR CPU | ~6 cores | 8 |
| TPOSS memory | ~500MB (per instance) | 2G |
| MySQL memory | ~20GB | 22G |
| RPR memory | ~400MB | 1G |
| DPR memory | ~200MB | 1G |
