top of page

Sharing Cloud CPUs Fairly: Instance Caging and CDB Resource Plans for Consolidated Oracle Databases

OmerNarman
Oct 31
8 min read

Cloud compute is paid for by the core, so consolidation is where the savings are: several databases on one VM, or many PDBs in one container database on an Exadata VM cluster in OCI, Azure, Google Cloud or AWS. The risk is the noisy neighbour. One reporting job uses every CPU on the host, and the order-entry database on the same machine slows to a crawl.


Oracle has two built-in controls for this, both included with Enterprise Edition. Instance caging limits how many CPUs a database instance may use. A CDB resource plan divides a container database's CPU between its PDBs. This post measures the current use, applies both, and shows how to see when a workload is actually being held back.



The Use Case

A 16-core VM in the cloud runs two container databases: SALESCDB, with an order-entry PDB and a reporting PDB, and HRCDB. Several times a week the month-end reports in SALESCDB push the host to 100% CPU, and order entry and HR both slow down. The goal is predictable performance for order entry, a fair share for HR, and the reporting work running only on what is left.


Environment used in this runbook


  • Host: a cloud VM with 16 cores (32 hardware threads), Oracle Linux 8

  • Databases: SALESCDB (PDBs ORDERS and REPORTS) and HRCDB (PDB HR), both Oracle Database 19c (19.24)

  • Edition: Enterprise Edition; Resource Manager and instance caging are included, no extra option is needed

  • Target split: SALESCDB up to 12 CPUs, HRCDB up to 6 CPUs, slight overcommit on purpose



How the Two Controls Work

  • Instance caging: with a Resource Manager plan active, the instance never runs more sessions on CPU at once than its CPU_COUNT parameter allows. Extra sessions wait, and the wait appears as "resmgr:cpu quantum".

  • CDB resource plan: inside one container database, each PDB gets a number of shares. When the CPU is contended, PDBs get CPU in proportion to their shares. A utilization_limit caps a PDB even when the CPU is free.

  • Overcommit: the sum of all CPU_COUNT values may exceed the cores. That keeps CPUs busy when one database is idle, at the cost of some contention when all are busy. Without overcommit (partitioning), each database gets a guaranteed slice.



Step 1: See What the Instance Thinks It Has

Start on each database by checking how many CPUs the instance sees and uses, and whether a resource plan is active. Without a plan, CPU_COUNT is only a hint for sizing and does not limit anything.


SQL

-- On SALESCDB, as SYSDBA in CDB$ROOT

COLUMN stat_name FORMAT A16

SELECT stat_name, value

FROM v$osstat

WHERE stat_name IN ('NUM_CPUS', 'NUM_CPU_CORES', 'NUM_CPU_SOCKETS');

SELECT name, value FROM v$parameter

WHERE name IN ('cpu_count', 'resource_manager_plan');

Expected output

STAT_NAME             VALUE
---------------- ----------
NUM_CPUS                 32
NUM_CPU_CORES            16
NUM_CPU_SOCKETS           1

NAME                           VALUE
------------------------------ ------------------------------
cpu_count                      32
resource_manager_plan

What to expect: 32 CPUs (hardware threads) on 16 cores, CPU_COUNT at its default of all 32, and no resource plan. Both databases currently compete for the whole host without any limit. CPU_COUNT counts threads, so a cage of 12 means 12 threads, roughly six cores' worth of throughput.



Step 2: Measure CPU Use per Database

Before deciding the split, look at how much CPU each database actually used at its busiest. AWR keeps the per-instance CPU rate (Diagnostics Pack licence required).


SQL

-- Run on each database: busiest hours of the last 14 days

SELECT TO_CHAR(TRUNC(end_time, 'HH24'), 'YYYY-MM-DD HH24') AS hour,

ROUND(MAX(maxval) / 100, 1) AS peak_cpus_used

FROM dba_hist_sysmetric_summary

WHERE metric_name = 'CPU Usage Per Sec'

AND end_time > SYSDATE - 14

GROUP BY TRUNC(end_time, 'HH24')

ORDER BY peak_cpus_used DESC

FETCH FIRST 4 ROWS ONLY;

Expected output

HOUR          PEAK_CPUS_USED
------------- --------------
2026-10-30 22           29.6
2026-10-29 22           28.1
2026-10-27 09            9.8
2026-10-26 10            9.4

What to expect: CPU Usage Per Sec is in centiseconds of CPU per second, so dividing by 100 gives CPUs in use. SALESCDB peaks near 30 CPUs at 22:00, during the reports, and stays under 10 during the day. Run the same query on HRCDB; here it peaks around 4. That confirms the noisy neighbour, and shows a cap of 12 for SALESCDB would cut only the reporting peak.



Step 3: Turn On Instance Caging

