Redis Pub/Sub vs Streams: Which to Choose in Python?

Redis Pub/Sub and Redis Streams seem to meet the same need: a producer emits, consumers receive. Both take a few lines to set up, and in a development environment they produce the same result. The difference shows up with a single question: what happens if the consumer isn’t there when the message is sent? A deployment, a network drop or a crashed worker is enough to raise it. The answer actually separates three models: Pub/Sub broadcast, reading a log with XREAD, and sharing work with consumer groups. ...

November 4, 2026 · 8 min · Anthony
Redis Pub/Sub vs Streams: Which to Choose in Python?

Polling, Long Polling or SSE: What to Choose in Python?

An order changes status, an export finishes, a message arrives. The server knows, the browser doesn’t. Polling, long polling and Server-Sent Events (SSE) all answer that same question, and they often get mixed up because the result on screen looks alike. What separates them is who triggers the delivery and what silence costs, when nothing changes. Let’s look at how each one works, what it really costs, and why the simplest solution is often the right one. ...

October 5, 2026 · 7 min · Anthony
Polling, Long Polling or SSE: What to Choose in Python?

Server-Sent Events vs WebSocket: Which to Choose in Python?

As soon as a screen has to update without a page reload, WebSocket enters the conversation. Order tracking, export progress, notifications, an LLM answer appearing token by token: the reflex is to open a bidirectional channel. Yet in all of these cases, the client has nothing to say to the server once the connection is established. The Server-Sent Events (SSE) pattern meets exactly this need with a plain HTTP response that never ends. The choice goes beyond protocol preference. It determines what you get for free (reconnection, resumption, HTTP authentication) and what you will have to build yourself. Let’s compare the two in Python, with FastAPI and Django, all the way to the problems that only show up in production. ...

September 15, 2026 · 11 min · Anthony
Server-Sent Events vs WebSocket: Which to Choose in Python?

GitOps Without Kubernetes: Django with doco-cd, SOPS and age

GitOps is almost always presented with Kubernetes in the background: ArgoCD, Flux, manifests by the hundreds. As a result, many teams deploying on a plain VPS with Docker Compose assume the model does not apply to them. They keep deploying over SSH: git pull, docker compose up -d, crossing their fingers that nobody skips a step. That is a shame, because the core of GitOps has nothing to do with Kubernetes. And for some time now, one tool has been filling exactly this gap: doco-cd, a continuous deployment engine for Docker Compose. Combined with SOPS and age to encrypt secrets directly in the repo, you get GitOps without Kubernetes: a complete pipeline where deploying boils down to git push. This article explains the principle, then walks through the setup on a Django project with several compose files. ...

June 29, 2026 · 10 min · Anthony
GitOps Without Kubernetes: Django with doco-cd, SOPS and age

CQRS in Django: a denormalized read model without Event Sourcing

The four previous articles in the series laid the building blocks for a distributed system to stay consistent: Saga to orchestrate workflows, Outbox to publish reliable events, Inbox to consume them without duplicates, Idempotency Keys to protect the API. One question is left: what do you do with events once they are published? The most common answer: you use them to build read views. That is exactly what the CQRS pattern (Command Query Responsibility Segregation) proposes: separate the write model from the read model when both diverge enough that forcing them into a single structure costs more than splitting them. ...

June 5, 2026 · 7 min · Anthony
CQRS in Django: a denormalized read model without Event Sourcing

Idempotency Keys: stopping a client from paying twice

The previous two articles tackled idempotency on the event side: the Outbox pattern guarantees a message is published at least once, and the Inbox pattern guarantees it is consumed only once. One last place where the same problem shows up sits further upstream: the HTTP API itself. When a client fires a POST /api/payments and the connection drops before the response comes back, the client has no way to know whether the payment was created. If it retries, it risks paying twice. If it does not retry, it risks not paying at all. The Idempotency Key pattern, popularized by Stripe and adopted since by most payment APIs, solves that dilemma by putting retry control in the client’s hands. ...

June 4, 2026 · 7 min · Anthony
Idempotency Keys: stopping a client from paying twice

Inbox pattern: consuming events without replaying them twice

The previous article on the Transactional Outbox set a clear guarantee: every event written to the database will eventually be published. That guarantee is intentionally at-least-once. A consumer may receive the same event two times, three times, or more if the network behaves badly. The Outbox pattern never promises uniqueness. The consequence follows immediately: if the consumer applies the effect of the message twice, it bills twice, sends two emails, decreases stock twice. The consistency guaranteed on the producer side collapses on the reader side. ...

June 3, 2026 · 7 min · Anthony
Inbox pattern: consuming events without replaying them twice

Transactional Outbox: publishing events without losing consistency

When a service updates its database and wants to notify the rest of the system by emitting an event to Kafka, RabbitMQ or SQS, the naive code looks like this: write to the database, then publish. If publishing fails after the commit, the event is lost. If publishing succeeds but the commit fails, the event refers to a state that does not exist. Both cases define the dual-write problem. The Transactional Outbox pattern fixes that inconsistency with a simple idea: never publish directly. The event is written to an outbox table within the same SQL transaction as the business change. A separate process reads that table and publishes to the broker. As long as the SQL transaction is atomic, the database and the future event are consistent by construction. ...

June 2, 2026 · 7 min · Anthony
Transactional Outbox: publishing events without losing consistency

Saga pattern: handling distributed transactions without rollback

A business operation that spans several services raises a question SQL has been answering for fifty years inside a single database: what happens when one step succeeds and the next one fails? As long as everything lives in the same database, BEGIN ... ROLLBACK is enough. The moment you call an external service, a third-party API or another database, that safety net disappears. The Saga pattern answers that question. Rather than attempting an impossible ACID transaction, it breaks the operation into local steps, each paired with a compensating transaction that knows how to undo its effect. If step 4 fails, the compensations for steps 1, 2 and 3 are replayed in reverse order. ...

June 1, 2026 · 7 min · Anthony
Saga pattern: handling distributed transactions without rollback

Anti-corruption layer: isolating your code from external APIs

Consuming an external API looks harmless at first. You run a requests.get, get a dictionary back, and use it directly throughout the code. The problem starts when that same JSON structure ends up scattered across ten files, and the API renames a field or switches price from float to string. Fixing it becomes a treasure hunt. The anti-corruption layer (ACL) addresses this problem. Borrowed from Domain-Driven Design, it acts as a translator between an external system and your business logic. One contact point, one place to update when the API changes. ...

May 27, 2026 · 4 min · Anthony
Anti-corruption layer: isolating your code from external APIs

Newsletter

Get new articles delivered straight to your inbox.