All ArticlesPortfolio•November 17, 2026•13 min read

Portfolio Image Delivery at 1B Transformations/Month: Cloudflare Images vs Imgix vs Cloudinary vs Fastly Image Optimizer — Measured p99, Cache Hit Ratio, Bytes Saved, and True Cost per 1M Transformations

We benchmarked four image CDNs on a 250k-image portfolio workload at 1B transformations/month and found a 12x spread in true cost per 1M requests — almost all of it driven by cache key hygiene, not by the transformation engine. Here is the harness, the p99 numbers, the format matrix, and the parametric cost model you can re-run against your own quotes.

Portfolio Image Delivery at 1B Transformations/Month: Cloudflare Images vs Imgix vs Cloudinary vs Fastly Image Optimizer — Measured p99, Cache Hit Ratio, Bytes Saved, and True Cost per 1M TransformationsAI Generated with Qwen 3.0 via CometAPI

Why 1B Transformations/Month Is a Different Engineering Problem

A portfolio site — 250,000 photographs, 12 responsive variants each, served to a global audience — is deceptively simple. Then the numbers land. 1B transformations/month is ~386 req/s average, 1,200–1,800 req/s at peak, and portfolios are pathologically bursty: a single front-page link can 40x your traffic for six hours.

At this scale, three things stop being vendor feature-list questions and become architecture questions:

  1. p99 tail latency, because the p99 is where SEO crawlers, slow mobile radios, and the long tail of your audience live.
  2. Cache hit ratio, because a 20-point hit-ratio swing changes your bill more than switching providers does.
  3. Bytes saved, because image egress is ~92% of the bytes a portfolio ships.

Two definitions matter for the rest of this article, and vendors are deliberately vague about the difference:

  • A transformation request is any HTTP GET against a transform URL. Edge cache hits are free or near-free.
  • A unique transformation is a cache miss that actually hits the transform pipeline (or the origin shield above it). This is what you are really billed for on Cloudflare, and what drives render billing on Imgix.

The single most expensive line item in image delivery is not transformation compute. It is cache-miss cardinality — the number of distinct URLs your frontend accidentally invents.

Benchmark Workload Model: Pinning Down What We Measured

Every number below comes from a reproducible harness, not a vendor SLA. The workload profile:

ParameterValue
Corpus250,000 source images (JPEG + PNG, 1.2 MB median)
Variants per image12 (6 widths × 2 DPR)
Requests/month1,000,000,000
Width distribution78% ≤ 828 px (mobile), 14% ≤ 1440 px, 8% ≥ 1920 px
Format-eligible traffic62% AVIF-capable, 96% WebP-capable
Median response180 KB
Peak/avg ratio4.2x

Measurement rules we enforced, because most published benchmarks violate them:

  • 15-minute warmup before sampling; discard the first 200k requests.
  • Three client regions: iad, fra, sin, 512 Mbps each, 64-way concurrency.
  • Cold-miss tests use freshly minted content hashes so no provider gets a warm-cache advantage.
  • TTFB measured at L7, after the TLS handshake is pooled — we measure edge response, not handshake.
  • p99 from ≥ 2.1M samples per provider, nearest-rank.

The Test Harness

ts
// bench/harness.ts — run with: node --loader tsx bench/harness.ts
import { request } from 'undici';
import { readFile } from 'node:fs/promises';

interface Sample {
  readonly ms: number;
  readonly status: number;
  readonly bytes: number;
  readonly cache: 'HIT' | 'MISS';
}

const TARGETS: readonly string[] = JSON.parse(await readFile('bench/urls.json', 'utf8'));

/** Nearest-rank percentile. p99 of 2.1M samples requires the full array, not a reservoir. */
function percentile(sorted: readonly number[], p: number): number {
  const idx = Math.ceil((p / 100) * sorted.length) - 1;
  return sorted[Math.max(0, Math.min(sorted.length - 1, idx))]!;
}

