liveBook · Manning

Asynchronous programming

As explained in Grokking Software Architecture

An execution model in which work is initiated without requiring the caller to wait for its completion.

Asynchronous programming lets work proceed without making the caller wait for every task to finish. In distributed systems, it can keep noncritical work off the user’s request path or start independent service calls together. section 6.8.4 section 12.6.1

Choose the approach to match what the user needs to wait for:

  • Defer noncritical work: verify stock and charge the card during checkout, then queue the shipping-label task for later. This avoids making checkout depend on the shipping service. section 6.8.4
  • Overlap independent requests: an API aggregator can call post, author, and comment services at the same time rather than waiting for each call in sequence. It still needs to handle service failures and fallback behavior. section 12.6.1 section 12.7.2

A blog-page aggregator

A C# method starts HTTP requests to three services, then uses Task.WhenAll to wait for them together. It checks whether the core post request succeeded before assembling the page; partial failures still need deliberate fallback handling. section 12.7.2

Figure 6.14 Avoiding the Distributed Monolith: Breaking a fragile synchronous chain with an asynchronous queue ensures critical tasks succeed even if non-critical services fail.

A queue breaks the synchronous order-processing chain by moving label printing out of the critical path. section 6.8.4

How Grokking Software Architecture covers it

How deep it goes
Demonstrates queue-based deferral and concurrent HTTP requests without detailing asynchronous execution internals.
Examples
Uses queued shipping-label printing and a blog aggregator that concurrently requests post, author, and comment data.
What you can do after
Apply it by queueing noncritical work or issuing independent HTTP calls concurrently, while accounting for partial failures.
How it connects
Connects asynchronous programming with message queues, microservices, API gateways, and event-driven architecture.

Also explained in

Compare how 37 books explain asynchronous programming →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.