Tuesday, January 18, 2022

Using Auto Scaling in ATP

Autonomous Transaction Processing (ATP) databases allows auto scaling where OCPU scale up 3 times the baseline OCPU count. This feature is enable by default.

This post looks use of auto scaling in ATP-S.
The test ATP DB was created without auto scaling enabled and with just 1 OCPU (baseline OCPU).

At this stage the cpu count parameter values show 2 which include CPU threading (2 x OCPU).
SQL> show parameter cpu

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------
cpu_count                            integer     2
cpu_min_count                        string      2
This cpu_count is also reflected in the performance hub where average active session count max value is shown as 2 when maximum thread checkbox is selected.

Auto scaling could be enabled on a ATP that was created without auto scaling by selecting manage scaling under more actions buttion.


This will result in a work request and tile for the ATP will show scaling in process.

In the end ATP would have auto scaling enabled.

With the auto scaling enabled the CPU parameters and utilization information are shown with respect to the maximum OCPU that could be used. For example the cpu count now shows 6. This is calculated by multiplying the maximum OCPUs possible with auto scaling when baseline OCPU is 1, which is 3 and threads per OCPU which is 2.
SQL> show parameter cpu

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------
cpu_count                            integer     6
cpu_min_count                        string      6
The performance hub average active session graph also shows the maxmimum as 6.
The CPU utilization graph shown in the service console reports utilization based on this maximum allowed OCPU count (in above case 6). This is mentioned in the Oracle documentation.
When the DB load increases the database automatically allocate more CPU. However, this doesn't change the OCPU count shown in the Autonomous Database Details page. The allocation of OCPUs due to auto scaling could be observed in the number of OCPUs allocated graph which is available in service console.
Below graph shows how OCPUs were allocated (and deallocated) as CPU utilization increased (and decreased).

There's no database query mentioned in the ATP-S related documentation to get the OCPU count used by the ATP DB when auto scaling is enabled. However, for ATP-D the documentation mentions the following query to get the OCPUs the database is currently using.
SELECT AVG_RUNNING_SESSIONS/2 FROM V$RSRCPDBMETRIC;
This query also returns values in ATP-S as well, which are more or less accurate to the nearest integer that the number of allocated OCPU graph shows.
The baseline OCPU count could be increased manually while auto scaling is enabled. In this case the baseline OCPU was increased to 2.

The CPU count values and graph maximum are adjusted to reflect the new baselne and the auto scaling maximum. cpu_count now shows 12 which is ocpu baseline 2 x 3 (maximum OCPUs with auto scaling) x 2 (threads).
SQL> show parameter cpu

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------
cpu_count                            integer     12
cpu_min_count                        string      12

If auto scaling is disabled at this stage the cpu count and graph maxmimum settle at the new baseline value (2 in this case).

cpu count is 2 OCPUs x 2 (threads)
SQL> show parameter cpu

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
cpu_count                            integer     4
cpu_min_count                        string      4