Managing Instance Costs and Resource Quotas in OpenStack
Introduction
Cloud spending can spiral out of control without proper resource management. OpenStack provides robust quota and monitoring systems to help you control costs, prevent resource exhaustion, and maintain predictable spending across your cloud environment. This guide walks through the essential strategies for managing instance costs and resource quotas effectively.
Understanding quotas is critical for both cost control and operational stability. Without proper limits, a single misconfigured service or runaway process can consume all available resources, leading to unexpected bills and service disruptions for other projects or users.
Understanding OpenStack Resource Quotas
Resource quotas in OpenStack act as guardrails that limit how many resources a project or user can consume. These limits apply to compute, storage, network, and other service resources.
Core quota types:
- Compute quotas (Nova): Instances, vCPUs, RAM, key pairs, security groups
- Storage quotas (Cinder): Volumes, volume storage capacity (GB), snapshots, backups
- Network quotas (Neutron): Networks, subnets, routers, floating IPs, security group rules
- Object storage quotas (Swift): Container count, object count, storage capacity
Quotas operate at the project level, meaning every OpenStack project has defined limits for each resource type. When a project reaches its quota limit, no additional resources of that type can be created until existing resources are deleted or the quota is increased.
How to View and Monitor Quotas in Horizon Dashboard
The Horizon dashboard provides a visual interface for viewing your resource quotas and usage levels. This method is ideal for users who prefer a graphical interface.
Viewing Your Current Quotas
- Log in to the Horizon dashboard
- Navigate to Project > Compute > Overview
- View the usage summary showing current usage vs. quota limits
- The overview displays usage graphs for instances, vCPUs, RAM, and other compute resources
Checking Storage Quota Usage
- From the Horizon dashboard, navigate to Project > Volumes > Volumes
- Review the volume quota information displayed at the top of the page
- View current volume count, total storage capacity used, and available capacity
- Check Project > Volumes > Snapshots to monitor snapshot quota usage
Checking Network Resource Usage
- Navigate to Project > Network > Network Topology
- View a visual representation of your network resources
- Navigate to Project > Network > Networks to see network quota details
- Check Project > Network > Floating IPs to monitor floating IP allocation
Understanding Quota Limits
The Horizon dashboard displays quota information in several locations:
- Compute quotas: Instances, vCPUs, RAM, key pairs, security groups
- Storage quotas: Volumes, volume storage capacity (GB), snapshots, backups
- Network quotas: Networks, subnets, routers, floating IPs, security group rules
Usage is typically displayed as a ratio (e.g., "5/10 instances") or as a percentage bar showing how much of the quota is consumed.
How to View and Monitor Quotas Using OpenStack CLI
The OpenStack command-line interface provides detailed quota and usage information through various commands. This method is ideal for automation and scripting.
Viewing Compute Quotas
Check your project's compute quotas:
1openstack quota show --compute
Check default compute quotas:
1openstack quota show --compute --default
List all instances across projects (admin only):
1openstack server list --all-projects
View hypervisor statistics:
1openstack hypervisor stats show
Viewing Storage Quotas
Check volume quotas for your project:
1openstack quota show --volume
Viewing Network Quotas
Check network quotas for your project:
1openstack quota show --network
Viewing Usage for a Specific Project
View quotas for a specific project:
1openstack quota show --project <project-id>
View absolute limits and current usage:
1openstack limits show --absolute
The openstack limits show command displays both quota limits and current usage in a single view, making it easier to identify resources approaching their limits.
Setting and Adjusting Quotas
Administrators can modify project quotas to align with organizational policies, budgets, and resource availability. Adjusting quotas is a balancing act between providing flexibility and preventing resource overconsumption.
Setting compute quotas for a project:
1openstack quota set --instances 50 \2 --cores 100 \3 --ram 204800 \4 <project-id>
This command sets a project to a maximum of 50 instances, 100 vCPUs, and 200GB of RAM (specified in MB).
Setting volume quotas:
1openstack quota set --volumes 20 \2 --gigabytes 500 \3 --snapshots 50 \4 <project-id>
Setting network quotas:
1openstack quota set --networks 10 \2 --subnets 20 \3 --routers 5 \4 --floating-ips 10 \5 <project-id>
Resetting quotas to defaults:
1openstack quota set --default <project-id>
Best practices for quota management:
- Start with conservative quotas and increase based on demonstrated need
- Document quota changes and the business justification
- Review quotas quarterly to ensure alignment with project requirements
- Set different quota levels for development, staging, and production projects
- Implement approval workflows for quota increase requests
- Monitor quota utilization trends to anticipate future needs
Monitoring Resource Usage and Costs
Effective cost management requires continuous monitoring of resource consumption. OpenStack provides native tools, and third-party solutions can enhance visibility.
Native OpenStack monitoring:
Track instance resource usage:
1openstack server list --long2openstack server show <instance-id>
Monitor volume usage:
1openstack volume list --long2openstack volume show <volume-id>
Check floating IP allocation:
1openstack floating ip list
Review network usage:
1openstack network list2openstack subnet list3openstack router list
Using Ceilometer for detailed metrics:
If your OpenStack deployment includes Ceilometer (telemetry service), you gain access to granular resource usage data:
1openstack metric list2openstack metric measures show <metric-id>3ceilometer sample-list --meter cpu_util4ceilometer sample-list --meter network.incoming.bytes
Ceilometer tracks metrics such as CPU utilization, network bandwidth, disk I/O, and storage consumption, enabling detailed cost analysis and capacity planning.
Third-party monitoring solutions:
- CloudKitty: OpenStack rating and billing service that converts resource usage into cost estimates
- Prometheus + Grafana: Time-series monitoring with customizable dashboards for resource tracking
- Datadog, New Relic: Commercial APM solutions with OpenStack integrations
- Custom scripts: Parse OpenStack API responses and send data to your preferred monitoring platform
Key metrics to track for cost optimization:
- Instance uptime and utilization patterns
- Storage volume attachment status (unattached volumes cost money)
- Floating IP allocation (unused IPs incur charges)
- Snapshot accumulation (old snapshots consume storage)
- Network bandwidth usage (especially egress traffic)
Rightsizing Instances for Cost Efficiency
Rightsizing means matching instance resources to actual workload requirements. Overprovisioning wastes money; underprovisioning degrades performance.
Identifying oversized instances:
Check CPU utilization:
1# From within the instance2top3mpstat -P ALL 545# Using OpenStack telemetry (if available)6ceilometer sample-list --meter cpu_util --query 'resource_id=<instance-id>'
Check memory usage:
1free -h2vmstat 5
Monitor disk I/O:
1iostat -x 52iotop
Indicators that an instance is oversized:
- Consistent CPU utilization below 20%
- Memory usage consistently under 40%
- Low disk I/O with minimal read/write operations
- Application response times well within acceptable limits
Indicators that an instance is undersized:
- CPU utilization consistently above 80%
- Memory usage approaching 90% or swap activity
- High I/O wait times or disk queue depths
- Application timeouts or degraded performance
Rightsizing process:
- Collect baseline metrics over at least one week to capture usage patterns
- Identify workload characteristics: CPU-bound, memory-intensive, I/O-heavy, or network-dependent
- Select appropriate flavor: Choose the smallest flavor that meets peak usage requirements with a 20% buffer
- Test the new configuration in a staging environment before production changes
- Create a snapshot of the current instance before resizing
- Resize the instance:
1# Stop the instance2openstack server stop <instance-id>34# Resize to new flavor5openstack server resize --flavor <new-flavor-name> <instance-id>67# Confirm the resize after testing8openstack server resize confirm <instance-id>910# Or revert if performance degrades11openstack server resize revert <instance-id>
- Monitor post-resize performance for at least 48 hours
- Document the change and track cost savings
Automated rightsizing recommendations:
Some organizations implement automated analysis scripts that compare instance utilization against flavor specifications and generate rightsizing recommendations:
1# Pseudocode for rightsizing analysis2instances = get_all_instances()3for instance in instances:4 cpu_avg = get_average_cpu(instance.id, days=7)5 mem_avg = get_average_memory(instance.id, days=7)67 if cpu_avg < 0.20 and mem_avg < 0.40:8 print(f"Instance {instance.id} is oversized")9 recommended_flavor = find_smaller_flavor(instance.flavor)10 estimated_savings = calculate_savings(instance.flavor, recommended_flavor)11 print(f"Recommended: {recommended_flavor}, Estimated savings: ${estimated_savings}/month")
Implementing Cost Control Policies
Beyond quotas and rightsizing, implementing organizational policies ensures sustainable cloud spending.
Common cost control strategies:
1. Scheduled instance shutdown
Shut down development and testing instances during non-business hours:
1# Stop instances at night2openstack server stop <instance-id>34# Start instances in the morning5openstack server start <instance-id>
Automate this with cron jobs or OpenStack Heat templates with time-based triggers. For a 9-to-5 development environment, this can reduce costs by approximately 65%.
2. Instance lifecycle management
Define policies for instance creation, usage, and termination:
- Require business justification for new instances
- Set expiration dates for temporary instances
- Automatically delete instances tagged as ephemeral after a defined period
- Implement approval workflows for production instance creation
3. Tagging and cost allocation
Tag instances with project codes, departments, or cost centers:
1openstack server set --property cost_center=engineering \2 --property project=web_app \3 --property environment=production \4 <instance-id>
Use these tags to generate cost allocation reports and track spending by team or project.
4. Reserved capacity planning
For predictable, long-running workloads, consider reserved capacity commitments if your OpenStack provider offers them. Reserved capacity typically provides 20-40% cost savings compared to on-demand pricing.
5. Storage cleanup automation
Old snapshots, unattached volumes, and unused images consume storage and cost money:
1# List unattached volumes2openstack volume list --status available34# Delete old snapshots5openstack volume snapshot list6openstack volume snapshot delete <snapshot-id>78# Remove unused images9openstack image list --private10openstack image delete <image-id>
Implement automated cleanup scripts that delete snapshots older than a retention period (e.g., 30 days) and notify owners of unattached volumes before deletion.
6. Budget alerts and enforcement
Configure monitoring alerts when spending approaches budget thresholds:
- 50% of budget: Informational alert
- 75% of budget: Warning with review requirement
- 90% of budget: Critical alert with potential quota reduction
- 100% of budget: Automatic quota freeze pending approval
Advanced Cost Optimization Techniques
1. Spot instances and preemptible workloads
Some OpenStack deployments offer lower-cost preemptible instances for fault-tolerant workloads like batch processing, data analysis, and CI/CD pipelines. These instances can be reclaimed with short notice but cost 50-80% less than standard instances.
2. Multi-region cost optimization
If your OpenStack environment spans multiple regions, evaluate regional pricing differences. Network egress charges can vary significantly between regions, and some regions may offer lower compute costs.
3. Storage tiering
Use appropriate storage types for different workloads:
- High-performance SSD for databases and transactional systems
- Standard HDD for file storage and archives
- Object storage (Swift) for backups and large datasets
- Cold storage for long-term retention with infrequent access
4. Network cost optimization
Minimize expensive cross-region or external network transfers:
- Use private networks for inter-instance communication
- Deploy CDN or caching layers to reduce origin traffic
- Implement data compression for large transfers
- Keep related services in the same availability zone or region
5. Leverage autoscaling for variable workloads
Implement Heat orchestration templates with autoscaling groups that automatically adjust capacity based on demand:
1resources:2 web_server_group:3 type: OS::Heat::AutoScalingGroup4 properties:5 min_size: 26 max_size: 107 resource:8 type: OS::Nova::Server9 properties:10 flavor: m1.medium11 image: ubuntu-20.04
Autoscaling reduces costs by scaling down during low-traffic periods while maintaining performance during peak demand.
Common Quota and Cost Management Mistakes
1. Setting quotas too high by default
New projects often receive excessive quotas "just in case," leading to uncontrolled resource sprawl. Start conservative and increase based on actual need.
2. Ignoring unattached volumes
Volumes persist after instance deletion unless explicitly deleted. Regularly audit and remove unattached volumes to avoid unnecessary storage costs.
3. Forgetting about floating IPs
Allocated floating IPs incur charges even when not associated with an instance. Release unused IPs promptly.
4. Snapshot accumulation
Automated backup scripts can create numerous snapshots without cleanup, consuming significant storage. Implement retention policies and automated deletion.
5. Not monitoring test environments
Development and staging environments often escape cost scrutiny despite consuming significant resources. Apply the same cost controls to non-production environments.
6. Overprovisioning for peak capacity
Designing for absolute peak load without autoscaling leads to substantial waste during normal operations. Use autoscaling or manual capacity adjustments instead of permanent overprovisioning.
7. Neglecting to review and optimize regularly
Resource requirements change over time. Schedule quarterly reviews of instance sizing, quota utilization, and cost trends to identify optimization opportunities.
Setting Up Cost Reporting and Alerts
Using OpenStack APIs for cost reporting:
1#!/usr/bin/env python32import openstack34# Connect to OpenStack5conn = openstack.connect(cloud='mycloud')67# Get all projects8projects = conn.identity.projects()910for project in projects:11 print(f"\nProject: {project.name}")1213 # Get compute usage14 servers = conn.compute.servers(all_tenants=True, project_id=project.id)15 server_count = len(list(servers))1617 # Get volume usage18 volumes = conn.volume.volumes(all_tenants=True, project_id=project.id)19 volume_count = len(list(volumes))20 total_volume_gb = sum(v.size for v in volumes)2122 print(f" Instances: {server_count}")23 print(f" Volumes: {volume_count} ({total_volume_gb} GB)")
Integrating with billing systems:
If using CloudKitty for billing:
1# View rating information2cloudkitty storage dataframes get --begin 2026-01-01 --end 2026-01-3134# Generate cost report by project5cloudkitty summary get --begin 2026-01-01 --end 2026-01-31 --groupby project_id
Setting up alerts:
Configure monitoring system alerts based on quota utilization:
1# Example Prometheus alert rule2groups:3 - name: openstack_quotas4 rules:5 - alert: HighQuotaUsage6 expr: (openstack_quota_used / openstack_quota_limit) > 0.857 for: 5m8 labels:9 severity: warning10 annotations:11 summary: "Project {{ $labels.project_id }} quota usage above 85%"
Conclusion
Effective management of instance costs and resource quotas in OpenStack requires a combination of technical controls, monitoring, and organizational policies. By implementing appropriate quotas, continuously monitoring resource usage, rightsizing instances, and enforcing cost control policies, you can maintain predictable cloud spending while ensuring resources are available when needed.
The key to sustainable cloud cost management is treating it as an ongoing process rather than a one-time effort. Regular reviews, automated monitoring, and clear accountability structures ensure your OpenStack environment delivers value without unnecessary expense.
Next steps:
- Audit your current quota allocations and usage patterns
- Implement monitoring and alerting for resource utilization
- Schedule a rightsizing analysis for existing instances
- Define and document cost control policies for your organization
- Automate cleanup of unused resources (snapshots, volumes, floating IPs)
- Establish regular cost review meetings with stakeholders