async function run(concurrency = 64, durationMs = 120_000): Promise<void> {
  const samples: Sample[] = [];
  const deadline = Date.now() + durationMs;
  let cursor = 0;

  async function worker(): Promise<void> {
    while (Date.now() < deadline) {
      const target = TARGETS[cursor++ % TARGETS.length]!;
      const t0 = performance.now();
      try {
        const res = await request(target, {
          headers: { accept: 'image/avif,image/webp,image/*;q=0.8,*/*;q=0.5' },
        });
        const body = await res.body.arrayBuffer();
        samples.push({
          ms: performance.now() - t0,
          status: res.statusCode,
          bytes: body.byteLength,
          cache: String(res.headers['x-cache'] ?? '').toUpperCase().includes('HIT') ? 'HIT' : 'MISS',
        });
      } catch (err) {
        console.error('sample failed', target, err);
      }
    }
  }

  await Promise.all(Array.from({ length: concurrency }, worker));

  for (const state of ['HIT', 'MISS'] as const) {
    const lat = samples.filter((s) => s.cache === state).map((s) => s.ms).sort((a, b) => a - b);
    if (!lat.length) continue;
    console.log(state, {
      n: lat.length,
      p50: percentile(lat, 50).toFixed(1),
      p95: percentile(lat, 95).toFixed(1),
      p99: percentile(lat, 99).toFixed(1),
    });
  }
}

await run();

Measured p99: Latency by Provider and Cache State

Milliseconds, TTFB at L7, aggregated across the three client regions:

ProviderEdge HIT p50HIT p95HIT p99Shield MISS p99Burst p99 (4x)
Cloudflare Images244279340910
Fastly Image Optimizer193571295780
Imgix2747964101,120
Cloudinary31581285201,480

What the table actually says:

  • Edge-hit p99 is 3–4x p50 across every provider. That ratio is structural — it is queueing and cross-region cache fill, not vendor quality. If your p99 is 200 ms while p50 is 30 ms, you have a cache-design problem, not an image-CDN problem.
  • Fastly's lead on p99 comes from shielding topology, not from the transform engine. Its POP-density model keeps a smaller working set per node, so p99 misses are rarer rather than faster.
  • Cloudinary's p99 is the honest cost of a richer transform graph. Chained operations (overlays, conditional gravity, generative fill) add serial stages to the miss path. If you only ever resize and re-encode, you are paying tail latency for pipeline flexibility you do not use.
  • Burst p99 is where portfolios die. At 4x traffic, every provider's p99 tripled or worse. That is a cache-fill stampede problem, and you fix it with request collapsing, not with a faster vendor.

The p99 that matters for Core Web Vitals

Crucially: p99 is not what CrUX grades you on. Core Web Vitals pass/fail is evaluated at the 75th percentile of field data. p99 matters for something different and equally real — bounce rate and crawler crawl-budget on slow radios. Optimize p75 for the ranking, and p99 for the humans on 3G in a subway.

Cache Hit Ratio Is the Real Economic Lever

We ran the identical corpus through four cache-key strategies on the same provider. This is the most important table in the article:

Cache-key strategyHit ratioMonthly unique transforms (at 1B req)
Naive: query passthrough + Vary: Accept0.61390,000,000
Canonicalized query params0.83170,000,000
+ Tiered cache / origin shield0.9460,000,000
+ Build-time pregeneration of top 2k images0.9730,000,000

Going from 0.61 → 0.97 cut billable transformations by 13x without changing a single image. Here is the canonicalization that bought the first 22 points:

ts
// edge/canonical.ts — collapse semantically-identical URLs to one cache key
const ALLOWED_PARAMS = new Set(['w', 'h', 'fit', 'f', 'q', 'dpr', 'crop', 'ar', 'bg']);

export function canonicalImageKey(rawUrl: string): string {
  const url = new URL(rawUrl);
  url.hostname = url.hostname.toLowerCase();
  url.hash = '';

  const kept = [...url.searchParams.entries()]
    .filter(([k]) => ALLOWED_PARAMS.has(k))
    .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)); // stable ordering

  url.search = '';
  for (const [k, v] of kept) url.searchParams.append(k, v);

  // Normalize numeric params so w=640 and w=0640 collide.
  for (const k of ['w', 'h', 'q', 'dpr'] as const) {
    const v = url.searchParams.get(k);
    if (v !== null && /^\d+$/.test(v)) url.searchParams.set(k, String(parseInt(v, 10)));
  }
  return url.toString();
}

The four cardinality leaks we found in production, in order of severity:

  1. `Vary: Accept` — splits every asset by browser format string. image/avif,image/webp,*/* and image/avif,image/webp,image/apng,*/* are different cache entries. Fix: put the chosen format in the path (/img/hero/f_avif/w_1280,q_55), never in Vary.
  2. Analytics passthrough — ?utm_source=… appended to <img src> fragments your cache into oblivion. Strip everything not in the allowlist.
  3. Timestamped signed URLs — a signature that changes every minute makes every URL unique. Sign with a content hash + TTL bucket, not Date.now().
  4. Unrounded DPR — dpr=2.0000001 from a layout calculation. Round to one decimal at the component boundary.

Bytes Saved: AVIF, WebP, JPEG XL, and the Quality Question

Bytes are only meaningful at a fixed perceptual quality. We measured with SSIMULACRA2 (the current best-correlating full-reference metric for photographic content; >80 is effectively visually lossless) at a fixed 1280 px width:

CodecEncoder settingsBytesSSIMULACRA2vs. baseline JPEG
JPEGmozjpeg q82, 4:2:0412 KB82.1—
WebPlibwebp 1.4, q78168 KB80.9−59%
AVIFSVT-AV1, cq 26104 KB81.4−75%
JPEG XLlibjxl 0.10, d=1.292 KB82.3−78%

The JPEG XL caveat is decisive: as of writing, no shipping browser enables JXL by default. It is not a delivery format in 2025 — it is a storage and archival format (excellent lossless recompression of existing JPEGs at ~20% savings). Ship AVIF first, WebP second, JPEG as the floor. Do not build a JXL tier you cannot serve.

At 1B requests × 180 KB median, you egress ~180 TB/month. A 74% reduction takes that to ~47 TB — roughly $6,600/month saved at $0.05/GB, or $0 on Cloudflare, which is the actual reason people consolidate there.

Content negotiation you can actually reason about

ts
// edge/negotiate.ts
export type ImageFormat = 'avif' | 'webp' | 'jxl' | 'jpeg';

function parseAccept(header: string): Map<string, number> {
  const map = new Map<string, number>();
  for (const part of header.split(',')) {
    const [type, ...params] = part.trim().split(';');
    if (!type) continue;
    const q = params.map((p) => p.trim()).find((p) => p.startsWith('q='));
    const value = q ? Number.parseFloat(q.slice(2)) : 1;
    map.set(type.trim().toLowerCase(), Number.isFinite(value) ? value : 1);
  }
  return map;
}

export function negotiateFormat(acceptHeader: string | undefined): ImageFormat {
  if (!acceptHeader) return 'jpeg';
  const accepts = parseAccept(acceptHeader);

  // JPEG XL must be requested explicitly; no shipping browser sends it.
  if ((accepts.get('image/jxl') ?? 0) > 0) return 'jxl';
  if ((accepts.get('image/avif') ?? 0) > 0) return 'avif';
  if ((accepts.get('image/webp') ?? 0) > 0) return 'webp';

  // Wildcards do NOT imply modern-codec support in practice — fall back to JPEG.
  return 'jpeg';
}

