Channels
Ably aggregates all its data into named units of distribution, referred to as “channels”. Channels offer a way to implement the Publish-Subscribe (Pub/Sub) architectural pattern, which is a popular pattern used for realtime data delivery.
The Publish-Subscribe messaging pattern lets any number of publishers publish data to a channel, which could be subscribed to by any number of subscribers. The key thing to note about Pub/Sub is that publishers and subscribers are completely decoupled as explained further down this page. Once subscribed, the subscribers no longer have to poll the server or data provider to check if there is any new data that they need to be aware of; instead, they will be notified of it as it becomes available.
Understanding Pub/Sub with an example
To understand Pub/Sub in more detail, let’s consider an example of location tracking of a vehicle in realtime. In this case, the vehicle whose location is to be tracked acts as a publisher, while the user intending to receive the location updates acts as a subscriber. This scenario is illustrated below.

As you can see, in order to accomplish this scenario, the client would subscribe to the location channel, to receive updates continuously being published by the vehicle to the same channel. Since the location tracking needs to be live, one would use the realtime library to implement this. Ably’s Realtime library uses the WebSocket transport protocol under the hood; thus the connection remains open for the whole duration that the app is running for.
Connections are used to establish and maintain realtime communication with channels but are separate from channels, see the connection documentation for further information.
Understanding de-coupling of Pub/Sub clients
The Ably Platform supports the Publish-Subscribe messaging pattern via the concept of channels as explained in the previous sections. With Ably, you are able to use any number of devices and languages with one another. The various clients of Ably’s Platform can be quite diverse too, as shown in the illustration below. This means that while a publisher might be a sensor working with MQTT, the subscriber could be a web browser working with JavaScript.

Ably is responsible for routing the right message to the right client in real time (typically within 60ms globally).
Read the Realtime Library documentation to learn how you can implement Pub/Sub in your applications, or you can have a look at our REST Library if you wish to do discrete operations like publishing data periodically, on channels. Further, you can also jump into the Pub/Sub tutorial or check out a video to see it in action.