Mastering Message Exchange Patterns: From Pub/Sub to Anycast

This article explains the fundamental message exchange architectures and routing patterns—including publish‑subscribe, fan‑out, unidirectional and bidirectional streaming, as well as unicast, broadcast, multicast, and anycast—illustrated with diagrams and practical examples for modern backend systems.

ITFLY8 Architecture Home
ITFLY8 Architecture Home
ITFLY8 Architecture Home
Mastering Message Exchange Patterns: From Pub/Sub to Anycast

Conceptually, a message is an information exchange between a sender and one or more receivers, a core component of programming and system architecture since the mainframe era.

Message Exchange Architecture

This section describes the mechanisms for moving messages between senders and receivers.

Publish‑Subscribe

The Pub‑Sub pattern sends messages from a publisher to a broker’s topic (an inbox). Subscribers bind to the topic and receive messages asynchronously. Implementations include RabbitMQ (Exchange) and Kafka (Topic).

Publish‑Subscribe diagram
Publish‑Subscribe diagram

Publish‑Subscribe is ideal for delivering event information to interested parties.

The benefits are simplicity—message in, message out—and asynchrony, eliminating blocking locks between sender and receiver.

Fan‑out

Similar to Pub‑Sub, fan‑out allows many subscribers to bind to a single topic; when a message is sent, all subscribers receive a copy, effectively “distributing” the message.

Fan‑out diagram
Fan‑out diagram

Fan‑out sends a copy of the message to every interested subscriber.

Twitter is a classic example: a tweet is delivered to all followers.

Unidirectional Streaming

In this mode the sender continuously streams data to the receiver, such as a mobile device sending GPS updates to a server.

Unidirectional streaming diagram
Unidirectional streaming diagram

The sender pushes a continuous data flow to the receiver.

Alternatively, the sender can connect to a broker that forwards the stream to subscribed receivers.

Broker‑mediated stream diagram
Broker‑mediated stream diagram

Message brokers can manage unidirectional streams.

Bidirectional Streaming

Both sender and receiver continuously exchange messages, establishing a persistent connection (e.g., gRPC over HTTP/2) that allows data to flow in both directions.

Bidirectional streaming diagram
Bidirectional streaming diagram

Bidirectional streaming enables constant data flow between client and server.

Routing

This section covers how messages are routed between senders and receivers, focusing on unicast, broadcast, multicast, and anycast.

Unicast

Messages are routed from the sender to a specific receiver; HTTP request/response is a classic example.

Unicast diagram
Unicast diagram

In unicast, a single message is sent to one receiver.

The web browser sends a request to a web server, which routes the request and returns a response via the same routing mechanisms.

Broadcast

The sender transmits a message to all receivers on the network; routers discover devices and forward the message.

Broadcast diagram
Broadcast diagram

Broadcast delivers a message to every network participant.

An example is ARP, which maps IP addresses to MAC addresses and forwards messages accordingly.

Multicast

Messages are sent to a specific group of receivers, such as devices of a certain type or subnet.

Multicast diagram
Multicast diagram

Multicast forwards a message to a defined group of receivers.

IPTV uses multicast to stream video to devices tuned to a particular channel.

Anycast

Routers deliver the message to any receiver that satisfies a set of conditions, often based on geographic proximity.

Anycast diagram
Anycast diagram

Content Delivery Networks (CDNs) commonly use anycast to serve users from the nearest server.

Summary

Developers and architects who work with messaging in applications will recognize many of these patterns; some names may be new, but the implementations are familiar. Using standard names for message‑transfer patterns streamlines communication and design discussions, helping teams quickly agree on solutions such as “use publish‑subscribe to meet this business need.”

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendDistributed SystemsarchitectureroutingMessagingpub/sub
ITFLY8 Architecture Home
Written by

ITFLY8 Architecture Home

ITFLY8 Architecture Home - focused on architecture knowledge sharing and exchange, covering project management and product design. Includes large-scale distributed website architecture (high performance, high availability, caching, message queues...), design patterns, architecture patterns, big data, project management (SCRUM, PMP, Prince2), product design, and more.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.