Skip to content

Storage and retention

Estimating storage is estimating traffic with two more factors: how big each item is, and how long it is kept. Four numbers give the answer.

  1. Events per day, E: the records, messages or rows written each day.
  2. Size of one event, s: the average size as it is stored.
  3. Copies of the data, c: how many full copies exist.
  4. Retention, t: the number of days before data is deleted.

The storage needed once the retention period has filled is R = E × s × c × t.

Mental model. Storage is a tank that fills at a daily rate and drains by the retention rule. Its level does not grow for ever. It settles at the daily volume times the number of days kept.

This is the same equation as Little’s Law in the performance module (Little’s Law): what is held equals the rate it arrives times the time each piece stays. There the pieces were requests and the time was milliseconds. Here the pieces are bytes and the time is days.

Suppose the shop writes one log line of about 1 kB for every request. That is the 40 million requests a day from the last lesson, so 40 million events a day. It keeps three copies, and deletes anything older than 30 days. The calculator below starts there.

Storage calculator

Your numbers

million events per day

How many records, messages or rows are written each day.

kB

The average size of one event as it is stored, metadata included. Measure a sample: a size on the network is not a size on disk.

days

How many days the data is kept before it is deleted. Once the retention period has filled, the storage stops growing.

copies

How many full copies are stored: 1 is no replica, 3 is a primary and two replicas.

Changing the numbers needs JavaScript. The result is for the starting numbers.

Result

Storage to provision3.6 TB

Each day adds 120 GB, in all copies.

How it is calculated

Each step shows its formula, the numbers that go in, and the figure that comes out.

  1. Written per day, one copy

    W = E × s

    One day's events, each of the average size.

    E events per day
    40M
    s size of one event
    1 kB

    W written per day, one copy40 GB

  2. Stored per day, all copies

    S = W × c

    Every copy is a full copy, so each day adds c times as much.

    W written per day, one copy
    40 GB
    c copies
    3

    S stored per day, all copies120 GB

  3. Stored once the retention period has filled

    R = S × t

    Data older than t days is deleted, so after t days the storage stops growing. This is the figure to provision.

    S stored per day, all copies
    120 GB
    t retention in days
    30

    R storage once the retention period has filled3.6 TB

Written and still stored over a period, all copies
Period (days)WrittenStill stored
1120 GB120 GB
30 · your retention3.6 TB3.6 TB
36543.8 TB3.6 TB
Model notes

Assumptions

  • The same number of events arrive every day. Real volumes grow, peak and fall, so check the growth separately.
  • Every event takes the average size. A few very large events can change the total, so use the average of the whole stream, not of a sample of small ones.

Simplifications

  • Only the events are counted. Indexes, metadata and logs add bytes, and compression removes some, so the size on disk differs from this figure.
  • Each copy is a full copy. Storage that uses erasure coding keeps less than the same number of full copies would.
  • No headroom is added. Disks are not filled to the brim, and a system needs room to grow and to rebuild after a failure, so provision more than this figure.
  • Sizes use decimal units: 1 TB is 10^12 bytes. Some tools show binary units, where 1 TiB is 2^40 bytes, about 10% more than 1 TB.
  • In back-of-envelope mode, the counts and sizes you enter are rounded to the nearest power of ten before anything is calculated. The result is an order of magnitude, not a figure to buy against.

Parameter values are illustrative. They are not benchmarks of any real product.

Follow the steps. 40 million events of 1 kB are 40 GB written each day, for one copy. Three copies make 120 GB a day. Over 30 days that is 120 GB × 30 = 3.6 TB, the figure to provision.

The table shows the shape. After one day, 120 GB is stored. After 10 days it is 1.2 TB, and after 30 days it is 3.6 TB. After that the storage stops growing, because each day deletes the day that has aged out as it adds a new one. The last row says it: a year of writing is 43.8 TB, of which only the last 30 days, 3.6 TB, are still stored.

The 1 kB is the size as stored, and it is the number most likely to be wrong. A size on the network is not a size on disk, so measure a sample of real events.

The documentation of Prometheus, a monitoring system, gives this formula for the disk it needs:

needed_disk_space = retention_time_seconds × ingested_samples_per_second × bytes_per_sample

It is the calculator’s product with one copy, written in seconds. The same page says that Prometheus stores an average of only 1 to 2 bytes per sample, and that its retention defaults to 15 days.

Take 100,000 samples per second, a rate chosen for illustration, at 2 bytes. Fifteen days is 1,296,000 seconds, so the disk needed is 1,296,000 × 100,000 × 2 = 259.2 GB. The storage calculator gives the same figure if you enter 8,640 million events a day (100,000 × 86,400) of 0.002 kB, one copy and 15 days: it shows 259 GB. A formula from a real system with the same shape as the calculator’s shows that the estimate is a product of plain quantities, not a trick.

The 3.6 TB is the data, not the disk. A disk is not filled to the brim, and a system needs room to grow and to rebuild after a failure. Suppose you aim to keep disks at most 70% full, a target chosen for illustration. Then you provision 3.6 ÷ 0.7 = 5.1 TB.

Units need care too. The calculator uses decimal units, as the SI does: 1 TB is 10^12 bytes. Some tools show binary units, where the NIST prefix is tebi and 1 TiB is 2^40 bytes. The same 3.6 TB is 3.6 × 10^12 ÷ 2^40 = 3.27 TiB, about 9% fewer in the binary unit. Always check which a figure is in before comparing two of them.

Set Retention to 60 days. The daily writing does not change, 120 GB a day, and the stored volume is 7.2 TB, exactly double. The system writes the same data each day. It only keeps each piece twice as long.

Now set it to a year, 365 days. The figure is 43.8 TB, which is 12.2 times the 30-day figure. The data from days 31 to 365 is stored only so that someone can look at it. If nobody looks at logs older than a month, that is 40.2 TB of disk, counting all three copies, kept for nothing. Retention is a product decision with a price, and the estimate puts the price next to the decision.

The same reasoning applies to copies. Going from 3 copies to 1 divides the figure by 3, to 1.2 TB, and removes the protection that the copies gave. That trade-off belongs to the later modules on replication.

  • Storage is events per day times the size of one event, times the copies, times the days of retention.
  • It settles at the daily volume times the retention, because old data is deleted. For the shop’s log, 40 GB a day in one copy is 120 GB with three, and 120 GB × 30 days is 3.6 TB.
  • It is Little’s Law applied to data: what is held equals the rate in times the time each piece stays.
  • Prometheus’s sizing formula has the same shape: retention in seconds times samples per second times bytes per sample. At 100,000 samples a second, 2 bytes and 15 days it gives 259.2 GB.
  • Doubling the retention doubles the figure, 7.2 TB at 60 days, and a year gives 43.8 TB, which is 12.2 times the 30-day figure.
  • The disk is bigger than the data: at a 70% fill target 3.6 TB becomes 5.1 TB. Decimal and binary units differ by about 9% at this size.

Next: bandwidth, and why a link is sized for the peak but a month’s transfer for the average.

Your progress

Built by GhaziAlibi.

© ShardCraft. All rights reserved.