Storage Retention Replicas and Backup Budgets

Back of the Envelope Estimation · 35 min

System Design · Module 4 · Lesson 2 of 4 · 35 min

Storage Retention Replicas and Backup Budgets

Calculate logical data size, distinguish data copies from backups, and account for indexes logs and operational free space.

Retained logical bytes are the starting point; physical capacity also needs explicit overhead, recovery and growth budgets.

01 The idea

The problem this lesson solves

A storage estimate often starts correctly and ends too early. Multiplying records by bytes gives logical data volume, but the deployed system also stores indexes, replicas, logs and recovery data. Deletion and retention create another set of questions. This lesson builds the budget in layers so each multiplier corresponds to something the system actually keeps.

You need multiplication, division and unit conversion. Keep reads, writes and bytes in separate calculations.

RetentionHow long the product keeps a class of data.
Logical sizeThe modeled application data size before physical storage overhead.
BackupRetained recovery data used to restore a prior state under a defined policy.

02 Worked example

Budget one year of retained records

Storage Retention Replicas and Backup Budgets worked diagram01Daily recordsCount × bytes02RetentionDays retained03Live copiesReplica multiplier04Recovery budgetBackups + logsKeep the units and assumptions visible at each step.Storage Retention Replicas and Backup Budgets compact diagram01Daily recordsCount × bytes02RetentionDays retained03Live copiesReplica multiplier04Recovery budgetBackups + logs
Live replication is only one storage multiplier. Indexes, retained logs, backups and operational free space need separate budgets.
1
Count new data10,000 × 500 = 5,000,000 logical bytes per day.
2
Apply retention365 days produces 1.825 GB of logical data.
3
Add copiesThree live copies produce 5.475 GB before overhead.
4
Budget operationsAdd indexes, logs, backups and free space as separately stated assumptions.

03 The method

Understand the mechanism

Measure the object you intend to retain

Begin with a record definition. A short-link mapping may include a code, owner id, destination, timestamps and metadata. The serialized request size is not necessarily the database row size, and the row size is not the entire physical storage cost.

For the exercise, assume 500 modeled logical bytes per newly created mapping. This is an input, not a claim about every URL or database engine. Real destinations vary in length, and storage formats add headers, alignment and other overhead.

Use a distribution when sizes vary substantially. An average is useful for aggregate growth, while maximum accepted size matters for per-request memory, indexes and abuse resistance. A small number of very large values can dominate bytes even when they are rare by count.

Keep metadata and large object content separate. A database row that points to an uploaded video does not include the video’s storage merely because the application treats them as one resource. Estimate each storage system at its own boundary.

Apply creation rate and retention

At 10,000 new mappings/day and 500 bytes each, daily logical growth is 5,000,000 bytes. Retaining 365 days gives 1,825,000,000 bytes, or 1.825 decimal GB. The formula is records/day × bytes/record × retained days.

Decimal GB means 1,000,000,000 bytes; GiB means 1,073,741,824 bytes. Use one convention consistently and label it. Confusing bytes with bits creates an eightfold error; confusing GB and GiB creates a smaller but still relevant difference.

Retention is not always a simple fixed window. If users can keep links indefinitely, the active dataset grows with cumulative creations minus deletions. If the service retains tombstones, audit history or deleted records for recovery, “deleted by the user” may not mean “all physical copies removed immediately.”

Updates can create additional retained versions, logs or history even when the number of live mappings stays constant. A system with heavy editing can therefore write much more than its net live-data growth suggests.

Count live copies without confusing them with backups

If there are three complete live copies, the logical data component across them is 1.825×3 = 5.475 GB before other costs. Be explicit whether “three replicas” means three copies total or one primary plus three additional copies. Ambiguous naming causes off-by-one capacity plans.

Each full copy may also maintain indexes and local operational data. If an index estimate is for one copy, multiply it consistently with the copies that actually keep that index. Do not multiply everything blindly when different replicas or storage tiers have different structures.

Live replication serves availability, read placement or failover goals. It is not automatically a backup against accidental deletion or bad application writes, because those changes can replicate too. Recovery from a historical mistake requires a retained recovery mechanism with a suitable point in time.

