jonnify·redis /redis-patterns/production-operations/capstone

R8.07 · Capstone — the door to the EchoMQ course

Thirty patterns, one thread.

The course capstone: nine chapters and thirty Redis patterns, each proven once in the real BCS build — EchoMQ backed by Valkey, EchoStore in front, codemojex the worked consumer — read back as one line. The thread that ran through all of it is the branded id.

Grounding: the real surfaces the course taught — the branded JOB id and the emq:{q}: keyspace (echo/apps/echo_mq), EchoMQ.Jobs.enqueue/claim, EchoMQ.Lanes.claim/3, EchoMQ.Keyspace.slot/1 (slot("123456789")==12739), AOF durability (infra/valkey/conf/valkey.conf, appendfsync everysec), EchoStore (echo/apps/echo_store), and the consumer Codemojex.Guesses.submit/3 (echo/apps/codemojex). The branded-id vectors are from echo/apps/echo_data branded_id self_check. The engine is Valkey.

The arc, R0 to R8. Nine chapters, each landing its patterns on a real surface. Hover or select a chapter to read what it taught and where it applied.
R0 → R8 · thirty patterns, each applied to a real surface · the branded id is the thread R0catalog R1cache R2coord R3queue R4time R5stream R6flow R7model R8prod one id minted at the consistent core, carried unchanged to the available periphery
readout · Select a chapter to read the patterns it taught and the real surface it applied. Each is one row of the R0 catalog, worked.

A capstone is not a new pattern. It is the whole course read back as one line: thirty patterns, nine chapters, and one consistent claim — a pattern is worth learning only when you can apply it, so each one landed twice, once as the pattern and once as the real move it became.

§1

The arc — nine chapters, thirty patterns

the course · R0–R8

The course moved from a single key to a production tier, and each chapter landed its patterns on a real surface you can open on disk — none of it invented for the page.

ChapterThe patternsApplied surface
R0 · Catalogthe thirty patterns mapped; the frame that holds them — problem, solution, trade-off, placethe catalog itself
R1 · Cachingcache-aside, stampede control, client-side caching, sessionsEchoStore — L1 ETS over L2 Valkey, coherence by mint time
R2 · Coordinationatomic operations, locks, the fencing token, the inline Lua moveone EVAL over keys that share a slot
R3 · Reliable queuesthe state machine, at-least-once delivery, claim, lease, retryEchoMQ.Jobs — a branded JOB claimed under a server-clock lease
R4 · Time & prioritydelay sets, priority queues, the scheduled job promoted on timethe schedule set on the bus
R5 · Streams & eventsappend-only events, consumer groups, the replayable logthe retained, ordered history
R6 · Flow controlrate limiting, fair lanes, groups, batches, worker concurrencyEchoMQ.Lanes via Codemojex.Guesses.submit/3
R7 · Data modelingthe primary-database trade, encodings, secondary indexes, time seriesthe structure chosen for the access pattern
R8 · Productionkernel settings, AOF durability, the pool, reconnect, colocation, telemetryvalkey.conf · EchoMQ.Pool · EchoMQ.Keyspace · EchoMQ.Meter

Thirty patterns, each proven once in the real BCS build. Every figure in the course was quoted from code or config — a real emq:{q}: key, a script verb, a valkey.conf directive, an EchoStore figure — never a benchmark dump, never an invented surface.

§2

The through-line — one branded id, carried unchanged

echo_data/branded_id.ex

The course had a single thread, worth naming on its own: the branded id. One 14-character name — a 3-character uppercase namespace and 11 Base62 characters carrying a 63-bit snowflake — minted once at the consistent core and carried unchanged to the available periphery. Every chapter handled that one id under a different aspect, and it has four properties.

The four properties of the id. The same 14-char id runs through all four; each is the property one part of the course relied on. Select a property to read which chapter used it and the real surface.
one id: USR0KHTOWnGLuC · 3-char namespace + 11 Base62 over a 63-bit snowflake typednamespace on the wire + in the type → emq:{q}:job:<JOB> (R2, R3) orderedtext sorts as the mint instant → the mint-ordered queue (R3, R4) placedslot("123456789")==12739 → the {q} hashtag, one of 16384 slots (R2, R8) conformantplacement("USR0KHTOWnGLuC")==234878118 → a polyglot fleet (R8.06) the brand is checked at every boundary — a value cannot be used where it does not belong
readout · Select a property. Typed gates the key, ordered orders the queue, placed colocates the slot, and conformant lets a polyglot fleet share one bus — one id, four properties.

Source truths, not measurements (echo/apps/echo_data branded_id self_check) — placement("USR0KHTOWnGLuC")→234878118 · parse("USR0NgWEfAEJfs")→{:ok, "USR", 320636799581945856} · decode("USRzzzzzzzzzzz")→:error (an overflow is refused, not wrapped). The USR namespace is the manuscript's illustrative figure; a codemojex example uses PLR / ROM / GAM / GES / JOB.

