---
title: Exactly-Once, CQRS, and Event Sourcing Replay on AWS
description: 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.
url: https://www.joinhorizon.co/blog/exactly-once-cqrs-event-sourcing-replay-aws/
datePublished: 2026-06-12T00:00:00.000Z
dateModified: 2026-10-28T00:00:00.000Z
author: palaniappan-p
category: Cloud Architecture
tags: engineering-guide, distributed-systems, event-sourcing, aws
---

# Exactly-Once, CQRS, and Event Sourcing Replay on AWS

> 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.

As of June 2026, AWS messaging is at-least-once unless you engineer Kafka EOS or FIFO dedup, and your database write must still be idempotent.

## Symptoms, mechanisms, and AWS controls

| 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    |

My recommendation: treat exactly-once as a consumer contract. Implement idempotent writes on DynamoDB and treat Kinesis as at-least-once.

> **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

1. **Broker:** Kafka transactions / SQS FIFO dedup ID
2. **Consumer:** idempotency key store (DynamoDB)
3. **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 the read model from offset 0, and use version vectors or 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

1. Add `event_id` unique constraint on projection table.
2. Test replay in staging and measure duplicate suppression.
3. Read [microservices patterns guide](https://www.joinhorizon.co/blog/microservices-design-patterns-aws-production-guide-2026/) for outbox.

## More in this track

Part of the **Engineering Guides** library (June 2026).

- Previous: [Part 4](https://www.joinhorizon.co/blog/consensus-paxos-raft-byzantine-fault-tolerance-cloud/)
- Next: [Part 6](https://www.joinhorizon.co/blog/microservices-design-patterns-aws-production-guide-2026/)
- Browse tracks: [Engineering Guides hub](https://www.joinhorizon.co/resources/engineering-guides/)

## What this guide doesn't cover

Saga orchestration is covered in the canonical microservices post.

## FAQ

### Does Kinesis or EventBridge give me exactly-once end to end?
No. AWS messaging is at-least-once unless you add Kafka EOS or SQS FIFO dedup, and the database write must still be idempotent. Treat exactly-once as a consumer contract with DynamoDB conditional writes, not a broker guarantee.

### When should I skip CQRS and event sourcing?
Skip a durable event log when the workload is simple CRUD on PostgreSQL with no projections. Kinesis plus a read model is for rebuildable views, not every table.

### What could go wrong if I replay without an event_id unique key?
Duplicate charges and double side-effects. Add event_id uniqueness on the projection, version the read model, and test a staging replay. FIFO dedup IDs do not protect a non-idempotent sink.

### How do I keep an append-only store from growing forever?
Snapshot and compact. DynamoDB TTL on snapshots plus Firehose to S3 for the archive is the pattern in this guide. Unbounded event stores are a cost and restore-time problem, not a purity badge.

---

*Source: https://www.joinhorizon.co/blog/exactly-once-cqrs-event-sourcing-replay-aws/*
