Patterns

Messaging patterns for Node.js services: request/reply, competing consumers, work queues, delayed and recurring work, and Redis pub/sub versus streams.

10 articles

Aug 28, 2026 · Mykhailo Stadnyk

Checking an IP against 10,000 networks without comparing it to 10,000 networks

Every request asks the same question — is this one of ours? — and the loop you wrote to answer it gets slower every time someone adds a partner range. Here is how to answer it in logarithmic time instead, what an address really is once you stop treating it as a string, and the quiet precondition that a fast implementation must uphold or it will lie to you.

read →
Aug 18, 2026 · Mykhailo Stadnyk

Cache invalidation across services: a TTL, a tag, or the database

Caching a service method is one decorator. Deciding when the entry dies is the whole job. Here are the three mechanisms measured — a guessed TTL, a tag invalidated by an event, and PostgreSQL dropping the entry 6ms after the row changes — plus the four ways a cache goes on serving data it already knows is stale, and a fifth that got fixed while this was being written.

read →
Aug 14, 2026 · Andrii Glushko

The N+1 problem when GraphQL resolvers call microservices

A field resolver runs once per parent object. Put a service call inside it and one innocent-looking query becomes twenty-six. Here is the same query measured at 26 calls and at 3, why your latency chart will not show you the difference, and the two ways the fix comes back silently empty.

read →
Aug 13, 2026 · Serhiy Morenko

Distributed tracing for Node.js services over a message queue

The standard objection to queue-based RPC is that you lose the trace: the caller sends, something else picks it up, and the connection between them is gone. It isn't — the trace context rides in the request metadata. Here is a measured three-process trace, and the four ways it silently comes out wrong.

read →
Jul 31, 2026 · Serhiy Morenko

One notification, every replica: the LISTEN/NOTIFY duplicate problem

LISTEN/NOTIFY is a broadcast, not a queue. Scale a Node app to three replicas and the same notification gets handled three times — no error, no warning, three charges on the card. Here's why, and what an inter-process lock actually does about it.

read →
Jul 28, 2026 · Andrii Glushko

Graceful shutdown and zero-drop deploys

Every deploy sends a kill signal to a process that is probably in the middle of something. Nothing 500s, no dashboard turns red, and the work is gone anyway. Here's what actually happens to an in-flight message on SIGTERM, and the built-in drain that keeps it.

read →
Jul 24, 2026 · Serhiy Morenko

Auto-scaling Redis broker: with and without broadcast

One Redis behind your message bus is a ceiling and a single point of failure. The promoter and unicaster modules turn a fleet of plain Redis instances into a horizontally auto-scaling broker — here are the recipes for networks that deliver broadcast and for clouds like GCP that don't, and how to encrypt the result when the brokers announce addresses no certificate can carry.

read →
Jul 23, 2026 · Andrii Glushko

One isolated imq CLI home per @imqueue project

Every imq invocation shares one ~/.imq — one config, one pid registry, one set of logs. Here's how to give each project its own isolated CLI environment with IMQ_CLI_HOME, plus recipes for direnv, shell wrappers, per-client tokens and disposable sandboxes.

read →
Jul 23, 2026 · Serhiy Morenko

RPC over Redis in Node.js: patterns and pitfalls

How request/reply RPC over Redis actually works in Node.js — correlation, timeouts and at-least-once delivery, which of those @imqueue handles for you, and what it deliberately leaves to you: retrying a failed RPC call, coalescing duplicate concurrent calls with @lock, and the circuit breaker it does not ship.

read →
Jun 22, 2026 · Mykhailo Stadnyk

Redis as a message bus: patterns beyond pub/sub

Most people know Redis pub/sub and stop there. Redis has richer primitives — lists, blocking pops, and streams — that make it a capable message bus. Here's a tour, and where each fits.

read →