Chapter 13

Singular Update Queue

Use a single thread to process requests asynchronously to maintain order without blocking the caller.

Problem

When the state needs to be updated by multiple concurrent clients, we need it to be safely updated with one-at-a-time changes. Consider the example of the Write-Ahead Log pattern. We need entries to be processed one at a time, even if several concurrent clients are trying to write. Generally, locks are used to protect against concurrent modifications. But if the tasks being performed are time-consuming, such as writing to a file, blocking all the other calling threads until the task is completed can have severe impact on the overall system throughput and latency. It is important to make effective use ...

Get Patterns of Distributed Systems now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.