← All projects

Amazon · 2024–2025 · design author & lead engineer

Perceptual compression engine: the smallest file that still looks right.

An automated optimization pipeline for marketing and storefront graphics. Each image is compressed 60 ways in parallel and scored for how it looks to a human, and the smallest file that clears a quality floor ships.

compressions tried in parallel per image
60
SSIMULACRA 2 perceptual quality floor
≥ 80
peak concurrent workers, sized from first principles
2,500
of marketing graphics in scope, across web, desktop and mobile
100%

01 / architecture

How it works

Compression engine: a synchronous request path, a 60-way parallel quality search, a size-cap search path, and async lineage SYNCHRONOUS PATH · UP TO 250 REQUESTS / MIN Marketing toolsraw upload Optimize APIquality or size cap Stage originaltemp, 30-day TTL Fan-out engine60 parallel jobs Select winnersmallest ≥ 80 PublishURL + score PARALLEL QUALITY SEARCH · 60 WORKERS PER IMAGE fan out 60 scores chroma subsamplingon chroma subsamplingoff Q99score Q98score … Q86≥ 80 ✓ … Q71score Q70score example winner Q99score Q98score … Q86score … Q71score Q70score ScorerSSIMULACRA 2binary inruntime layer each worker compresses at one level, then scores the result against the original size cap set Bounded binary search range Q0 → default level at most 3 iterations stop when range ≤ 5 levels Variants every level kept AI lifestyle edits Source record uncompressed original uses Source Background job after response 0 added latency SIZE-CAP PATH · 5% OF TRAFFIC ASYNC LINEAGE · OFF THE REQUEST PATH 1 2 3 4 5 6
  1. 1Parallel enumeration30 quality levels (99 down to 70) × chroma subsampling on and off gives 60 compressions per image, all run at once. The whole space is searched in one round-trip of about 10 s.
  2. 2Perceptual scoring at scaleThe SSIMULACRA 2 binary is packaged into the serverless runtime. Each worker downloads the original and its candidate, scores them, and returns size and score.
  3. 3Selection ruleBy default, the smallest file scoring at least 80 wins. The chosen level and score go back in the response, so marketers see the quality cost of every file.
  4. 4Bounded binary searchFor the ~5% of requests with a hard file-size cap, a search from Q0 up to the default level runs at most 3 iterations and stops once the range is 5 levels or fewer. This caps latency and rendering cost.
  5. 5Async lineageAfter the response, a background job records the original as a source and each output as a variant, using Source. Lineage adds no latency, and repeat requests can reuse results.
  6. 6Backward-compatible APIA new quality mode and max-file-size field on the existing optimize API. Marketing tools preview the default result through a 30-day temporary URL and set a size cap only when they need one.

02 / trade-offs

Trade-offs, measured

Sizing the worker pool

Concurrency = requests per second × jobs per request × seconds per job

250 / minpeak request rate
÷ 60 ×
60jobs per image
×
10 sper compress + score
=
2,500concurrent workers

10 s per job is a conservative budget; the existing optimize API's p99 was about 8 s. Estimated running cost was about $1K per 100M renderings, which made full enumeration affordable.

Which path requests take

Share of marketing image requests

The size-cap path serves a small, shrinking share of traffic, so it was designed to spend as little compute as possible rather than search exhaustively.

Two algorithms for the size-cap path

Compressions per request compute cost
Enumerate
40
Binary
10
Sequential rounds latency
Enumerate
1
Binary
≤ 3

Enumeration wins on latency and binary search wins on cost. Both are designed for this path; binary search is the fallback that caps compute.

03 / impact

Impact

marketers no longer pre-compress images by hand, which used to degrade them before upload
0 manual steps
a guaranteed perceptual quality floor, with the score returned for every file
≥ 80 on every image
the full 60-candidate search finishes in about 10 s at a peak of 250 requests/min
1 round-trip

What it unlocked