LAB 59 ‐ Compartment Quota - DevWithNehaCloud/Oracle-Cloud-Infrastructure-wiki GitHub Wiki
A Compartment Quota in Oracle Cloud Infrastructure (OCI) is used to control and restrict the amount of resources that can be consumed within a specific compartment.
It allows administrators to define a maximum limit for supported resources such as:
- Compute OCPUs
- Memory
- Storage
- Other supported OCI resources
Unlike Service Limits, which are defined by Oracle for the tenancy, Compartment Quotas are administrator-defined limits used to control resource consumption within a compartment.
The objective of this practical was to verify that a Compartment Quota can restrict Compute resource consumption.
Our requirement was to restrict a compartment so that only two 1-OCPU VM.Standard.E4.Flex instances could be created.
We achieved this by setting the E4 Compute OCPU quota to 2 OCPUs.
Compartment
→ E4 Compute Quota = 2 OCPUs
→ Instance 1 = 1 OCPU → Allowed ✅
→ Instance 2 = 1 OCPU → Allowed ✅
→ Instance 3 = 1 OCPU → Restricted ❌
For this testing, we used:
Shape: VM.Standard.E4.Flex
OCPU per Instance: 1
| Instance | Shape | OCPU |
|---|---|---|
| Instance 1 | VM.Standard.E4.Flex | 1 |
| Instance 2 | VM.Standard.E4.Flex | 1 |
| Instance 3 | VM.Standard.E4.Flex | 1 |
Configured quota:
E4 Compute Quota = 2 OCPUs
Therefore:
- Instance 1 → 1 OCPU → Allowed ✅
- Instance 2 → 1 OCPU → Allowed ✅
- Instance 3 → 1 OCPU → Restricted ❌
The relevant E4 Compute quota is:
standard-e4-core-count
OCI Compartment Quotas are configured using quota policy statements.
The basic syntax is:
set <service-family> quota <quota-name> to <value> in compartment <compartment-name>
For E4 Compute OCPU quota, the relevant values are:
Service Family: compute-core
Quota: standard-e4-core-count
Example:
set compute-core quota standard-e4-core-count to 2 in compartment Test-Compartment
This means that the specified compartment can consume a maximum of 2 E4 Compute OCPUs under this quota.
Created:
- Shape:
VM.Standard.E4.Flex - OCPU:
1
Instance 1 → Created Successfully ✅
Quota calculation:
- Configured Quota = 2 OCPUs
- Used = 1 OCPU
- Remaining = 1 OCPU
Created another:
- Shape:
VM.Standard.E4.Flex - OCPU:
1
Instance 2 → Created Successfully ✅
Quota calculation:
- Configured Quota = 2 OCPUs
- Used = 2 OCPUs
- Remaining = 0 OCPU
At this point, the complete E4 OCPU quota has been consumed.
Attempted to create another:
- Shape:
VM.Standard.E4.Flex - OCPU:
1
The resource requirement becomes:
Existing Usage = 2 OCPUs
New Request = 1 OCPU
Total Required = 3 OCPUs
However, the configured quota is only:
Maximum Allowed = 2 OCPUs
Therefore, the third instance could not be created under the configured resource restriction.
During our practical test, the third instance creation resulted in an:
Out of Capacity
error.
Note: An
Out of Capacityerror can have multiple causes in OCI, including actual infrastructure capacity limitations. Therefore, when documenting a quota test, the configured quota and current resource usage should also be verified.
| Test | Instance | OCPU Requested | Result |
|---|---|---|---|
| 1 | E4 Flex Instance 1 | 1 | ✅ Created |
| 2 | E4 Flex Instance 2 | 1 | ✅ Created |
| 3 | E4 Flex Instance 3 | 1 | ❌ Restricted |
Configured E4 Quota = 2 OCPUs
Instance 1 = 1 OCPU
Instance 2 = 1 OCPU
Total Used = 2 OCPUs
When Instance 3 was requested:
Existing Usage = 2 OCPUs
Additional Request = 1 OCPU
Total Required = 3 OCPUs
Configured Quota = 2 OCPUs
Therefore:
3 OCPUs Required > 2 OCPUs Allowed
→ Third Instance Creation Restricted ❌
- Compartment Quota is used to control resource consumption within a compartment.
- Quotas are configured by administrators.
- Quotas are different from Service Limits.
- A quota can restrict Compute resources based on supported resource types.
- For
VM.Standard.E4.Flex, the relevant E4 OCPU quota isstandard-e4-core-count. - By configuring the quota to 2 OCPUs, two 1-OCPU E4 Flex instances can consume the available quota.
- A third 1-OCPU instance would require a total of 3 OCPUs, exceeding the configured quota.
- Quotas help with:
- Resource governance
- Cost control
- Preventing uncontrolled resource consumption
- Environment-level resource management
Consider an organization with separate compartments for different environments:
Development
→ E4 Quota = 10 OCPUs
Testing
→ E4 Quota = 5 OCPUs
Production
→ E4 Quota = 50 OCPUs
This allows an organization to control how much Compute capacity each environment can consume.
For example, if the Testing compartment has an E4 quota of 5 OCPUs, it can consume up to 5 E4 OCPUs according to the configured quota.
Once the configured quota is fully consumed, additional instances requiring the same quota resource cannot be provisioned within that limit.
In this practical, we used an OCI Compartment Quota to control E4 Compute resource consumption.
We configured:
Quota: standard-e4-core-count
Maximum: 2 OCPUs
We then created two:
VM.Standard.E4.Flex instances
with:
1 OCPU each
Both instances were created successfully because their combined usage was:
1 + 1 = 2 OCPUs
When we attempted to create a third 1-OCPU instance, the total required capacity became:
1 + 1 + 1 = 3 OCPUs
which was beyond the configured quota of:
2 OCPUs
This practical demonstrates how OCI Compartment Quotas can be used to control and govern Compute resource consumption within a compartment.
Navigation Menu → Governance & Administration → Tenancy Management → Quota Policies
Create two instances using the VM.Standard.E4.Flex shape, with 1 OCPU assigned to each instance.
Getting an error while creating the third instance in the same compartment because the configured quota limit has been reached.