At once you might have thought what on earth does the title mean, when you read PubSubHub – right ? Well the name seems absurd but has its own meaning inside. Just to relieve a little from your anxiety PubSubHub means PublishSubscribeHub. And its nothing but an open source server-to-server publish/subscribe extension of Atom & Rss. Its a decentralized protocol which can help internet reach close to webhooks.
Yeah with webhooks, web will no longer be driven by You & me. The web is going to weave itself automatically using webhooks. Well this blogpost is not about webhooks, so I can shutup right here and start telling you more about PubSubHub. Look at the image below and try to grasp something.
Did you able get something ? Think it is much similar to RSS and what is the use of doing the hub way ? Well let me try explaining this step-by-step:
- A URL declares a HUB using the link tag like
. This HUB(s) can be self hosted or any of the public hubs.
- A subscriber receives normal Atom feed. If the received feed contains a HUB definition then it can subscribe to HUB instead of the URL – why ? Well subscribing to the URL(this is what we have been doing since years now) pings server repeatedly for new content. The server has to respond to every request saying “That you have got the latest content”. This is also known as repeated polling. You can change the ping intervals to the sever, but there is no ideal time for it. If you set it to 1 minute, then the server is pinged every 1 minute causing overhead to server and the requester both. And if delay is of 1 hour or more then its too much time. However PubSubHub tries to eliminate this problem and update you with the latest content within in seconds, so even 1 minute seems to be a long interval then.
- Now that a new content is published by a publisher, it pings the HUB server saying “Hey I have some new stuff for you, take it and distribute it !!”. The HUB pulls the content and multicasts it to the subscribers. The subscribers are nothing but authenticated users.
As mentioned at the starting of the blog post that , PubSubHub is a decentralized protocol which means that there is no company which centrally controls it. It is an open protocol and any one can run a hub, you can start your own hub. For instance you can get PHP’s client library to ping PubHubSub at Google Code under the project PubSubHub. WordPress already has a plugin for PubSubHub and many other CMS also support the same.
Now to conclude this post, the three steps that can get you started to be real-time are :
- Publish content using any Open Source client.
- Subscribe using Open Hubs.
- Write or build your own hub – Smarty, eh ?
Still confused ? Just go through the presentation on PubSubHub :
So lets contribute in creating a real-time web and start using PubSubHub.
Stay Digified !!