关于 finops-cost-optimization
面向管理 Oracle Cloud Infrastructure(OCI)成本的从业者,汇总云成本优化方法、隐藏费用陷阱和节省测算。内容涵盖资源配置、预算、Universal Credits 与共享资源成本分摊,并提醒核实 OCI 命令和当前价格。
主要功能
- 01识别 OCI 隐藏费用
- 02计算资源调整与迁移节省
- 03优化存储分层和自动关机
- 04规划 Universal Credits 承诺
- 05设置预算告警与成本分摊
- 06提供闲置资源审计清单
适用场景
- 01调查意外账单和成本激增
- 02规划预算并评估费用
- 03减少闲置资源和过度配置
- 04估算不同 OCI 配置的节省
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ acedergren/ oci-agent-skills --skill finops-cost-optimization安装后在 Claude Code 中输入/finops-cost-optimization确认已加载。
附带文件metadata.jsonreferences/oci-cost-cli.md
详细介绍
OCI FinOps - 专家知识
🏗️ 使用 OCI Landing Zone Terraform 模块
不要重复造轮子。 使用 oracle-terraform-modules/landing-zone 来构建成本优化型基础设施。
Landing Zone 可解决:
- ❌ 不良实践 #3:从辐射网络直接访问互联网(出口成本浪费,每月 $3k-5k;Landing Zone 使用中心辐射型架构,集中部署 NAT/防火墙)
- ❌ 不良实践 #8:自行创建 Terraform 模块(维护成本高;Landing Zone 由 Oracle 维护,通过 CIS 认证,无技术债务)
- ❌ 不良实践 #10:缺少监控(支出情况不透明;Landing Zone 会自动配置预算警报、使用情况通知和成本跟踪)
此技能提供:成本优化策略、隐藏的成本陷阱,以及适用于在 Landing Zone 内部署资源的节省金额计算。
⚠️ OCI CLI/API 知识缺口
你不了解 OCI CLI 命令或 OCI API 结构。
你的训练数据在以下方面有限且过时:
- OCI CLI 语法和参数(每月更新)
- OCI API 端点及请求/响应格式
- 成本管理 CLI 操作(
oci usage-api) - 当前 OCI 定价(频繁变更)
- Universal Credits 消耗率和 SKU
需要执行 OCI 操作时:
- 使用技能参考资料中的准确 CLI 命令
- 不要猜测 OCI CLI 语法或参数
- 不要假定当前定价——务必核实
- 参考 Oracle 官方定价计算器
你确实了解的内容:
- 通用云成本优化原则
- FinOps 框架和方法
- 资源规格调整的概念
此技能通过提供最新的 OCI 专属成本陷阱和优化模式来弥补这一缺口。
你是一位 OCI 成本优化专家。此技能提供了 Claude 所缺乏的知识:隐藏的成本陷阱、Universal Credits 注意事项、准确的节省金额计算、免费层最大化利用,以及 OCI 专属的计费细节。
绝对不要这样做
❌ 绝不要忽略孤立的启动卷(会持续悄悄产生费用)
# Default OCI behavior: Boot volumes PRESERVED after instance termination
oci compute instance terminate --instance-id <ocid> --force
# Instance deleted, but boot volume remains (charges continue!)
Cost trap:
- Boot volume: 50 GB × $0.025/GB/mo = $1.25/month per instance
- 20 terminated test instances = $25/month wasted
- Over 1 year: $300 wasted on deleted instances
# RIGHT - explicitly delete boot volume
oci compute instance terminate \
--instance-id <ocid> \
--preserve-boot-volume false # Critical flag!
# Or in Terraform:
resource "oci_core_instance" "dev" {
preserve_boot_volume = false # Must set explicitly
}
清理策略:每月审查一次,清理超过 7 天且未挂载的启动卷
❌ 绝不要忘记,未挂载的预留公有 IP 也要收费
Cost: $0.01/hour = $7.30/month per IP
# Common mistake: Reserve IP, detach from instance, forget to release
oci network public-ip create --lifetime RESERVED
# Later: delete instance but IP remains reserved (charges continue)
Wasted cost example:
- 5 old reserved IPs from deleted instances
- 5 × $7.30/month = $36.50/month waste
- Over 1 year: $438 wasted
# RIGHT - use ephemeral IPs for temporary resources
oci network public-ip create --lifetime EPHEMERAL
# Auto-deleted when instance terminated
# Or release reserved IPs explicitly
oci network public-ip delete --public-ip-id <ocid>
检测方法:列出未关联实例的预留 IP
❌ 绝不要认为停止资源就等于零成本
Stopped Autonomous Database:
✓ Compute: Zero cost (stopped)
✗ Storage: $0.025/GB/mo continues
✗ Backups: Retention charges continue
Example: 1 TB ADB stopped for 30 days
Storage: 1000 GB × $0.025 = $25/month (charged!)
Stopped Compute Instance:
✓ Compute: Zero cost
✗ Boot volume: $0.025/GB/mo continues
✗ Block volumes: $0.025/GB/mo continues
✗ Reserved IP (if attached): $7.30/month continues
# Better for long-term idle (>30 days): TERMINATE + backup
# Restore from backup when needed
规则:停止 = 计算暂停,存储仍会计费
❌ 绝不要忽略数据出口费用(可能导致意外账单)
OCI egress pricing:
- First 10 TB/month: FREE
- 10-50 TB: $0.0085/GB
- 50+ TB: Contact sales for discount
# Common mistake: Large data export
oci os object bulk-download --bucket-name backups --download-dir /local
# Downloading 15 TB = 5 TB chargeable × $0.0085/GB = $42,500 surprise!
# Cheaper alternatives:
1. Use OCI FastConnect (fixed cost, unlimited egress)
2. Download within same region (free between OCI services)
3. Export to another OCI region first (inter-region = free)
Cost comparison (15 TB export):
- Internet egress: $42,500
- FastConnect (1 Gbps): $1,100/month flat rate
- Breakeven: 130 GB/month egress
注意事项:OCI 区域之间的数据出口免费(Oracle 内部网络)
❌ 绝不要在不了解费用的情况下启用 NAT Gateway
NAT Gateway pricing:
- Gateway itself: $0.01/hour = $7.30/month
- Data processed: $0.01/GB
# Mistake: Use NAT Gateway for high-traffic apps
Example: Application with 5 TB/month outbound traffic
- Gateway: $7.30/month
- Data: 5000 GB × $0.01 = $50/month
- Total: $57.30/month
# Cheaper alternative: Public IP on instance (ephemeral IP = free)
Cost: $0/month for egress <10 TB
When NAT Gateway makes sense:
- Private subnets with <100 GB/month egress
- Security requirement (no public IPs on instances)
When to avoid:
- High-traffic egress (use public IPs instead)
- Low-security dev/test environments
❌ 绝不要过度承诺 Universal Credits
Universal Credits gotcha:
- Credits are NON-TRANSFERABLE between service categories
* Compute credits → can only pay for compute
* Database credits → can only pay for database
* Cannot move credits between categories
# Mistake: Commit to $10k/month compute credits
# Reality: Only use $6k/month compute
# Cannot use $4k surplus for database spending
# Result: Waste $4k/month ($48k/year)
# RIGHT - commit conservatively based on baseline usage
Analyze 3-6 months historical usage
Commit to 70-80% of baseline (not peak)
Expiration gotcha:
- Monthly credits expire end of month
- Cannot roll over to next month
- Use-it-or-lose-it model
❌ 绝不要相信预算预测(误差率为 30-40%)
OCI Budget types:
1. ACTUAL: Alerts on actual spending (accurate)
2. FORECAST: Alerts on projected spending (often wrong)
# Problem: Forecast uses simple linear projection
Example:
- Week 1: $100 spend
- Forecast for month: $100 × 4 = $400
- Reality: Week 1 included one-time data migration
- Actual month: $150 total
- Forecast error: 167% over-prediction
# WRONG - rely on forecast alerts
Alert at 80% forecast → fires prematurely
# RIGHT - use actual spend alerts at multiple thresholds
Alert at 50% actual, 75% actual, 90% actual, 100% actual
最佳实践:使用 FORECAST 查看趋势,使用 ACTUAL 编制预算
成本优化策略
规格迁移节省(准确计算)
固定规格 → 灵活规格迁移
Legacy fixed shape:
VM.Standard2.4: 4 OCPUs, 60 GB RAM (fixed ratio 1:15)
Cost: $0.06/hr × 4 = $0.24/hr = $175/month
Flex shape (right-sized):
VM.Standard.E4.Flex: 4 OCPUs, 16 GB RAM (custom ratio)
Cost: ($0.02/OCPU-hr × 4) + ($0.0015/GB-hr × 16) = $0.104/hr = $76/month
Savings: $99/month per instance (56% reduction)
Migration path:
1. Create flex instance with same OCPU count
2. Test with minimal RAM (4 GB per OCPU)
3. Increase RAM only if needed
4. Delete fixed instance
AMD → Arm 迁移
AMD instance:
VM.Standard.E4.Flex: 4 OCPUs, 16 GB RAM
Cost: $0.02/OCPU-hr × 4 × 730 = $58.40/month
Arm instance (same workload):
VM.Standard.A1.Flex: 4 OCPUs, 16 GB RAM
Cost: $0.01/OCPU-hr × 4 × 730 = $29.20/month
Savings: $29.20/month per instance (50% reduction)
Gotcha: ARM64 architecture (not all apps compatible)
Check: Docker images available for ARM64?
最大化利用免费层
准确的费用规避(你无需支付的费用):
Always-Free tier value if fully utilized:
Compute:
- 2 AMD Micro VMs: 2 × $7/month = $14/month
- 4 Arm OCPUs (24 GB): 4 × $7.30/month = $29.20/month
Subtotal: $43.20/month
Database:
- 2 Autonomous Databases: 2 × $292/month = $584/month
Storage:
- 200 GB block: $5/month
- 10 GB object: $0.26/month
- 10 GB archive: $0.02/month
Subtotal: $5.28/month
Networking:
- 1 load balancer: $10/month
- 10 TB egress: $85/month
Subtotal: $95/month
TOTAL COST AVOIDED: $727.48/month ($8,730/year)
注意事项:2 个 ADB 的限制适用于整个租户(不是每个区域/隔间各自计算)
存储生命周期优化
自动分层节省:
Scenario: 10 TB compliance data, accessed quarterly
Without tiering (all Standard):
10,000 GB × $0.0255/GB/mo = $255/month = $3,060/year
With tiering (Archive after 30 days):
Month 1 (Standard): 10,000 GB × $0.0255 = $255
Months 2-12 (Archive): 10,000 GB × $0.0024 × 11 = $264
Total year: $519
Savings: $2,541/year (83% reduction)
Lifecycle policy:
- Day 0-30: Standard (frequent access window)
- Day 31+: Archive (compliance retention)
- Retrieval cost: $0.01/GB (acceptable for quarterly access)
计算资源自动关机
开发/测试环境自动化:
Scenario: 10 development instances, 2 OCPUs each
Running 24/7: 10 × 2 × $0.02/hr × 730 = $292/month
Auto-shutdown (weekdays 9am-6pm only):
Usage: 9 hours/day × 5 days = 45 hours/week = 195 hours/month
Cost: 10 × 2 × $0.02/hr × 195 = $78/month
Savings: $214/month (73% reduction)
Implementation:
1. Tag instances: Environment=Development
2. Create Functions for start/stop
3. Schedule with OCI Events:
- Start: Weekdays 9am
- Stop: Weekdays 6pm
Universal Credits 注意事项
额度类别(不可互相转移):
| 类别 | 包含的服务 | 典型用途 |
|---|---|---|
| 计算 | VM、裸金属、容器实例、OKE | 应用、工作负载 |
| 数据库 | ADB、DB Systems、Exadata、MySQL | 数据存储、事务处理 |
| 存储 | 块、对象、文件、归档 | 备份、数据湖 |
| 网络 | 负载均衡器、FastConnect、NAT GW | 连接、出口流量 |
承诺陷阱:
Scenario: Commit to $5k/month database credits
Month 1-3: Use only $3k/month (waste $2k/month)
Cannot: Transfer $2k to compute spending
Result: Waste $6k over 3 months
Better approach:
1. Analyze 6 months baseline usage per category
2. Commit to 70% of baseline (room for variance)
3. Over-commit only if growth guaranteed
过期:月度额度必须当月使用,过期作废(不可结转)
成本分摊挑战
共享资源分摊(OCI 专属):
Problem: How to allocate costs for shared VCN?
VCN costs:
- DRG: $0.01/hr = $7.30/month
- NAT Gateway: $0.01/hr + $0.01/GB = variable
- FastConnect: $1,100/month (1 Gbps)
Allocation strategies:
1. Equal split: $1,107.30 / N teams
2. Usage-based: Track egress per team (requires tagging)
3. Chargeback: Production pays 100%, dev/test free
Gotcha: OCI doesn't auto-allocate shared resource costs
Must implement manual showback/chargeback process
负载均衡器成本分摊:
Problem: Multiple apps share 1 load balancer
LB costs:
- Flexible LB: $10/month + $0.008/LCU-hour
- Bandwidth: $0.01/GB processed
Allocation approach:
1. Tag backends by team (freeform_tags.Team)
2. Estimate traffic % per team (monitoring metrics)
3. Allocate LB cost proportionally
Example:
- Total LB cost: $50/month
- Team A: 60% traffic → $30/month
- Team B: 40% traffic → $20/month
预算最佳实践
多阈值告警:
# Best practice: Set 4 alert levels
oci budgets alert-rule create \
--budget-id <ocid> \
--type ACTUAL \
--threshold 50 \
--recipients "[email protected]"
oci budgets alert-rule create \
--budget-id <ocid> \
--type ACTUAL \
--threshold 80 \
--recipients "[email protected],[email protected]"
oci budgets alert-rule create \
--budget-id <ocid> \
--type ACTUAL \
--threshold 90 \
--recipients "[email protected],[email protected],[email protected]"
oci budgets alert-rule create \
--budget-id <ocid> \
--type ACTUAL \
--threshold 100 \
--recipients "[email protected],[email protected],[email protected]"
Alert strategy:
50%: FYI to team (informational)
80%: Action required (investigate spike)
90%: Escalation to management
100%: Finance involved (budget exceeded)
注意事项:预算仅用于告警,不会强制执行(无法阻止支出)
隐藏成本检测
每月审查清单:
# 1. Orphaned boot volumes (cost trap #1)
oci bv boot-volume list --all --lifecycle-state AVAILABLE \
| grep -v "attached-instance"
# 2. Unattached block volumes
oci bv volume list --all --lifecycle-state AVAILABLE
# 3. Reserved IPs without instance
oci network public-ip list --scope REGION --lifetime RESERVED
# 4. Stopped instances with volumes
oci compute instance list --lifecycle-state STOPPED
# 5. Old snapshots/backups
oci bv backup list --all \
| jq '.data[] | select(.["time-created"] < "2024-01-01")'
# 6. Unused load balancers (no backends)
oci lb load-balancer list --all
# 7. Empty Object Storage buckets
oci os bucket list --all --fields approximateCount,approximateSize
预计每月节省金额:对于典型租户,清理浪费可节省 $100-500
渐进式加载参考资料
OCI Cost Management CLI
在以下情况下加载 oci-cost-cli.md:
- 设置预算和告警规则
- 通过 CLI 查询使用情况报告
- 管理服务限制和配额
- 实施标记以进行成本分配
- 下载详细的成本报告
以下情况无需加载:
- 快速计算成本(参见上方的表格和示例)
- 了解成本陷阱(上方已完整列出)
- 比较形状定价(上方已涵盖)
Oracle 官方文档来源
主要参考资料(已抓取 200 多个官方来源):
注意:此技能中的所有成本计算、陷阱和注意事项均基于这些官方来源和 A-Team Oracle 博客
何时使用此技能
- 意外账单:调查费用,查找成本激增
- 预算规划:估算成本、设置预算、预测支出
- 成本优化:调整资源规格、减少浪费、迁移形状
- 免费套餐:最大限度地使用永久免费资源,避免过度配置
- Universal Credits:制定承诺计划,分配额度
- 成本分配:显示分摊、费用分摊、共享资源成本
- 节省金额计算:比较选项,分析投资回报率