Capacity Planning and Resource Limits
What you'll learn: How to calculate and allocate the right amount of storage, memory, and retention for your Prometheus metrics infrastructure.
Running Prometheus at scale means anticipating how much disk space you'll need, how much RAM your servers require, and how long you can keep data before running out of resources. This is capacity planning—the art of matching infrastructure to workload.
Understanding Metric Volume
Your storage needs depend on two factors:
- Cardinality: How many unique time series you have (combinations of metric names and label sets)
- Scrape frequency: How often Prometheus collects metrics
Think of it like photographing a parade: high cardinality means photographing every individual person, and scrape frequency is how many photos per second you take. More photos of more subjects = more storage.
Calculating Storage Requirements
A rough formula: samples_per_second × retention_days × bytes_per_sample × 1.2 (overhead)
For example, if you have 100,000 time series scraped every 15 seconds (6,667 samples/second), stored for 15 days at ~2 bytes per sample:
6,667 × 15 days × 86,400 seconds × 2 bytes × 1.2 ≈ 207 GB
Memory Needs
Prometheus loads recent data into memory. Budget roughly 2-4 bytes per active sample, plus overhead for queries. High-cardinality environments with millions of series can require 32GB+ RAM.
Setting Retention Policies
Use --storage.tsdb.retention.time and --storage.tsdb.retention.size flags to limit how long data persists. Balance operational needs (troubleshooting requires history) against cost (storage isn't free).
Key Takeaway: Capacity planning for Prometheus requires calculating storage based on cardinality, scrape rate, and retention period, while allocating sufficient memory for active series and query workloads.