Learning WebSub (Part 1) : Introduction to WebSub

Ayesh Almeida
3 min readMar 6, 2023

--

Photo by Austin Distel on Unsplash

WebSub is an open protocol for distributed publisher/subscriber communication. It outlines a common mechanism which could be used by a publishers of any kind of web content and their subscribers based on HTTP webhooks.

WebSub is a protocol that enables real-time notifications of content-updates. It is based on publisher/subscriber model, where publishers publish updates to their content, and subscribers receive those updates. WebSub allows for this communication to occur in a decentralized and scalable manner.

Before WebSub, publishers has to rely on polling, which involves subscribers periodically checking the publishers’ server for updates. This approach can be resource intensive, especially for publishers with a large number of subscribers. WebSub offers a more efficient alternative, allowing subscribers receive update in real-time without the need for constant polling.

WebSub contains 3 main roles:

  • Publisher: Person who update content for a topic
  • Subscriber: Person who registers to received updates for a topic
  • Hub: Mediator between the publisher and the subscriber

Publisher and Hub

The relationship between the publisher and the hub is simple. Publisher advertises a hub and a topic in a resource URL. A subscriber can identify the topic and hub in which the topic has been hosted by sending a request to this resource URL [1].

And when there is a content-update for a topic, publisher will notify the hub and the hub will then notify the subscribers.

Subscriber and Hub

WebSub subscriber subscribes to a topic advertised by a publisher in a specific hub. Following diagram depicts the WebSub subscriber interactions with publisher and hub.

WebSub Subscriber Interactions

Following are the description for the sequences shown in the above diagram.

  1. Subscriber discovers the hub advertised by publisher’s topic.
  2. Subscriber makes an HTTP POST request to the hub to subscribe to updates about topic .
  3. Hub verified the subscription attempt with an HTTP GET request to the
  4. Publisher notifies the hub of new content.
  5. Hub delivers the contents of the topic to each subscriber with an HTTP POST request to the subscriber endpoint.

Sequences (1), (2), and (3) are related to the subscription flow. Sequences (4) and (5) describe the content distribution flow, when there is an update the the topic .

Note: Subscriber receives content-updates for the topic only after the subscription attempt is verified by the hub.

Key Features

  • Scalable : Can handle large number of publishers and subscribers using hubs, which acts as intermediaries between publishers and subscribers.
  • Real Time : Enables real-time notifications of content updates to subscribers.
  • Flexible : Can be used for wide range of use cases, from news and media to API integration and IoT.

Use Cases

  • News and media : Can be used to provide real-time updates to news and media content, allowing subscribers to stay up-to-date on breaking news and events.
  • Social media : Can be used to provide real-time notifications for social media content, such as likes, comments, and shares.
  • API Integration : Can be use to simplify the API integration between reactive micro-services by providing a HTTP based publisher/subscriber model.
  • IoT : Can be used to provide real-time updates for IoT devices, allowing subscribers to monitor and control devices in real-time.

WebSub is a simple but powerful protocol that enables real-time content syndication and notification. It provides a scalable approach to content updates, allowing publishers to notify subscribers in real-time without the need for constant polling. WebSub has a variety of use cases, from news and media to API integration and IoT. With its efficient and scalable approach to content updates, WebSub is sure to play an important role in the future of real-time communication.

--

--

Ayesh Almeida
Ayesh Almeida

Written by Ayesh Almeida

A Tech Enthusiast who wants to build simple solutions for complex problems.

No responses yet