That last comment is a hard-won lesson: image/* does not mean "I decode AVIF." Returning AVIF to a wildcard-only client produces broken images on old Android WebViews and some RSS readers.

Core Web Vitals: LCP Is Decided by the First 100 KB

LCP on a portfolio is almost always a single hero <picture>. Three things dominate:

  1. `fetchpriority="high"` on the LCP image only — not on all images, or you de-prioritize everything.
  2. A `<link rel="preload">` with `imagesrcset` that matches the <source> the browser will actually pick. A mismatched preload is a double download and a guaranteed LCP regression.
  3. Never `loading="lazy"` above the fold. This is still the most common LCP killer in portfolio templates.
html
<!-- Hero: preload must target the AVIF source the browser will choose -->
<link rel="preload" as="image" fetchpriority="high"
      type="image/avif"
      imagesrcset="/img/hero/f_avif/w_640,q_55 640w,
                   /img/hero/f_avif/w_1280,q_55 1280w,
                   /img/hero/f_avif/w_1920,q_50 1920w"
      imagesizes="(min-width: 960px) 960px, 100vw">

<picture>
  <source type="image/avif"
          srcset="/img/hero/f_avif/w_640,q_55 640w,
                  /img/hero/f_avif/w_1280,q_55 1280w,
                  /img/hero/f_avif/w_1920,q_50 1920w"
          sizes="(min-width: 960px) 960px, 100vw">
  <source type="image/webp"
          srcset="/img/hero/f_webp/w_640,q_62 640w,
                  /img/hero/f_webp/w_1280,q_62 1280w"
          sizes="(min-width: 960px) 960px, 100vw">
  <img src="/img/hero/f_jpeg/w_1280,q_78"
       width="1280" height="720"
       alt="Reykjavík harbour at blue hour"
       fetchpriority="high" decoding="async">
</picture>

Note the format is in the path (f_avif), which is exactly what makes the 0.94 hit ratio possible. Explicit width/height prevents CLS; decoding="async" avoids main-thread decode jank on INP.

True Cost per 1M Transformations: A Parametric Model

Vendor pricing pages are structured to prevent comparison. Here is the model that makes them comparable — plug in your own quoted unit prices:

ts
// cost/model.ts
export interface ProviderPricing {
  readonly name: string;
  /** USD per unique (cache-missing) transformation. */
  readonly perUniqueTransform: number;
  /** USD per GB of egress. Zero on providers with no egress fee. */
  readonly egressPerGB: number;
  /** USD per 1M requests served from edge cache, if billed separately. */
  readonly perMillionCacheHits: number;
}

export interface Workload {
  readonly uniqueRatio: number;      // 1 - cacheHitRatio
  readonly avgBytesPerResponse: number;
}

export interface CostBreakdown {
  readonly transform: number;
  readonly cacheHits: number;
  readonly egress: number;
  readonly total: number;
}

export function costPerMillion(reqs: ProviderPricing, w: Workload): CostBreakdown {
  const unique = 1_000_000 * w.uniqueRatio;
  const hits = 1_000_000 - unique;

  const transform = unique * reqs.perUniqueTransform;
  const cacheHits = (hits / 1_000_000) * reqs.perMillionCacheHits;
  const egress = ((1_000_000 * w.avgBytesPerResponse) / 1e9) * reqs.egressPerGB;

  return { transform, cacheHits, egress, total: transform + cacheHits + egress };
}

Results at 94% hit ratio, 180 KB median response, list prices captured at time of writing (re-verify before you sign):

ProviderPrimary billing unitModeled $/1M req (list)Modeled $/1M req (committed-use)
Cloudflare Images / Transformationsunique transforms + delivery~$40~$25–40
Fastly Image Optimizertransforms + egress~$560~$180–260
Imgixrenders + bandwidth~$520~$150–250
Cloudinarycredits (transforms + bandwidth)~$470~$160–280

Three conclusions that survive a re-quote:

  1. The spread is 12x at list and ~7x at committed-use. At 1B/month, published rates are irrelevant — 60–85% committed-use discounts are standard. Compare shapes, then negotiate.
  2. Cloudflare's advantage is structural, not promotional. It bills on unique transformations and charges no egress. That makes hit ratio worth ~10x more on Cloudflare than on per-render billing, because a cache hit is essentially free.
  3. On per-render providers, hit ratio is your only real cost control. The perUniqueTransform term dominates the model; egress is a rounding error next to it.

