LambdaLens
Serverless video analysis that scaled out to concurrent streams and halved its own cloud bill.
50%
Cloud cost reduction
90%+
Inference accuracy
Unseen video data
Real time
Concurrent stream processing
See it work
The problem
Analyzing video for faces and key scenes on a persistent GPU box meant paying for idle capacity between jobs, and a burst of uploads would queue behind whatever was already running.
Approach
Uploads land in S3, which emits events into SQS. Lambda consumes that queue, so concurrency follows the actual arrival rate and there is no idle compute between bursts. A queue between storage and compute also means a spike is absorbed rather than dropped.
FFmpeg decodes video into frames and OpenCV handles preprocessing before a ResNet-34 model classifies each frame. Running inference inside the same function avoids a network hop per frame.
The container was the cost problem. Trimming layers, pruning build dependencies, and shrinking the image cut both cold-start time and per-invocation cost roughly in half.
Structured CloudWatch logs carry a correlation identifier through every stage, so a single frame can be traced end to end instead of guessing which invocation failed.
Architecture
Decisions and tradeoffs
Serverless instead of a persistent worker
S3 events into SQS into Lambda.
- Why
- Workload arrived in bursts. Paying per invocation matched spend to actual usage and removed the idle cost entirely.
- What it cost
- Accepted cold starts and hard execution limits, which constrained how large a single unit of work could be.
Optimize the image before optimizing the model
Aggressive container slimming.
- Why
- Profiling showed image pull and initialization dominated cost, not inference. The cheapest 50% came from the build, not the math.
- What it cost
- A leaner image is more brittle. Dependencies have to be pinned deliberately, and upgrades break more visibly.
Correlation identifiers in structured logs
One traceable identifier threaded through every stage.
- Why
- With hundreds of concurrent invocations, unstructured logs make a single failure effectively unfindable.
- What it cost
- More log volume and cost, plus the discipline of passing context through every function boundary.