echo_data/branded_id.ex · self_checkfrozen
# the boot-asserted vectors — source truths, not benchmarks
placement("USR0KHTOWnGLuC")  => 234878118              # placed: native & pure agree
parse("USR0NgWEfAEJfs")      => {:ok, "USR", 320636799581945856}
decode("USRzzzzzzzzzzz")     => :error                 # an overflow is refused, not wrapped

Notes on ValkeyThe placed property is a Valkey cluster fact: every key of a queue carries the queue's {q} hash tag, so they all hash (CRC16 of the brace bytes) to one of the 16384 cluster slots and co-locate. That is what keeps a multi-key claim or atomic Lua script legal (no CROSSSLOT) and lets EchoMQ.Keyspace.slot/1 route client-side — valkey.io/topics/cluster-spec.

That fourth property, conformant, is what makes a polyglot worker fleet possible: if every runtime agrees on the id and its placement, a Go worker and an Elixir worker can drain the same bus. The shipped bus is Elixir; the polyglot fleet is the conformance target the wire protocol and the id contract make reachable, demonstrated in the EchoMQ Proof pillar.

§3

What you can now do

the course · outcomes

The course's outcomes, stated plainly. After these thirty patterns you can:

  • Choose the right pattern and name its failure mode. Cache-aside risks staleness; at-least-once delivery risks a duplicate; a fixed-window limiter risks a burst at the boundary. Knowing the trade is the skill — the pattern is the easy half.
  • Read a real atomic Lua move and say why the multi-key change is one script. The keys share a slot (the {q} hashtag), so the change is atomic and CROSSSLOT-safe — one EVAL, not a transaction that can interleave.
  • Build a reliable, scheduled, observable, rate-limited queue. The claim-with-lease, the retry with a fencing token, the delay set, the telemetry tree, the token bucket — each a pattern you saw applied, and Codemojex.Guesses.submit/3 the worked consumer that composes them.
  • Operate the tier as a system of record. AOF durability (appendfsync everysec bounds worst-case loss to about a second), a pool sized for round-trip-hiding rather than cores, a reconnect discipline that fails in-flight callers rather than replay them, cluster colocation by hashtag, and a telemetry surface a Prometheus or OpenTelemetry exporter can read.
the recap · one move from each end of the coursefrozen
R3 enqueue   EchoMQ.Jobs.enqueue(conn, "cm", JOB, payload)      ← a branded JOB on the bus
R6 fair lane Codemojex.Guesses.submit/3 → Lanes.enqueue/5      ← one guess, the PLR lane
R8 durable   valkey.conf: appendonly yes / appendfsync everysec  ← AOF, the durability dial
R8 placed    EchoMQ.Keyspace.slot("123456789") == 12739          ← one of 16384 cluster slots

The skill the course built is judgement, not recall: a pattern, the failure it guards against, and the one real move it becomes — from a single enqueue to the durability dial that keeps it across a restart.

§4

The door — the system that applies them

/echomq · six pillars

Redis Patterns Applied taught the patterns. The dedicated EchoMQ, In Depth course teaches the system that applies them, in depth, across its six pillars — all built. Every Redis pattern here is one move the EchoMQ protocol makes; the protocol governs all of them at once, and the polyglot fleet — one bus drained by workers in several runtimes — is the conformance target it makes reachable.

this course

Thirty Redis patterns, taught applied: cache-aside and stampede control (R1), atomic Lua and the fencing token (R2), the reliable-queue state machine (R3), schedules (R4), the replayable log (R5), fair lanes and flow control (R6), the modeling trades (R7), and production operations (R8). Each landed on a real surface.

EchoMQ, In Depth

The same patterns as one owned protocol: /echomq/overview (the bus, the three roles), /echomq/protocol (the emq:{q}: keyspace, the Lua layer, branded ids), /echomq/queue (jobs, lanes, claim, retry, schedule, flow), /echomq/bus (the retained event log), /echomq/cache (the near-cache), and /echomq/proof (conformance and the measurement plane — the polyglot-fleet target).

The natural next course is the system itself: the patterns are the vocabulary, the EchoMQ protocol is the grammar that composes them, and the six pillars are where each move is taught in depth on the real shipped code.

§5

References

sources · related

Sources

  • Valkey — Cluster specification — the {q} hash tag forces a queue’s keys onto one of the 16384 slots, the placement property the atomic Lua move and cluster colocation depend on.
  • Valkey — Persistence — AOF as the single source of durability; appendfsync everysec bounds worst-case loss to about a second, the production durability dial R8 grounded.
  • Valkey — EVAL — the scripting primitive behind every atomic multi-key move in the course; one script, declared keys, no interleave.
  • Redis — Redis patterns — the pattern catalog the course is built on, each entry taught here applied to a real system.
  • llms.txt — the convention — the route-mirrored markdown this course keeps beside every page, one source of record per route.

Related in this course