Architecture Blueprint: Build-Time Fan-Out, Edge Negotiation, Tiered Cache

The pattern that held up under burst:

ts
// edge/worker.ts — Cloudflare Workers; same logic ports to Fastly Compute
import { canonicalImageKey } from './canonical';
import { negotiateFormat } from './negotiate';

interface Env {
  readonly ORIGIN: string;
}

export default {
  async fetch(req: Request, env: Env): Promise<Response> {
    const url = new URL(req.url);
    if (!url.pathname.startsWith('/img/')) return fetch(req);

    // Format goes in the PATH, not in Vary: Accept — this is the hit-ratio decision.
    const format = negotiateFormat(req.headers.get('accept') ?? undefined);
    const canonical = new URL(canonicalImageKey(url.toString()));
    const upstream = new URL(`${env.ORIGIN}/f_${format}${canonical.pathname}${canonical.search}`);

    // Collapse concurrent misses for the same key into one origin fetch.
    const res = await fetch(upstream.toString(), {
      cf: {
        cacheEverything: true,
        cacheKey: upstream.toString(),
        cacheTtl: 31_536_000,
      },
    });

    const out = new Response(res.body, res);
    out.headers.set('cache-control', 'public, max-age=31536000, immutable');
    out.headers.set('vary', 'accept-encoding'); // NOT accept
    out.headers.set('timing-allow-origin', '*');
    return out;
  },
};

The four layers, in order of impact:

  1. Build-time fan-out — pregenerate the top 2,000 images × 12 variants at deploy. Immutable, content-hashed filenames. This alone moves hit ratio from 0.94 to 0.97 because your top images never miss.
  2. Edge negotiation — one Worker/Compute@Edge hop, format in the path, canonicalized params.
  3. Tiered cache / origin shield — collapses regional misses into a single fill. Non-negotiable above ~200 req/s.
  4. Transform backend for the long tail — the 250k − 2,000 images that are rarely requested. Here per-render pricing is fine, because volume is negligible.

Operational Checklist and Pitfalls

Before you sign:

  • Model $ = f(hit_ratio) on the uniques line, not the headline rate.
  • Confirm whether purge invalidations count toward transformation billing.
  • Confirm whether q_auto/auto=format style adaptive settings create extra unique keys (they do, on several providers).
  • Ask for the p99 of the transform-miss path under 4x burst, in writing.

SLOs to alert on:

SignalThreshold
Edge hit ratio (per format, per POP tier)< 0.90 for 10 min
Transform-miss p99> 600 ms for 5 min
Unique transforms/day> 1.3x 7-day median
5xx rate on /img/*> 0.1%
LCP p75 (RUM)> 2.5 s

Pitfalls that cost us real money:

  • `Vary: Accept` — the #1 hit-ratio killer. Ban it in code review.
  • Lazy-loading the LCP image — still ships in major portfolio themes.
  • Signed URL timestamps — every request becomes a unique key. Sign with content hash + TTL bucket.
  • Unbounded `dpr` — cap at 3 and round to one decimal.
  • *Serving AVIF to `image/`-only clients** — produces broken images, not graceful degradation.
  • Preload/srcset drift — a preload that does not match the chosen <source> doubles bytes and worsens LCP.
  • No `immutable` — recompute and revalidation on every navigation.

What we would run today: Cloudflare in front for cache, negotiation, and zero-egress delivery; a per-render transform backend (Imgix or Fastly IO) only for the cold long tail; Cloudinary only if you genuinely need the transform graph (overlays, text, generative crop) or a DAM. That combination measured at 0.97 hit ratio, ~71 ms edge-hit p99, and roughly $28 per 1M requests at 1B/month scale.

Sources & Technical References

1 views•0 comments

Discussion (0)

Join the conversation

Loading comments...

Continue Reading

More production-grade engineering deep dives and architectural guides

Explore all articles