AWS S3 as an Interface Between Independent Event Systems

An S3 batch-ingestion case study: PostgreSQL discovery and journaling, concurrent file claims, record-level change detection, and failure-recovery trade-offs.

  • AWS
  • Architecture
  • Distributed systems
  • Backend
An optional bidirectional S3 architecture with incoming event files and a separate results prefix

1. The integration problem is not always technical

When two independently operated systems need to exchange a large volume of events, the default response is often to introduce a queue, event bus, or streaming platform. That may be justified, but it also introduces shared infrastructure and additional coordination around platform ownership, access, schemas, and operational responsibilities.

In many organisations, the hardest parts of integrating independently operated services are not technical. Competing priorities, different KPIs, ownership boundaries, constrained capacity, and busy roadmaps all create friction.

In these scenarios, there is significant value in choosing the simplest integration point that allows teams to cooperate while minimising mutual dependencies, both technical and operational.

2. The core pattern: immutable files plus a consumption ledger

The pattern is straightforward: the event producer writes immutable batches of events to a defined S3 location, and the event consumer discovers and processes new files independently.

S3 holds the source files for their configured retention period, while a consumption ledger—typically a database table—records file discovery and processing state. Together, these components provide a foundation for replayable integration, provided retention, failure recovery and downstream idempotency are deliberately designed. S3 itself does not provide consumer acknowledgements, retries or queue state.

When no suitable shared messaging platform already exists, publishing immutable files to S3 can require substantially less cross-team coordination than introducing and operating shared streaming infrastructure.

Flow A: incoming events
Event producer → S3 incoming/ → consumer ledger → event consumer

Flow B: result events (one possible return channel)
Event consumer → managed delivery stream → original producer

In the implementation behind this article, a scheduled discovery task compares the available S3 objects with a PostgreSQL file ledger and registers unseen files as pending. Changes to that ledger are journaled, and journal consumers initiate processing. Workers guard against concurrent processing with row-level locking. This prevents simultaneous claims, but does not itself guarantee that failed processing will be retried. The broader production-grade pattern should include bounded claims, retry scheduling and a recovery path for abandoned work. Object immutability must likewise be enforced by convention or configuration rather than assumed from S3.

The interface can also work in both directions

The S3 boundary can also be used in both directions: a consumer could publish immutable result files to a separate prefix for its original producer. That is an architectural option, not a requirement. In the implementation that informed this article, processing outcomes were returned through a separate managed delivery stream, while S3 handled incoming batches.

Return events can represent per-record ingestion outcomes, subsequent business results or transformed data. Keeping the return channel independent means each side can choose the transport and delivery guarantees suited to its workload.

Where both directions use S3, each needs its own schema, object namespace, consumption state and recovery policy. When the return path uses another transport, its own acknowledgement and retry guarantees must be considered separately.

3. Inside a real batch consumer

The architectural sketch becomes more useful when viewed as a processing sequence. In one implementation, a producer exported newline-delimited JSON files to a date-organised S3 prefix. A scheduled consumer discovered new objects and registered them in a PostgreSQL ledger. The ledger was journaled, so newly pending records triggered file processing without requiring a separate query loop over pending rows.

File-level coordination

A worker selected a pending ledger row using SELECT ... FOR UPDATE SKIP LOCKED. That allowed multiple workers to encounter the same journal record without concurrently processing the same file. The straightforward implementation held the transaction and row lock until the whole file had finished. This is an important trade-off: it gives simple exclusion, but ties up a database connection and keeps a transaction open during network I/O and potentially lengthy processing.

A stronger design for larger workloads is a short transactional claim: change the file to a processing state with a lease, commit, process outside the transaction, and then record completion. A periodic recovery process can return expired claims to the queue. These mechanisms are recommendations rather than guarantees supplied by the original long-running transaction.

Record-level processing

Once downloaded, each JSON Lines record was parsed independently. Malformed records generated individual failure outcomes rather than making the entire file unreadable. Repeated records within a file were collapsed by a stable business key, with the last occurrence winning. That policy works only when file order is meaningful; it should not be confused with selecting the record with the newest business timestamp.

The remaining records passed through a throttled worker pipeline with bounded parallelism. Rate limiting protected downstream systems, while the concurrency cap limited simultaneous persistence and reporting operations. Limits must apply across concurrently processed files if the system needs a global throughput ceiling; a per-file throttle is not a global one.

Before updating the item store, the consumer normalised relevant fields and computed a fingerprint from values that could affect downstream decisions. Unchanged records could skip the database write and the subsequent processing event. This was valuable because the expensive work was not parsing the file; it was the downstream pipeline triggered by each meaningful change.

This optimisation has a subtle coupling: when a fingerprint depends on the active business rules, changing those rules may require a replay or rescreening operation. Otherwise previously processed records can retain decisions derived from an older rule set until fresh input arrives.

Completion is not the same as success

The consumer emitted per-record ingestion outcomes independently of later business results. It could therefore acknowledge that a record had been accepted, skipped or rejected without implying that the downstream business decision had already completed.

The file-level state was coarser: a file could be marked processed even when individual records failed. That can be a reasonable contract when failures are reported and reconciled separately, but it requires monitoring at both levels. A processed-file counter alone is not sufficient evidence of a healthy ingestion pipeline.

4. Why S3 can be the simplest viable solution

For batch-oriented workloads, S3 can deliver most of the properties the integration actually needs with very little shared infrastructure. Object storage is generally inexpensive for this access pattern, producers and consumers can remain available independently, and throughput can grow by partitioning files and adding workers. Total cost still includes requests, discovery scans, ledger operations, data transfer and consumer compute.

