Race weekscene 17 / 26~3 min

Now, or later

The queue, finally named.

Every design on the wall answers one question over and over: does the asker need this answer now, or does the work merely need to happen soon? The whole act of sorting jobs into those two piles has run under this story since its first half-second.

Work done while the asker waits is Concept · lights on your mapsynchronous processingWork performed while the requester waits: the answer must come back before the response is honest. The reason a spinner exists.: Case’s registration had to be validated before the screen could honestly say anything, so Case watched a spinner for the duration. Work accepted now and done soon, with nobody waiting, is Concept · lights on your mapasynchronous processingWork accepted now and performed soon, with nobody waiting on it. Sorting each job into now or soon is a core design skill, and most systems are a braid of both.: the confirmation email did not delay the yes by one millisecond, and arrived two minutes later, and both of those facts were the design working. Act I ended on exactly this split without naming it. Named.

The waiting line, and who empties it

The machinery of soon is a Concept · lights on your mapqueueA waiting line for work: components put messages describing tasks in one end, and the messages wait until something takes them out the other. It decouples the asker from the doer, so the urgent answer never waits on the slow work., a waiting line for messages describing work. The ingest path drops send the notifications onto the line and turns back to the mats, which is the ADR from Act II, working: the write joins a queue, so nothing waits on what comes next. And the thing at the other end of the line is a Concept · lights on your mapworkerA program whose job is taking messages off a queue and doing them, with no user waiting and no request to answer. It can take its time, retry, and even crash harmlessly, since the message just returns to the queue.: a program with no audience, pulling messages and doing them. The mat’s row at 120 milliseconds, a worker takes the split off the queue, is one of these, mid-shift. Workers can be slow, can retry, can crash and let the message fall back into the line for another go. Nothing with a spinner can afford any of those luxuries, which is the entire reason the two kinds of work are kept apart.

A queue between two components is also a shock absorber, and on Sunday that stops being a metaphor: when a quarter-million events arrive in bursts, the line holds the surge while the workers chew steadily. Depth of queue becomes a number on the wall, watched like a river gauge.

One row of the mat remains unexplained: how one crossing becomes three different consequences without the mat knowing any of them. That trick has its own scene.

End of scene

This scene covers: synchronous processing, asynchronous processing, queue, worker, SQS

Monolith and microservices