---
title: "Pub/Sub: key concepts and its usage for real-time application"
description: Discover the Pub/Sub concept for real-time application development and use Kuzzle to facilitate your developments using Pub/Sub.
---

[Kuzzle blog](https://blog.kuzzle.io)

# [Pub/Sub: key concepts and its usage for real-time application](https://blog.kuzzle.io/pub-sub-for-real-time-applications)

 Written by [Alicia Thermos](https://blog.kuzzle.io/author/alicia-thermos) | May 03, 2019

[Version française](https://blog.kuzzle.io/fr/pub-sub-pour-applications-temps-reel)

 

 Web and mobile applications are more and more expected to update their information in real time

 

Whether to follow stock market prices, book a cab or chat on instant messaging, the application must be updated without requiring any action from the user.

 

In this article, we will see what are the concepts behind real-time applications with Pub/Sub and then we will see how to use it with Kuzzle.

 

This article is part of a series on real-time application development:

 

- [Pub/Sub: key concepts and its usage for real-time application](https://blog.kuzzle.io/pub-sub-for-real-time-applications)
- [Develop a new generation of apps with Kuzzle real-time engine](https://blog.kuzzle.io/develop-a-new-generation-of-apps-with-kuzzle-real-time-engine)

# Pub/Sub: notify your clients in real time

 

The concept of [Publisher/Subscriber](https://www.wikiwand.com/en/Publish%E2%80%93subscribe_pattern), or Pub/Sub, is a concept in which **a communication channel (topic) is set up between a server and several clients**. This channel is represented by a persistent network communication (WebSocket, MQTT, etc.).

 

Customers, or subscribers, will first subscribe to notifications received in a specific channel. Then the server, or publisher, will send data to the clients through this channel.

 

 

 

 

So when new information is available, the server can notify the clients.

 

# Make your Pub/Sub development easier with Kuzzle

 

 

 With Kuzzle, it is very easy to implement the Pub/Sub concept in your application.

 

For this we will use:

 

- [the Realtime controller](https://docs.kuzzle.io/api/1/controller-realtime/),
- [the Javascript SDK](https://docs.kuzzle.io/sdk-reference/js/6),
- [the WebSocket protocol](https://docs.kuzzle.io/protocols/1/native-protocols/websocket/).

 

First of all, we will subscribe to a notification channel. In Kuzzle, **a channel is identified by the name of an index, the name of a collection and filters**.

 

We will come back later on the filters, concerning the index and the collection, it is not necessary that these really exist in base for the Pub/Sub, they only serve to define a communication channel.

 

To subscribe to channel notifications, we will use the [Realtime controller's subscribe method](https://docs.kuzzle.io/sdk-reference/js/6/realtime/subscribe/). **The last parameter is a callback that will be called for each new notification received.**

 

```
const filters = {};

await kuzzle.realtime.subscribe('index', 'collection', filters, notification => {
  // Do something with the notification
});
```

 

We will now publish messages in the same channel, **they will be transmitted to all customers subscribing to this channel.**

For this we will use the [publish method of the Realtime controller](https://docs.kuzzle.io/sdk-reference/js/6/realtime/publish/).

 

```
await kuzzle.realtime.publish('index', 'collection', { content: 'liia meh ry' });
```

 

Customers subscribing to this communication channel will all receive the message *{ content: ‘liia meh ry’ }*.

 

The implementation of the Pub/Sub concept in an application is very simple with the help of Kuzzle and [our SDKs](https://docs.kuzzle.io/sdk-reference/).

 

The use of a persistent protocol is necessary to be able to do Pub/Sub, for [your web or mobile applications](https://kuzzle.io/products/by-product/mobile-backend/) we recommend to use the WebSocket protocol and for [your IoT application](https://kuzzle.io/products/by-product/iot-backend/)s you can use the MQTT protocol.

# Complexity of Pub/Sub development

 

Although simple to implement, the Pub/Sub concept can pose **problems of maintainability and scalability**.

 

For each piece of information you want to make available in real time, you must create a new communication channel, your customers must subscribe to it and then finally you must send your data to it.

 

**It is necessary to have a certain amount of server side code to develop, test and maintain**

 

In Kuzzle, even if we really like real time, we find that the Pub/Sub concept is limited and that its implementation requires many resources.

 

We have therefore developed [our own real-time engine](https://docs.kuzzle.io/api/1/essentials/notifications/#documents-changes-messages-default) to overcome these problems and accelerate the development of real-time applications.

 

See you next week for the rest of this series of articles on real-time applications!

 

[View full post](https://blog.kuzzle.io/pub-sub-for-real-time-applications)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Alicia Thermos"
  },
  "dateModified" : "2025-07-21T13:48:30.666Z",
  "datePublished" : "2019-05-03T11:02:02Z",
  "headline" : "Pub/Sub: key concepts and its usage for real-time application",
  "image" : {
    "@type" : "ImageObject",
    "height" : 284,
    "url" : "https://cdn2.hubspot.net/hubfs/3803374/_blogpost%20tech_Pub_Sub_%20key%20concepts.png",
    "width" : 768
  },
  "mainEntityOfPage" : "https://blog.kuzzle.io/pub-sub-for-real-time-applications",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Kuzzle blog"
  }
}
```