Home

pubsub

Pub/Sub, short for publish-subscribe, is a messaging pattern that decouples producers of information from consumers. Producers publish messages to named channels called topics, while consumers subscribe to topics of interest to receive messages. A broker or message broker mediates between publishers and subscribers, enabling asynchronous communication and scalable distribution.

Key elements include topics, publishers, subscribers, and subscriptions. Publishers emit messages to a topic; subscribers register

Uses and considerations: pub/sub is widely used in event-driven architectures, real-time notifications, microservices communication, and IoT.

subscriptions
to
that
topic;
the
broker
delivers
messages
to
all
active
subscriptions.
Messages
may
be
delivered
immediately
or
retained
for
later
delivery,
depending
on
configuration.
Delivery
guarantees
vary;
common
modes
include
at-least-once,
at-most-once,
and
exactly-once
semantics,
though
exactly-once
is
complex
to
implement.
Subscriptions
can
be
durable,
surviving
broker
restarts,
or
non-durable.
The
system
may
support
filtering,
enabling
subscribers
to
receive
only
relevant
messages.
Advantages
include
loose
coupling,
scalability,
and
easier
integration
of
independent
components.
Drawbacks
can
include
eventual
consistency
challenges,
message
ordering
across
distributed
systems,
and
the
need
for
careful
handling
of
duplicates.
Related
technologies
and
protocols
include
MQTT,
AMQP,
and
cloud
services
such
as
Google
Cloud
Pub/Sub.
Some
systems
implement
pub/sub
as
a
distributed
log,
like
Kafka,
which
determines
ordering
and
durability
differently.