Skip to content
Navigation

Type at least two characters. Search covers page titles, headings, tags and database names.

↑ ↓ to navigateEnter to openEsc to close0 pages
Performanceintermediate

Capacity Forecasting

Turning growth trends into dates, so capacity work is scheduled rather than triggered by an incident.

2 min readIntermediateUpdated Edit this page

Forecasting converts "disk is at 60%" into "disk is full on 12 March". The second is actionable; the first is not.

Forecast each resource separately

They exhaust at different times and have different lead times to fix:

ResourceSignalTypical lead time
DiskBytes used, growth per dayHours to days
MemoryCache hit ratio trend, working setDays
ConnectionsHigh-water markHours
IOPS / throughputUtilisation against the provisioned limitDays
CPUUtilisation at peak, not averageDays to weeks
Series or shard countCardinality, partition countWeeks

Producing a date

# Prometheus: predicted seconds until the filesystem is full, from a 7-day trend.
predict_linear(node_filesystem_avail_bytes{mountpoint="/var/lib/postgresql"}[7d], 86400 * 30)
 
# Alert when it will fill within four hours.
predict_linear(node_filesystem_avail_bytes[6h], 4 * 3600) < 0
-- PostgreSQL: database growth from a table you populate daily.
SELECT day, size_bytes,
       size_bytes - lag(size_bytes) OVER (ORDER BY day) AS daily_growth
FROM db_size_history ORDER BY day DESC LIMIT 30;

Linear projection is adequate for most resources. Where growth is clearly non-linear — a product in a growth phase — project from the recent trend and shorten the review interval rather than trying to fit a curve.

Account for non-linear events

Some things do not grow smoothly:

  • A new customer or tenant can change the trend overnight.
  • A feature launch adds a table, an index, or a new query pattern.
  • Retention changes. Extending retention from 30 to 90 days triples the data with no change in write rate.
  • A failover. After promotion, one node carries what two were sharing.
  • Rebalancing. Adding a node to a distributed cluster requires headroom on the existing ones while data moves.

Add planned changes to the forecast explicitly rather than hoping the trend absorbs them.

Reviewing

A monthly review with a short output:

Resource       Current   Growth/mo   Limit    Exhausts     Action
disk           1.4 TB    +90 GB      2 TB     ~6 months    plan volume increase in Q4
memory         48/64 GB  +2 GB       64 GB    ~7 months    review working set, archive old orders
connections    380 peak  +25         500      ~4 months    add PgBouncer, cap total
IOPS           7k peak   +400        10k      ~7 months    monitor; provisioned IOPS available

The value is the two right-hand columns. A resource with a date and an owner is scheduled work; one without is an incident waiting to be scheduled for you.