Layer Cache Efficiency Calculator
Work out layer cache efficiency instantly with clear inputs, formula shown and shareable results.
About Layer Cache Efficiency Calculator
Docker invalidates a layer and everything after it when its inputs change, so layer ordering determines cache efficiency. Copying application source before installing dependencies invalidates the expensive dependency layer on every code change; copying only the manifest first, installing, then copying source keeps that layer cached and cuts the rebuilt layer count dramatically.
Formula
Layer cache
cached share = (total - invalidated) / total; incremental build = invalidated x per-layer time; saving = (total - invalidated) x per-layer time x builds
Worked example
With the default values below, Layer Cache Efficiency Calculator returns Layers reused from cache of 71.4%. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Layers in the imageaccepts 1–128
- 14
- Layers rebuilt on a typical changeminimum 0
- 4
- Average build time per layerminimum 0.1 s
- 22 s
- Builds per dayminimum 1
- 120
Results
- Layers reused from cache
- 71.4%
- Incremental build time
- 88 s
- Cold build time
- 308 s
- Build hours saved per day
- 7.33 h
Step by step
- 1Values used
- 2Layer cache
- 3Layers reused from cache= 71.4
- 4Incremental build time= 88 s
- 5Cold build time= 308 s
- 6Build hours saved per day= 7.33 h
Assumptions and limits
- The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 2 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
Why does one early change rebuild everything?
Cache invalidation cascades. Any layer after the changed one must be rebuilt because its base has changed, regardless of whether its own inputs did.
How should a Dockerfile be ordered?
Least frequently changing first: base image, system packages, dependency manifests, dependency install, then application source last.
Related Calculators
- Build Time Savings From Cache Calculator
- Cache Hit Ratio Calculator
- Cache Size For Hit Ratio Calculator
- Alert Noise Ratio Calculator
- Apdex Score Calculator
- Artifact Retention Calculator
- Automation ROI Calculator
- Autoscaling Threshold Calculator
- Availability From Error Rate Calculator
- Blue Green Cutover Time Calculator
You might also need
- Cache Hit Ratio CalculatorAlso in DevOps, SRE & Performance
- Apdex Score CalculatorAlso in DevOps, SRE & Performance
- Artifact Retention CalculatorAlso in DevOps, SRE & Performance
- Automation ROI CalculatorAlso in DevOps, SRE & Performance
- Autoscaling Threshold CalculatorAlso in DevOps, SRE & Performance
- Capacity Headroom CalculatorAlso in DevOps, SRE & Performance