Instance caging needs two settings: a CPU_COUNT below the host's CPUs, and an active resource plan. In a container database, the built-in DEFAULT_CDB_PLAN is enough to start caging; you replace it with a CDB plan in Step 5. Both parameters are dynamic, so no restart is needed.


SQL

-- On SALESCDB

ALTER SYSTEM SET resource_manager_plan = 'DEFAULT_CDB_PLAN' SCOPE = BOTH;

ALTER SYSTEM SET cpu_count = 12 SCOPE = BOTH;

-- On HRCDB

ALTER SYSTEM SET resource_manager_plan = 'DEFAULT_CDB_PLAN' SCOPE = BOTH;

ALTER SYSTEM SET cpu_count = 6 SCOPE = BOTH;

Expected output

System altered.

System altered.

What this does: SALESCDB may now run at most 12 sessions on CPU at once, HRCDB at most 6. DEFAULT_CDB_PLAN gives every PDB one share, which is fine as a starting point. Together they allow 18 CPUs on a 32-thread host, so both databases are protected from each other and there is spare capacity for the operating system and agents.


Tip: Keep CPU_COUNT at 2 or more for any production instance, and change it in small steps. A very low CPU_COUNT also shrinks the number of background and parallel processes Oracle starts.


Step 4: Confirm the Cage Is Active

Check that the plan is active and that the instance reports the caged CPU count. V$RSRC_PLAN shows the plan in force, and its CPU_MANAGED column tells you whether Resource Manager is actually controlling CPU.


SQL

COLUMN name FORMAT A20

SELECT name, is_top_plan, cpu_managed FROM v$rsrc_plan;

SELECT value AS cpu_count FROM v$parameter WHERE name = 'cpu_count';

Expected output

NAME                 IS_TOP_PLAN CPU_MANAGED
-------------------- ----------- -----------
DEFAULT_CDB_PLAN     TRUE        ON

CPU_COUNT
----------
12

What to expect: The top plan is DEFAULT_CDB_PLAN with CPU_MANAGED ON. If CPU_MANAGED is OFF, no plan with CPU directives is active and CPU_COUNT does not limit anything: check RESOURCE_MANAGER_PLAN, and check that no scheduler window has switched the plan to an empty one.



Step 5: Create a CDB Resource Plan for the PDBs

Now divide SALESCDB's 12 CPUs between its PDBs. ORDERS gets three times the shares of REPORTS and no limit; REPORTS is capped at 50% of the instance's CPU even when the rest is idle, so it can never fill the cage on its own.


SQL

BEGIN

DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA;

DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN(

plan => 'SALES_CDB_PLAN',

comment => 'Orders first, reports capped');

DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(

plan => 'SALES_CDB_PLAN',

pluggable_database => 'ORDERS',

shares => 3,

utilization_limit => 100);

DBMS_RESOURCE_MANAGER.CREATE_CDB_PLAN_DIRECTIVE(

plan => 'SALES_CDB_PLAN',

pluggable_database => 'REPORTS',

shares => 1,

utilization_limit => 50,

parallel_server_limit => 50);

DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA;

DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA;

END;

/

ALTER SYSTEM SET resource_manager_plan = 'SALES_CDB_PLAN' SCOPE = BOTH;

Expected output

PL/SQL procedure successfully completed.

System altered.

What this does: It creates the plan in a pending area, validates it and submits it, then activates it. Under contention ORDERS gets 3 of every 4 CPU units and REPORTS 1. REPORTS can never use more than 50% of the instance's CPU, and no more than 50% of its parallel servers, so a large parallel report cannot take every parallel process either.



Step 6: Review the Plan Directives

Read the directives back from the dictionary. This is also the record to keep for change management and capacity reviews.


SQL

COLUMN pluggable_database FORMAT A26

SELECT pluggable_database, shares, utilization_limit, parallel_server_limit

FROM dba_cdb_rsrc_plan_directives

WHERE plan = 'SALES_CDB_PLAN'

ORDER BY pluggable_database;

Expected output

PLUGGABLE_DATABASE             SHARES UTILIZATION_LIMIT PARALLEL_SERVER_LIMIT
-------------------------- ---------- ----------------- ---------------------
ORA$AUTOTASK                                         90                   100
ORA$DEFAULT_PDB_DIRECTIVE           1               100                   100
ORDERS                              3               100                   100
REPORTS                             1                50                    50

What to expect: Your two directives, plus two that Oracle maintains: ORA$DEFAULT_PDB_DIRECTIVE applies to any PDB without its own directive (a new PDB gets one share), and ORA$AUTOTASK limits automatic maintenance jobs such as statistics gathering. Give every important PDB its own directive rather than relying on the default.



Step 7: Watch Who Is Being Throttled

V$RSRCPDBMETRIC reports, per PDB and per minute, how much CPU each PDB consumed and how long its sessions waited for CPU because of Resource Manager. Run it during the busy period.


SQL

COLUMN pdb_name FORMAT A10

SELECT p.name AS pdb_name,

