OCI Cost Optimization Strategies
Reduce OCI spending with universal credits, reserved capacity, autoscaling, and cost analysis tools.
Prerequisites
- Active OCI tenancy with running workloads
- Access to OCI Cost Analysis and Budgets
Cost Optimization on Oracle Cloud Infrastructure
OCI was designed with cost-competitive pricing as a core principle. Oracle undercuts AWS, Azure, and GCP on many services, particularly compute, networking (10 TB/month free outbound data transfer), and database workloads. However, cost optimization still matters because unmanaged cloud spending can grow quickly, even on the most cost-effective platform. The key is to combine OCI's structural pricing advantages with smart resource management and governance practices.
This guide covers OCI's pricing models, Universal Credits, cost analysis tools, budgets and alerts, right-sizing strategies, autoscaling, storage optimization, and organizational governance patterns that keep your cloud spending efficient as your usage grows.
OCI Pricing Advantages
OCI offers several structural pricing advantages over other clouds: 10 TB/month free outbound data transfer (vs. 100 GB on AWS/Azure), no cost for the Kubernetes control plane, OCPU pricing that maps to physical cores (1 OCPU = 2 vCPUs), off-box networking with no performance variability, and an Always Free tier that never expires. These advantages mean that many workloads cost 30-60% less on OCI compared to other clouds before any optimization effort.
Understanding OCI Pricing Models
OCI offers two primary pricing models: Pay As You Go (PAYG) and Universal Credits. Understanding the difference is essential for forecasting and controlling costs.
Pay As You Go vs Universal Credits
| Feature | Pay As You Go | Universal Credits |
|---|---|---|
| Commitment | None, no minimum spend | Annual commitment ($1K-$10M+/year) |
| Discount | List price | Up to 60% off list price |
| Flexibility | Use any service, any time | Credits apply to any OCI service |
| Billing | Monthly based on usage | Credits drawn down monthly |
| Unused credits | N/A | Expire at end of commitment term |
| Best for | Testing, small workloads, unpredictable usage | Production workloads, predictable spend |
| Support | Must purchase separately | Included (Premier Support) |
Universal Credits Are Flexible
Unlike AWS Reserved Instances or Azure Reserved VMs that commit you to specific instance types and regions, OCI Universal Credits are truly universal: they can be applied to any OCI service in any region. If your workload changes, your credits still apply. This flexibility makes Universal Credits lower risk than reserved capacity commitments on other clouds. The minimum annual commitment is typically $1,000, making it accessible even for small teams.
Cost Analysis and Visibility
OCI provides Cost Analysis, a built-in tool for understanding your spending patterns. Cost Analysis lets you filter and group costs by service, compartment, tag, region, and resource, with daily or monthly granularity. You can create custom reports, save frequently-used queries, and export data for external analysis.
# View current month's costs by service
oci usage-api usage-summary request-summarized-usages \
--tenant-id <tenancy-ocid> \
--time-usage-started "2026-03-01T00:00:00Z" \
--time-usage-ended "2026-03-14T23:59:59Z" \
--granularity "MONTHLY" \
--group-by '["service"]' \
--query-type "COST" \
--query 'data.items[].{service:"service", cost:"computed-amount", currency:"currency", unit:"unit"}' \
--output table
# View costs by compartment
oci usage-api usage-summary request-summarized-usages \
--tenant-id <tenancy-ocid> \
--time-usage-started "2026-03-01T00:00:00Z" \
--time-usage-ended "2026-03-14T23:59:59Z" \
--granularity "MONTHLY" \
--group-by '["compartmentPath"]' \
--query-type "COST"
# View daily cost trend
oci usage-api usage-summary request-summarized-usages \
--tenant-id <tenancy-ocid> \
--time-usage-started "2026-02-01T00:00:00Z" \
--time-usage-ended "2026-03-14T23:59:59Z" \
--granularity "DAILY" \
--query-type "COST" \
--query 'data.items[].{date:"time-usage-started", cost:"computed-amount"}' \
--output table
# View costs by tag (requires defined tags with cost tracking enabled)
oci usage-api usage-summary request-summarized-usages \
--tenant-id <tenancy-ocid> \
--time-usage-started "2026-03-01T00:00:00Z" \
--time-usage-ended "2026-03-14T23:59:59Z" \
--granularity "MONTHLY" \
--group-by '["tag:project-tags.Environment"]' \
--query-type "COST"Budgets and Alerts
OCI Budgets let you set spending limits and receive alerts when actual or forecasted spending approaches or exceeds your budget. You can create budgets at the compartment level (to track team or project spending) or at the tenancy level (for overall cost governance). Alerts can be configured to trigger at multiple thresholds.
# Create a monthly budget for a compartment
oci budgets budget create \
--compartment-id <tenancy-ocid> \
--amount 1000 \
--reset-period "MONTHLY" \
--display-name "production-budget" \
--description "Monthly budget for production compartment" \
--target-type "COMPARTMENT" \
--targets '["<production-compartment-ocid>"]'
# Create an alert rule (alert at 80% of budget)
oci budgets alert-rule create \
--budget-id <budget-ocid> \
--type "ACTUAL" \
--threshold 80 \
--threshold-type "PERCENTAGE" \
--display-name "80-percent-alert" \
--recipients "admin@example.com"
# Create a forecast alert (alert when forecasted to exceed budget)
oci budgets alert-rule create \
--budget-id <budget-ocid> \
--type "FORECAST" \
--threshold 100 \
--threshold-type "PERCENTAGE" \
--display-name "forecast-exceed-alert" \
--recipients "admin@example.com"
# List budgets
oci budgets budget list \
--compartment-id <tenancy-ocid> \
--query 'data[].{name:"display-name", amount:amount, spent:"actual-spend", forecast:"forecasted-spend"}' \
--output tableBudgets Do Not Stop Spending
OCI budgets are for alerting purposes only. They do not automatically stop or throttle resource usage when the budget is exceeded. To enforce hard spending limits, combine budgets with IAM policies that restrict resource creation in specific compartments, quota policies that cap the number of resources, and regular review of cost analysis reports. Consider using OCI Functions to create automated remediation actions triggered by budget alerts through the Notifications service.
Compute Cost Optimization
Compute is typically the largest cost category in any cloud deployment. OCI provides several mechanisms to optimize compute costs without sacrificing performance.
Optimization Strategies
| Strategy | Savings | Effort | Impact |
|---|---|---|---|
| Right-size with flex shapes | 20-50% | Low | Eliminate waste from fixed-size instances |
| Use ARM (Ampere A1) | ~50% | Medium | Best price-performance for compatible workloads |
| Preemptible instances | ~50% | Medium | Great for fault-tolerant batch workloads |
| Stop idle instances | Up to 100% | Low | Dev/test instances not needed 24/7 |
| Autoscaling | 30-60% | Medium | Match capacity to demand dynamically |
| Always Free tier | 100% | None | 2 AMD + 4 ARM cores for free forever |
# Find underutilized instances (low CPU over 7 days)
oci monitoring metric-data summarize-metrics-data \
--compartment-id $C \
--namespace "oci_computeagent" \
--query-text 'CpuUtilization[7d].mean() < 10'
# Schedule instance stop/start for dev environments
# Create an OCI Function that stops instances tagged "environment=dev"
# Trigger it via a scheduled alarm or OCI Events
# Example: Stop all dev instances in a compartment
oci compute instance list \
--compartment-id $C \
--lifecycle-state RUNNING \
--query 'data[?"freeform-tags".Environment == `dev`].id' \
--raw-output | while read INSTANCE_ID; do
echo "Stopping: $INSTANCE_ID"
oci compute instance action --instance-id "$INSTANCE_ID" --action STOP
done
# Right-size: reduce OCPU and memory on an underutilized flex instance
oci compute instance update \
--instance-id <instance-ocid> \
--shape-config '{"ocpus": 1, "memoryInGBs": 8}'
# Check instance pool size for autoscaling opportunities
oci compute-management instance-pool list \
--compartment-id $C \
--query 'data[].{name:"display-name", size:size, state:"lifecycle-state"}' \
--output tableStorage Cost Optimization
Storage costs accumulate silently as data grows. Implementing tiered storage, lifecycle policies, and regular cleanup of unused volumes prevents storage from becoming a significant cost driver.
# Find unattached block volumes (paying for storage not being used)
oci bv volume list \
--compartment-id $C \
--lifecycle-state AVAILABLE \
--query 'data[?!("is-auto-tune-enabled")].{name:"display-name", "size-gb":"size-in-gbs", created:"time-created", id:id}' \
--output table
# Find old boot volume backups that can be cleaned up
oci bv boot-volume-backup list \
--compartment-id $C \
--query 'data[].{name:"display-name", "size-gb":"size-in-gbs", created:"time-created", type:type}' \
--output table
# Enable auto-tiering on object storage buckets
oci os bucket update \
--namespace $NAMESPACE \
--bucket-name "application-data" \
--auto-tiering "InfrequentAccess"
# Check bucket sizes
oci os bucket get \
--namespace $NAMESPACE \
--bucket-name "application-data" \
--query 'data.{"approximate-size": "approximate-size", "approximate-count": "approximate-count"}'
# Reduce block volume performance tier to save costs
# Lower Cost tier (0 VPUs/GB) vs Balanced (10 VPUs/GB)
oci bv volume update \
--volume-id <volume-ocid> \
--vpus-per-gb 0 # Lower Cost tier for infrequently accessed dataNetwork Cost Optimization
OCI's networking pricing is one of its strongest competitive advantages. The first 10 TB of outbound data transfer per month is free, which is 100x more than AWS or Azure. However, there are still ways to optimize networking costs further.
| Traffic Type | Cost | Optimization |
|---|---|---|
| Intra-VCN (same AD) | Free | No optimization needed |
| Intra-VCN (different AD) | Free | No optimization needed |
| Inter-VCN (same region, via DRG) | Free | Use DRG instead of peering through internet |
| Inter-region (via DRG) | Charged per GB | Minimize cross-region replication; use local caches |
| Outbound internet | First 10 TB/month free | Usually no action needed for most workloads |
| Service Gateway | Free | Always use SGW for OCI service access from private subnets |
| FastConnect | Port fee + partner fee | Bundle multiple VCNs through one DRG |
Service Gateway Saves Money and Improves Security
Always use a Service Gateway for accessing OCI services (Object Storage, Autonomous Database, Container Registry, etc.) from private subnets. Traffic through the Service Gateway is free, private (does not traverse the internet), and faster than going through a NAT Gateway. This is one of the simplest and most impactful cost optimizations you can make.
Database Cost Optimization
Oracle Database workloads on OCI benefit from specific optimizations related to licensing, scaling, and the unique capabilities of Autonomous Database.
# Use ECPU instead of OCPU for finer-grained scaling
oci db autonomous-database update \
--autonomous-database-id <adb-ocid> \
--compute-model "ECPU"
# Stop Autonomous Database during non-business hours
oci db autonomous-database stop \
--autonomous-database-id <adb-ocid>
# Enable auto-scaling (use more only when needed)
oci db autonomous-database update \
--autonomous-database-id <adb-ocid> \
--is-auto-scaling-enabled true
# Use the License Included model if you do not have existing Oracle licenses
# Use BYOL (Bring Your Own License) if you have unused Oracle licenses
oci db autonomous-database update \
--autonomous-database-id <adb-ocid> \
--license-model "BRING_YOUR_OWN_LICENSE"
# Check ADB instances and their compute allocation
oci db autonomous-database list \
--compartment-id $C \
--query 'data[].{name:"display-name", model:"compute-model", compute:"compute-count", storage:"data-storage-size-in-tbs", "auto-scaling":"is-auto-scaling-enabled", license:"license-model"}' \
--output tableQuota Policies
Quota policies are a governance mechanism that limits the number of cloud resources that can be created in a compartment. Unlike budgets (which alert on spending), quotas enforce hard limits on resource creation. This prevents teams from accidentally provisioning expensive resources and ensures fair resource allocation across teams.
# Create quota policies (requires administrator privileges)
# Quota policies use a specific syntax different from IAM policies
# Limit compute instances in a compartment
oci limits quota create \
--compartment-id <tenancy-ocid> \
--name "dev-quotas" \
--description "Resource quotas for development compartment" \
--statements '[
"set compute quota vm-standard-e4-flex-core-count to 20 in compartment NonProduction:Dev",
"set compute quota vm-standard-a1-flex-core-count to 8 in compartment NonProduction:Dev",
"set block-storage quota total-storage-gbs to 500 in compartment NonProduction:Dev",
"set load-balancer quota lb-flexible-count to 2 in compartment NonProduction:Dev",
"set database quota autonomous-transaction-processing-ocpu-count to 4 in compartment NonProduction:Dev"
]'
# List quota policies
oci limits quota list \
--compartment-id <tenancy-ocid> \
--query 'data[].{name:name, statements:statements}' \
--output json
# Check current resource usage against limits
oci limits resource-availability get \
--service-name "compute" \
--limit-name "vm-standard-e4-flex-core-count" \
--compartment-id $C \
--availability-domain $ADCost Optimization Checklist
| Category | Action | Priority |
|---|---|---|
| Visibility | Set up budgets with 80% and 100% alerts for every compartment | High |
| Visibility | Enable cost-tracking tags and enforce tagging via tag defaults | High |
| Compute | Right-size all instances using flex shapes based on actual utilization | High |
| Compute | Migrate compatible workloads to ARM (Ampere A1) shapes | Medium |
| Compute | Stop dev/test instances outside business hours | Medium |
| Compute | Use preemptible instances for batch and CI/CD workloads | Medium |
| Storage | Delete unattached block volumes and old backups | High |
| Storage | Enable auto-tiering on all object storage buckets | Medium |
| Storage | Implement lifecycle policies for log and backup data | Medium |
| Network | Use Service Gateway for all OCI service access from private subnets | High |
| Database | Stop non-production ADB instances outside business hours | Medium |
| Database | Enable auto-scaling on ADB instead of over-provisioning | Medium |
| Governance | Set quota policies for each compartment to prevent over-provisioning | Medium |
| Governance | Review Universal Credits commitment annually based on actual usage | Low |
Automating Cost Optimization
Use OCI Functions and Events to automate cost optimization tasks. For example, create a function that runs nightly to stop all dev instances, or one that sends a Slack notification when a new expensive resource is created.
# Example: Use OCI CLI in a cron job to stop dev instances nightly
# Save as /opt/scripts/stop-dev-instances.sh
#!/bin/bash
COMPARTMENT_ID="ocid1.compartment.oc1..xxx"
# Get all running instances tagged as dev
INSTANCE_IDS=$(oci compute instance list \
--compartment-id "$COMPARTMENT_ID" \
--lifecycle-state RUNNING \
--query 'data[?"freeform-tags".Environment == `dev`].id' \
--raw-output)
for ID in $INSTANCE_IDS; do
echo "$(date): Stopping instance $ID"
oci compute instance action --instance-id "$ID" --action SOFTSTOP
done
# Add to cron: 0 20 * * 1-5 /opt/scripts/stop-dev-instances.sh
# Runs at 8 PM weekdays
# Example: Start dev instances in the morning
# 0 7 * * 1-5 /opt/scripts/start-dev-instances.shTrack Always Free Usage
Even with Always Free resources, keep track of what you are using. If you accidentally exceed Always Free limits (e.g., creating a third AMD micro instance), you will start incurring charges. Use the OCI Console > Governance > Limits, Quotas and Usage page to view your current usage against Always Free limits. Set up budgets even for Always Free tenancies as a safety net.
Key Takeaways
- 1Universal Credits provide a single prepaid balance that covers all OCI services.
- 2Reserved capacity offers up to 50% savings for predictable compute workloads.
- 3The Always Free tier includes compute, storage, and database resources permanently.
- 4OCI Cost Analysis provides granular spend tracking by compartment, tag, and service.
Frequently Asked Questions
How do OCI Universal Credits work?
How does OCI pricing compare to AWS and Azure?
Written by CloudToolStack Team
Cloud engineers and architects with hands-on experience across AWS, Azure, and GCP. We write guides based on real-world production patterns, not just documentation rewrites.
Disclaimer: This guide is for educational purposes. Cloud services change frequently; always refer to official documentation for the latest information. AWS, Azure, and GCP are trademarks of their respective owners.