Replication can also consume network bandwidth and apply capacity. A standby with enough disk but insufficient replay throughput can fall behind. Storage capacity is one part of maintaining useful copies, not the whole design.

Budget indexes, logs and free space separately

An index duplicates selected keys and references in an access structure. Its size depends on key widths, row count and implementation details. Estimate it from representative schema/data or measurement rather than a universal “indexes add exactly 20%” rule.

Transaction logs support durability and replication. Retention can grow when a replica or consumer falls behind, or when the recovery policy retains more history. Compaction, vacuum, reindexing and migration can temporarily require additional working space.

Free space is an operational requirement, not wasted capacity. A disk nearly full can turn an ordinary maintenance action into an outage. State a headroom policy and test the operations it is intended to permit.

A useful budget has separate lines: live table data, live indexes, retained logs, temporary maintenance space and safety margin. This makes it possible to revise one assumption without accidentally multiplying unrelated components.

Derive the recovery budget from recovery goals

A backup policy specifies what is captured, how often, how long it is retained and how it is restored. Full snapshots, incremental backups and log archives have different growth patterns. Some systems deduplicate or compress data; the effectiveness must be measured for the workload.

Recovery point objective describes the acceptable data-loss window. Recovery time objective describes the acceptable time to restore usable service. Frequent backup creation alone does not establish a short restore time, and a successful backup job does not prove the restored data is usable.

Estimate restore bandwidth and processing work. Moving a large snapshot to replacement storage, replaying logs, rebuilding indexes and warming caches can all contribute. Include the time needed to verify and redirect service after restoration.

Test with representative data and retain evidence. A recovery drill should check business invariants and recent records, not only whether a database process starts. The backup budget is justified by a recovery behavior the product needs.

Handle retention as a data lifecycle

Define when records expire, how deletion is executed and which dependent data follows them. Removing a mapping may require invalidating cached copies and updating indexes or projections. Historical backups may retain prior versions under a separate policy.

Large deletes can create database work and temporary storage pressure. Partitioning by time can help some retention workloads, but only if the access and ownership model fits. A time partition is not automatically a good sharding key for a hot write path.

Track actual growth against the estimate. Separate logical record count, average payload size, index bytes, log retention and backup bytes. If physical storage grows while live records stay flat, investigate retained versions, logs or index behavior instead of assuming the user forecast was wrong.

Your final budget should answer two questions: how much capacity is needed during normal operation, and how much is needed during the recovery or maintenance operation you promise to survive. A single records×bytes number answers neither completely.

Guided tutorial

  1. Compute the logical baseline

    Use 10,000 records/day, 500 bytes/record and 365 retained days. Calculate 5 MB/day and 1.825 GB/year in decimal units. Write the definition of a retained record next to the result so a reviewer knows whether it includes history or only the current mapping.

  2. Add copies and explicit assumptions

    Assume three total live copies and calculate 5.475 GB of copied logical data. Add separate hypothetical rows for indexes, retained logs and maintenance headroom. Label those assumptions instead of disguising them as known database overhead.

  3. Design one restore test

    Choose a recovery point and time objective for the exercise. List snapshot transfer, log replay, verification and traffic cutover as separate stages. Explain how you would measure each stage on a disposable restoration before claiming the objective is met.

  4. Change retention

    Recalculate logical data for 730 days and observe that the simple retained-data term doubles to 3.65 GB. Explain which other budget items might not double in the same way, such as fixed operational overhead or a separately defined backup-retention policy.

Sizing formulas

logical_bytes = writes_per_day * bytes_per_record * retained_days
live_data_copies = logical_bytes * copy_count
physical_budget = live_data_copies + index_copies + logs + free_space
backup_budget = separately modeled retained recovery data
# decimal GB = bytes / 1_000_000_000

Check your result

10,000 records/day × 500 bytes × 365 days gives 1.825 decimal GB. Three live copies use 5.475 GB before indexes, logs, backups and free space.

Calculate storage without mixing units