ROUND(m.cpu_consumed_time / 60000, 1) AS cpus_used,

ROUND(m.cpu_wait_time / 60000, 1) AS cpus_waiting,

m.avg_running_sessions, m.avg_waiting_sessions

FROM v$rsrcpdbmetric m

JOIN v$pdbs p ON p.con_id = m.con_id

ORDER BY p.name;

Expected output

PDB_NAME    CPUS_USED CPUS_WAITING AVG_RUNNING_SESSIONS AVG_WAITING_SESSIONS
---------- ---------- ------------ -------------------- --------------------
ORDERS            5.8           .2                5.814                 .162
REPORTS           5.9         14.1                5.972               14.096

How to read it: The metric times are in milliseconds over a one-minute interval, so dividing by 60,000 gives CPUs. ORDERS is using about 6 CPUs and barely waits. REPORTS is held at its 50% limit (6 of 12) and has about 14 sessions' worth of waiting. That is exactly the intended result: the reports run slower, and order entry is protected.



Step 8: Confirm the Effect on the Host and on Order Entry

Finally, check the host and the user experience. Host CPU should no longer hit 100% during the reports, and the order-entry response time should stay where it is during the day.


SQL

-- On SALESCDB, during the 22:00 report run

COLUMN event FORMAT A22

SELECT event, total_waits,

ROUND(time_waited_micro / 1e6) AS seconds_waited

FROM v$system_event

WHERE event = 'resmgr:cpu quantum';

SELECT ROUND(value) AS host_cpu_pct

FROM v$sysmetric

WHERE metric_name = 'Host CPU Utilization (%)'

AND group_id = 2;

Expected output

EVENT                  TOTAL_WAITS SECONDS_WAITED
---------------------- ----------- --------------
resmgr:cpu quantum         1842310          31046

HOST_CPU_PCT
------------
          61

What to expect: "resmgr:cpu quantum" waits appear: they are the time sessions spent queued by the cage or the plan. Host CPU is around 60% during the report run instead of 100%, leaving room for HRCDB and the operating system. In AWR or ASH, check that these waits fall almost entirely on REPORTS sessions; if ORDERS sessions wait on it too, raise its shares or the instance CPU_COUNT.



Step 9: Keep the Plan in Force

A few things undo Resource Manager quietly. Check them once, and add them to your regular health checks:


  • Maintenance windows switch to their own resource plan at night. Set the windows' plan to your CDB plan (DBMS_SCHEDULER.SET_ATTRIBUTE on each window's resource_plan attribute), or the cage loosens during the reports.

  • Instance restarts keep the plan only if it was set with SCOPE = BOTH or SPFILE, as in this post.

  • New PDBs get the default directive. Add a directive for each one as part of the PDB creation runbook.

  • Cloud resizing: when you scale the VM or the Exadata VM cluster's OCPUs or ECPUs, revisit every CPU_COUNT. Scaling up without raising them leaves the new cores unused.


SQL

-- Is any scheduler window going to switch the plan?

COLUMN window_name FORMAT A18

COLUMN resource_plan FORMAT A24

SELECT window_name, resource_plan, enabled

FROM dba_scheduler_windows

WHERE enabled = 'TRUE'

ORDER BY window_name;

Expected output

WINDOW_NAME        RESOURCE_PLAN            ENABL
------------------ ------------------------ -----
FRIDAY_WINDOW      DEFAULT_MAINTENANCE_PLAN TRUE
MONDAY_WINDOW      DEFAULT_MAINTENANCE_PLAN TRUE
SATURDAY_WINDOW    DEFAULT_MAINTENANCE_PLAN TRUE
SUNDAY_WINDOW      DEFAULT_MAINTENANCE_PLAN TRUE
THURSDAY_WINDOW    DEFAULT_MAINTENANCE_PLAN TRUE
TUESDAY_WINDOW     DEFAULT_MAINTENANCE_PLAN TRUE
WEDNESDAY_WINDOW   DEFAULT_MAINTENANCE_PLAN TRUE

What this does: It lists the maintenance windows and the plan each one activates. Here every window still uses DEFAULT_MAINTENANCE_PLAN, so from 22:00 the CDB plan would be replaced. Set each window's resource plan to SALES_CDB_PLAN (or a plan that includes the same PDB directives), then re-run the query.



Summary

Consolidating Oracle databases in the cloud only saves money if one workload cannot starve the others. Check CPU counts and plans with V$OSSTAT and V$PARAMETER, measure peak CPU per database from AWR, then cap each instance with CPU_COUNT and an active resource plan. Inside each container database, give PDBs shares and utilization limits with a CDB resource plan, review the directives, and watch V$RSRCPDBMETRIC and "resmgr:cpu quantum" to see who is being held back. Finally, make sure maintenance windows, restarts, new PDBs and cloud resizing do not quietly undo the plan.

Recent Posts

See All

Comments


bottom of page