Within the configured retention window, the same data supports replay, backfills, auditing, and future consumers without a separate archival path. When delivery latency of seconds or minutes is acceptable, this can be materially easier to build and operate than a richer messaging platform.

Storage costs can be controlled through S3 Lifecycle rules that expire data after a defined retention period or transition older objects into less expensive storage classes.

5. A queryable event history with Athena

The files in S3 are not only transport artefacts; they can also become a directly queryable event archive. By defining an Athena external table over the bucket or prefix, engineers can inspect historical events using standard SQL without first loading them into another database.

This is useful for debugging, audits, volume analysis, and validating producer output. The benefit depends on disciplined schemas and partitioning: JSON Lines is easy to adopt, while formats such as Parquet reduce scan costs for larger or more frequent analytical queries.

Retention policy should distinguish between data that must remain immediately queryable and data kept only for long-term recovery or compliance. Objects moved into archival storage classes may need to be restored before they can be queried, so cold storage reduces cost at the expense of access time and operational convenience.

6. The complexity S3 does not remove

S3 simplifies the shared infrastructure, but it does not eliminate the hard parts of reliable event processing. The consumer must still handle duplicate delivery, idempotent writes, atomic work claiming, retries, poison files, schema evolution, partial failures, and backlog monitoring.

These responsibilities are manageable when the workflow is simple, but they should be counted honestly. In particular, a pending ledger entry is not a retry policy: if processing rolls back without generating another journal event, the file can remain pending indefinitely. A reconciliation sweep, retry scheduler or lease-expiry mechanism is necessary for dependable recovery. Similarly, periodic full-bucket listings and full-ledger scans become expensive as history grows; partition-scoped discovery and key-based ledger checks are more sustainable. The pattern stops being lightweight when the application begins rebuilding a large portion of the delivery, routing and operational semantics already provided by a mature broker.

The same is true for bidirectional workflows: acknowledgement events and business-result events still need their own schemas, correlation IDs, and idempotent consumption logic.

Operational visibility should distinguish files discovered, files completed, records received, changes persisted, unchanged records skipped, parse errors and persistence errors. Recovery also depends on keeping source objects long enough to retry them, and retaining ledger identities longer than their corresponding objects so expired ledger partitions do not accidentally cause re-ingestion. The key test is whether the ledger, retry model and monitoring remain materially simpler than adopting the messaging platform they replace.

7. Polling, notifications, or both

A consumer can discover files by periodically listing S3, by reacting to object-created notifications, or by combining both approaches. Polling is simple and naturally reconciles missed work, but it introduces discovery latency and repeated listing costs.

Notifications provide faster delivery, yet remain at-least-once and add another component such as SQS or EventBridge. A practical compromise is to use notifications for prompt processing while retaining periodic S3 reconciliation as the correctness mechanism.

8. Trade-offs against structured messaging systems

S3 wins on durable retention, large batch handling, replay, low storage cost, and direct inspection of historical events. Queues and streams win on low latency, per-event acknowledgements, ordering, routing, retries, and consumer coordination.

The relevant comparison is therefore not whether S3 can imitate Kafka, SQS, or EventBridge, but whether the application needs the richer guarantees those systems provide. Choosing S3 is a deliberate trade: fewer shared infrastructure components in exchange for simpler delivery semantics and more responsibility in consumer code.

Criterion S3 files Queue or event bus Event stream
Typical latency Seconds to minutes Milliseconds to seconds Low-latency continuous delivery
Payload model Files and batches Individual messages or events Continuous ordered records
Retention and replay Natural and inexpensive Varies by service and configuration Strong within the configured retention window
Acknowledgements and retries Implemented by the consumer Usually managed per message Offsets plus application-level handling
Ordering Custom; not inherent Limited or service-specific Typically guaranteed within a partition
Historical queryability Direct through Athena Usually requires export or a separate sink Usually requires a separate analytical sink
Operational model Low shared infrastructure; more consumer logic Managed delivery semantics Richer semantics and greater platform complexity

9. When to choose this pattern

This pattern is a strong fit when:

  • events are naturally produced in files or batches;
  • delivery can tolerate seconds or minutes of latency;
  • retained history has operational or compliance value;
  • replay and backfills are likely requirements;
  • engineers benefit from querying historical events through Athena;
  • future consumers may need to read the same source data independently;
  • downstream writes can be made idempotent;
  • ingestion acknowledgements or business results can be returned through a separately designed output channel;
  • the ledger, retry logic, and monitoring remain simpler than operating a broader messaging platform.

10. When not to choose it

A queue, stream, or event bus is usually the better choice when:

  • events must arrive in near real time;
  • strict or partition-level ordering is important;
  • each event needs independent acknowledgement or retry;
  • routing, filtering, or fan-out are core requirements;
  • duplicate delivery cannot be handled safely;
  • individual record failures require precise retry control;
  • the organisation already operates a suitable messaging platform, making a second delivery model more complex rather than simpler.

11. Conclusion: choose the least structured tool that meets the guarantees

S3 should not be presented as a drop-in replacement for a message broker. It offers a different integration boundary that works well when durable batch transport, bounded retention, replay potential, queryability and loose coupling matter more than sophisticated delivery semantics. The consumer still needs intentional recovery, deduplication and observability.

The architectural decision should start from the guarantees the system genuinely needs. When those guarantees are modest, immutable files and a small ledger can be the simplest solution. When they are not, a structured messaging system earns its additional complexity.