Use decimal GB here. The model separates logical records from the number of live copies and deliberately leaves physical overhead as additional budget items.

records_per_day, bytes_per_record = 10000, 500
days, copies = 365, 3
logical = records_per_day * bytes_per_record * days
print(f"logical_GB={logical/1_000_000_000:.3f}")
print(f"live_data_GB={logical*copies/1_000_000_000:.3f}")
print(f"logical_GiB={logical/1_073_741_824:.3f}")

Expected output

logical_GB=1.825
live_data_GB=5.475
logical_GiB=1.700

GB and GiB describe the same byte count in different units. Indexes, logs, backups and maintenance space are still absent from this calculation, so live_data_GB is not the final provisioning number.

04 Cheat sheet

Review the decisions

Use this table to explain the mechanism and its limit without memorizing a product name.

Choice or conceptRememberCheck
Logical dataRows × payload × retentionBefore engine overhead
Live replicasAdditional data copiesNot historical recovery by themselves
Indexes and logsServing and durability structuresMeasure their growth
BackupsRestore prior stateRetention and restore time matter

05 Where & why

Check the primary references

Use official references for protocol and implementation details. The questions here are teaching prompts.

Primary reference
PostgreSQL backup and restore

Read PostgreSQL backup and restore

Primary reference
PostgreSQL streaming and synchronous replication

Read PostgreSQL streaming and synchronous replication

State the implementation version and the workload assumptions when defending your own design.

06 Interview questions

Explain the reasoning out loud

Answer before opening the explanation. The questions progress from vocabulary to decisions and failure behavior.

What does Retention mean?
How long the product keeps a class of data.
What does Logical size mean?
The modeled application data size before physical storage overhead.
What does Backup mean?
Retained recovery data used to restore a prior state under a defined policy.
Does a replica replace a backup?
No. It can reproduce a bad write or delete. Historical recovery requires retained data and a tested restore path.
Why separate logical and physical size?
The application payload is only part of the storage engine’s footprint. Separate line items make overhead assumptions visible and revisable.
Does longer retention increase QPS automatically?
No. It increases stored data for the same creation stream. Query cost or workload may change, but that is a separate assumption.
Why budget migration space?
During a migration, old and new copies or indexes may coexist. Peak disk use can exceed the final steady-state size.
What proves a backup is useful?
A successful restore and recovery test against the required data-loss and time objectives, not only the presence of a file.

07 Practice problems

Practice a new case

Solve the new cases before revealing hints. Complete worked solutions follow the set.

Daily size

Easy
Size 2,000 records/day at 250 bytes each in bytes/day.
Show the hint
Multiply count by payload.

Unit convention

Easy
Explain the difference between GB and GiB in a capacity memo.
Show the hint
One uses decimal, the other powers of two.

Retention budget

Medium
Size 50,000 records/day at 400 bytes each for 180 days and three copies in decimal GB.
Follow-up
Report logical storage and replicated data separately.
Show the hint
Multiply days before copies.

Retention change

Medium
Find logical storage for 20 MB/day retained for 45 days.
Show the hint
The daily unit remains MB.

Concurrent copies

Medium
A migration keeps two 8 GB datasets and builds a 2 GB index; find this modeled peak.
Show the hint
Include the old copy until rollback retention ends.

Recovery design

Hard
Explain how a service with three replicas recovers an accidental table delete and what extra data it needs.
Show the hint
The delete may reach every live copy.

Worked solutions

1. Daily size

500,000 logical bytes/day.

2. Unit convention

GB is 10^9 bytes; GiB is 2^30 bytes. State the convention and use it consistently.

3. Retention budget

Logical storage is 50,000 × 400 × 180 = 3.6 billion bytes = 3.6 GB. Three data copies are 10.8 GB, excluding indexes, logs and backups.

4. Retention change

900 MB of logical payload under the stated decimal-unit model, before overhead.

5. Concurrent copies

18 GB before logs, free space and other existing structures.

6. Recovery design

Use retained backups/logs and a tested restore procedure to recover a prior state. State the recovery point, permitted data loss, restore time, and how writes during recovery are handled.