Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Kogan.com Dev Blog 5 min read Deep dive mediumAdept

Patterns & Best Practices in Event-Driven Systems

Five core event-driven architecture patterns, compared with their tradeoffs: event notification (thin signals that force consumers to call back), event-carried state transfer (full payloads that decouple consumers at the cost of size and schema discipline), event sourcing with CQRS, choreography and orchestration. Recommended practices include idempotent consumers backed by unique constraints on event IDs, durable replayable streams such as Kafka or EventBridge+SQS, explicit event versioning, schema registries with Avro/Protobuf compatibility modes, domain-driven event names, and correlation IDs for distributed tracing. Many systems mix choreography for simple flows with orchestration for multi-step workflows that need retries and compensation.

Related posts

  • Asynchronous computing at Meta: Overview and learnings

    Meta Engineering mediumAdept

    Meta re-architected Async tier, its serverless asynchronous computing platform running multi-trillion workloads per day, by splitting an overloaded Dispatcher into data-source-specific "tailers" and a source-agnostic scheduler. Tailers now push work to the scheduler over RPC instead of the scheduler pulling from the FOQS queue. This removed redundant copying into FOQS, improved end-to-end latency and cross-region load balancing, and made streams, warehouses and pub/sub first-class sources, at the cost of being a poor fit for long-running workloads. Queues offer lease-based granular retries and flexible ordering at moderate cost, while streams are cheaper for high-volume sequential access but clog on failed items. A separate controlled-delay service, backed by a priority queue or chained fixed-delay streams, preserves at-least-once delivery without blocking the stream.

  • Event-driven architectures using Neon and Sequin

    Neon mediumAdept

    Sequin offers a lighter alternative to Debezium plus Kafka for change data capture on Neon Postgres, using a logical replication slot to build a strictly ordered "Sequence" of table rows that consumers can read, rewind and replay without copying data into a separate system. Setup covers enabling logical replication in Neon, creating a pgoutput replication slot and a publication, defining a Sequence with a sort column, and creating a pull consumer group with optional SQL filters and a chosen start position. Consumers fetch batches over an HTTP receive endpoint and acknowledge them with ack tokens, and Sequin redelivers rows until they are acknowledged.

  • Enhancing Distributed System Load Shedding with TCP Congestion Control Algorithm

    Zalando Engineering mediumAdept

    Zalando's customer communication platform applies TCP-style AIMD (Additive Increase Multiplicative Decrease) congestion control at its ingestion point to shed load and prioritize critical messages. The Stream Consumer pulls events from Nakadi and watches RabbitMQ publish latency (P50) and publish errors as congestion signals. Each event type's throttle adjusts its consumption rate independently: higher-priority types increase faster and decrease less (e.g. +15/−20% for P1 vs +5/−60% for P3), so no central coordination is needed. After six months in production, order confirmations keep stable processing times while commercial messages absorb delays. RabbitMQ queues stay small, and backlog remains in Nakadi, where low-priority events can be discarded in an emergency.

  • Utilizing Amazon DynamoDB and AWS Lambda for Asynchronous Event Publication

    Zalando Engineering mediumAdept

    Zalando Payments decoupled event publication from synchronous DynamoDB writes in its Order Store service using the Transactional Outbox pattern, removing the message bus from the request path and raising the availability ceiling from 99.8% to DynamoDB's own. DynamoDB Streams act as the outbox, emitting old and new item images to a Python AWS Lambda that builds a data-change event with a diff patch and publishes it to Nakadi. Failed publishes retry with exponential backoff, then land in an SQS dead letter queue that a Kubernetes CronJob drains by rerunning the same code. The tradeoff is that event ordering is no longer guaranteed.

  • Fan-out from Postgres with Change Data Capture using Debezium and Upstash Redis

    Neon mediumAdept

    Streaming committed Postgres changes from the write-ahead log via a logical replication slot avoids the dual-write problem, where an application writes to the database and a message broker separately and can leave them inconsistent. LISTEN/NOTIFY doesn't fix this because it is only at-most-once. The guide configures Debezium Server to read Neon's WAL using pgoutput, with an initial snapshot and file-based offset tracking, and to sink change events into an Upstash Redis stream. A Node.js consumer then uses XREADGROUP consumer groups and XACK to get at-least-once fan-out that can resume after restarts.

The quest for software engineering knowledge.

Look:
Layout: