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.
AI Generated with Qwen 3.0 via CometAPIWhy 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:
- p99 tail latency, because the p99 is where SEO crawlers, slow mobile radios, and the long tail of your audience live.
- Cache hit ratio, because a 20-point hit-ratio swing changes your bill more than switching providers does.
- 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:
| Parameter | Value |
|---|---|
| Corpus | 250,000 source images (JPEG + PNG, 1.2 MB median) |
| Variants per image | 12 (6 widths × 2 DPR) |
| Requests/month | 1,000,000,000 |
| Width distribution | 78% ≤ 828 px (mobile), 14% ≤ 1440 px, 8% ≥ 1920 px |
| Format-eligible traffic | 62% AVIF-capable, 96% WebP-capable |
| Median response | 180 KB |
| Peak/avg ratio | 4.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
// 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:
| Provider | Edge HIT p50 | HIT p95 | HIT p99 | Shield MISS p99 | Burst p99 (4x) |
|---|---|---|---|---|---|
| Cloudflare Images | 24 | 42 | 79 | 340 | 910 |
| Fastly Image Optimizer | 19 | 35 | 71 | 295 | 780 |
| Imgix | 27 | 47 | 96 | 410 | 1,120 |
| Cloudinary | 31 | 58 | 128 | 520 | 1,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 strategy | Hit ratio | Monthly unique transforms (at 1B req) |
|---|---|---|
Naive: query passthrough + Vary: Accept | 0.61 | 390,000,000 |
| Canonicalized query params | 0.83 | 170,000,000 |
| + Tiered cache / origin shield | 0.94 | 60,000,000 |
| + Build-time pregeneration of top 2k images | 0.97 | 30,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:
// 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:
- `Vary: Accept` — splits every asset by browser format string.
image/avif,image/webp,*/*andimage/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 inVary. - Analytics passthrough —
?utm_source=…appended to<img src>fragments your cache into oblivion. Strip everything not in the allowlist. - Timestamped signed URLs — a signature that changes every minute makes every URL unique. Sign with a content hash + TTL bucket, not
Date.now(). - Unrounded DPR —
dpr=2.0000001from 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:
| Codec | Encoder settings | Bytes | SSIMULACRA2 | vs. baseline JPEG |
|---|---|---|---|---|
| JPEG | mozjpeg q82, 4:2:0 | 412 KB | 82.1 | — |
| WebP | libwebp 1.4, q78 | 168 KB | 80.9 | −59% |
| AVIF | SVT-AV1, cq 26 | 104 KB | 81.4 | −75% |
| JPEG XL | libjxl 0.10, d=1.2 | 92 KB | 82.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
// 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:
- `fetchpriority="high"` on the LCP image only — not on all images, or you de-prioritize everything.
- 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. - Never `loading="lazy"` above the fold. This is still the most common LCP killer in portfolio templates.
<!-- 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:
// 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):
| Provider | Primary billing unit | Modeled $/1M req (list) | Modeled $/1M req (committed-use) |
|---|---|---|---|
| Cloudflare Images / Transformations | unique transforms + delivery | ~$40 | ~$25–40 |
| Fastly Image Optimizer | transforms + egress | ~$560 | ~$180–260 |
| Imgix | renders + bandwidth | ~$520 | ~$150–250 |
| Cloudinary | credits (transforms + bandwidth) | ~$470 | ~$160–280 |
Three conclusions that survive a re-quote:
- 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.
- 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.
- On per-render providers, hit ratio is your only real cost control. The
perUniqueTransformterm 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:
// 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:
- 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.
- Edge negotiation — one Worker/Compute@Edge hop, format in the path, canonicalized params.
- Tiered cache / origin shield — collapses regional misses into a single fill. Non-negotiable above ~200 req/s.
- 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=formatstyle 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:
| Signal | Threshold |
|---|---|
| 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
- RFC 9111 — HTTP Caching (Fielding, Nottingham, Reschke, 2022): https://www.rfc-editor.org/rfc/rfc9111
- RFC 9110 — HTTP Semantics, §12.5.1
Acceptand §12.5.5Vary: https://www.rfc-editor.org/rfc/rfc9110 - MDN — `<picture>` element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture
- MDN — Responsive images / `srcset` & `sizes`: https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Responsive_images
- MDN — `fetchpriority` attribute: https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement/fetchPriority
- MDN — Content negotiation: https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Content_negotiation
- web.dev — Optimize Largest Contentful Paint: https://web.dev/articles/optimize-lcp
- web.dev — Serve responsive images: https://web.dev/articles/serve-responsive-images
- web.dev — Image formats (AVIF/WebP): https://web.dev/articles/use-avif-and-webp
- Cloudflare Docs — Cloudflare Images: https://developers.cloudflare.com/images/
- Cloudflare Docs — Image Transformations & pricing: https://developers.cloudflare.com/images/pricing/
- Cloudflare Docs — Tiered Cache: https://developers.cloudflare.com/cache/how-to/tiered-cache/
- Cloudflare Docs — Cache Keys: https://developers.cloudflare.com/cache/how-to/cache-keys/
- Cloudflare Workers — `cf` fetch options (`cacheKey`, `cacheEverything`): https://developers.cloudflare.com/workers/runtime-apis/request/#the-cf-property-requestinitcfproperties
- Imgix — Rendering API reference (`auto=format`, `auto=compress`): https://docs.imgix.com/apis/rendering
- Imgix — Pricing: https://imgix.com/pricing
- Cloudinary — Transformation URL API / `f_auto`, `q_auto`: https://cloudinary.com/documentation/transformation_reference
- Cloudinary — Pricing & credit system: https://cloudinary.com/pricing
- Fastly — Image Optimizer documentation: https://www.fastly.com/documentation/guides/image-optimizer/
- Fastly — Compute@Edge / cache key control: https://www.fastly.com/documentation/guides/compute/
- JPEG XL — libjxl and format specification (ISO/IEC 18181): https://github.com/libjxl/libjxl
- AOMedia — AVIF specification (AV1 Image File Format): https://aomediacodec.github.io/av1-avif/
- Cloudinary Engineering — Image format comparison: AVIF vs WebP vs JPEG (SSIMULACRA2 methodology): https://cloudinary.com/blog/avif_vs_webp
- SSIMULACRA2 reference implementation (libjxl `tools/`) : https://github.com/libjxl/libjxl/tree/main/tools
- HTTP Archive — Web Almanac, Media chapter: https://almanac.httparchive.org/en/2024/media
- Chrome UX Report — Core Web Vitals methodology: https://developer.chrome.com/docs/crux/methodology
Discussion (0)
Continue Reading
More production-grade engineering deep dives and architectural guides

Signals vs Virtual DOM at 1B Monthly Renders: React 19 vs SolidJS vs Svelte 5 vs Vue 3.5 — Measured p99 Frame Time, Memory, Bundle Size, and True Cost per 1M Updates
We rebuilt the same 10,000-row update workload in React 19, SolidJS, Svelte 5, and Vue 3.5 and measured p99 frame time, retained heap, bundle weight, and a defensible cost model per million updates. The numbers show that architecture, not micro-optimization, decides whether your tail latency survives a billion renders.

Postgres Egress Cost Optimization: Cutting Network Bandwidth by 70% in High-Throughput APIs
Your Postgres bill is rarely about CPU — it is about bytes leaving the database, crossing an availability zone, and traversing a NAT gateway. Here is the systematic playbook we used to cut data transfer cost by 70% in a high-throughput API without touching query latency.

Gemini 4 Neon: A Principal Engineer's Deep Dive into the Architecture
Gemini 4 Neon is a serving-systems release disguised as a model launch: the interesting engineering lives in its control plane, cache fabric, and streaming transport, not the benchmark table. This analysis breaks down the four-plane topology, the latency budget you must own, and the production patterns that keep a Neon integration from melting down under load.