← All case studies

Case study

Scaling a time-critical event pipeline 6x

From 200K to 1.2M events per minute on a queue-based pipeline where a late event counts as a failed one.

Context
A consumer smart-home security company operating at very large scale. Device events feed a downstream service where every second of delay matters.
My role
Senior Software Engineer on the team owning the pipeline.

Results

throughput: 200K → 1.2M events per minute
6x

The problem

The architecture

ProducersBatch device events
Amazon SQSAt-least-once
CloudWatchAge of oldest message
AutoscalingOn queue depth
ConsumersECS Fargate
Dead-letter queuePoison messages
Downstream serviceDedup on event id
On time1.2M events / min

Follow one video from the moment it is uploaded until it is searchable. Press play, or step through the stages at your own pace.

Decisions and trade-offs

Scale on pending work, not CPU

Consumers scale on how many messages are waiting. CPU is the wrong signal for a pipeline whose real constraint is elsewhere.

Find the real bottleneck

Throughput plateaued while CPU looked fine: consumers were starved of network connections. Raising the connection limits removed the ceiling. CPU-based scaling would never have reacted.

Make the effect exactly-once

Delivery cannot be exactly-once, so processing is: a dedup key on the event id, state-shaped writes and conditional writes.

Alarm on age, not throughput

The key alarm is the age of the oldest message. A late event is a failed event, even when events per second look great. Dead-letter queues, a throttle and a kill switch complete the runbook.

Stack