Exactly-Once, CQRS, and Event Sourcing Replay on AWS
Quick summary: Exactly-once is a myth end-to-end—but idempotent consumers plus event stores get you close. CQRS read models on DynamoDB streams, Kinesis, and EventBridge replay semantics.
Key Takeaways
- CQRS read models on DynamoDB streams, Kinesis, and EventBridge replay semantics
- June 2026 truth: AWS messaging is at-least-once unless you engineer Kafka EOS or FIFO dedup—and your database write must still be idempotent
- Benchmark pattern (hypothetical workload) — order service with CQRS on DynamoDB + Kinesis, 8K events/sec, idempotent consumer dedup via conditional writes reduces duplicate side-effects from 1
- 2% to 0
- 001%, replay of 72-hour window completes in 47 minutes on 12 Lambda parallel consumers
Table of Contents
June 2026 truth: AWS messaging is at-least-once unless you engineer Kafka EOS or FIFO dedup—and your database write must still be idempotent.
Symptom → mechanism → AWS control
| Production symptom | Mechanism | AWS control |
|---|---|---|
| Duplicate charges on retry | At-least-once delivery without idempotency | DynamoDB idempotency keys, SQS FIFO deduplication |
| Stale read model after replay | Projection lag during catch-up | Kinesis enhanced fan-out, dedicated projection workers |
| Unbounded event store growth | Append-only without compaction | DynamoDB TTL on snapshots, S3 archival via Firehose |
Opinionated take: Exactly-once is a consumer contract—implement idempotent writes on DynamoDB and treat Kinesis as at-least-once, not a magic guarantee.
Benchmark pattern (hypothetical workload) — order service with CQRS on DynamoDB + Kinesis, 8K events/sec, idempotent consumer dedup via conditional writes reduces duplicate side-effects from 1.2% to 0.001%, replay of 72-hour window completes in 47 minutes on 12 Lambda parallel consumers.
Layers of “exactly-once”
- Broker — Kafka transactions / SQS FIFO dedup ID
- Consumer — idempotency key store (DynamoDB)
- Projection — CQRS read model version column
CQRS + event sourcing on AWS
| Piece | Service |
|---|---|
| Event log | Kinesis / MSK / EventBridge archive |
| Command side | Lambda + Aurora |
| Read model | DynamoDB / OpenSearch |
| Replay | New consumer group / replay archive to SQS |
Replay strategies: rebuild read model from offset 0; use version vectors / optimistic locking on projections.
AWS services map
| Need | Service | Skip when |
|---|---|---|
| Durable event log | Kinesis Data Streams | Simple CRUD with PostgreSQL |
| Idempotent side-effects | DynamoDB conditional writes | Fire-and-forget SNS notifications |
| Read model rebuild | Lambda + DynamoDB GSI projections | Single-table OLTP with no projections |
What to do this week
- Add
event_idunique constraint on projection table. - Test replay in staging—measure duplicate suppression.
- Read microservices patterns guide for outbox.
More in This Track
Part of the Engineering Guides library (June 2026).
- Previous: Part 4
- Next: Part 6
- Browse tracks: Engineering Guides hub
What this guide doesn’t cover
Saga orchestration—canonical microservices post.
AWS Cloud Architect & AI Expert
AWS-certified cloud architect and AI expert with deep expertise in cloud migrations, cost optimization, and generative AI on AWS.