4 ms·
> Is it really wise to build a publish-subscribe delivery system on top of HTTP? This seems to be a huge overhead. I'm only just learning about WebSub tonight,
by jcrites 8y ago
> Is it really wise to build a publish-subscribe delivery system on top of HTTP? This seems to be a huge overhead.
I'm only just learning about WebSub tonight, but it looks like a lean, efficient, and fairly minimal protocol to me. What gives you the impression that there will be huge overhead - could you be more specific?
When new content is published to a topic in WebSub, it's delivered with an HTTP POST that will look something like this:
POST / HTTP/1.1
Host: foo.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 13
Link: <https://hub.example.com/>; rel="hub"
Link: <http://example.com/feed>; rel="self"
say=Hi&to=Mom
If content is being published to a topic at high volume, then the HTTP connection for each subscription will remain open persistently, meaning that you pay the cost to establish it only once when receiving the first message. (If there aren't enough messages to take advantage of a persistent connection, then efficiency probably doesn't matter that much for the use-case.)
Furthermore, it looks like these messages can be sent using HTTP/2, if client & service support it (which is something that you'd prioritize for cases where efficiency matters). HTTP/2 is a binary protocol and takes advantage of HPACK header compression (RFC 7541). This means that if the same header appears in multiple requests, it will be transmitted very efficiently. Thus WebSub headers that are likely to be the same for all requests across a connection (like Host, Content-Type, and Link) will be transmitted virtually for free.
Even the vanilla HTTP/1.1 request described above seems reasonable though -- certainly not something that strikes me as a cost or efficiency problem -- and the HTTP/2 framing of the content is probably going to be not much longer than the content payload.
Now let's compare to XMPP PubSub. From looking at XEP-0060, an item published over that protocol looks like the following - based on Example 101 in: https://xmpp.org/extensions/xep-0060.html#publisher-publish https://xmpp.org/extensions/xep-0060.html#publisher-publish
<message from='pubsub.shakespeare.lit'
to='francisco@denmark.lit' id='foo'>
<event xmlns='http://jabber.org/protocol/pubsub#event'>
<items node='princely_musings'>
<item id='ae890ac52d0df67ed7cfdf51b644e901'>
<entry xmlns='...'>
say hi to mom ...
</entry>
</item>
</items>
</event>
</message>
[Edit: changed from example 99 to 101, and elided the part of the content that was Atom-specific to more fairly compare the framings.]
Based on this naive comparison, I don't see a reason to conclude that WebSub will have more overhead than XMPP PubSub. When implemented over HTTP/2 it may be more efficient.
- edhelas 8y agoHere you are comparing publishing an Atom post to XMPP and publishing a simple message. It will more look like something like that (even if it's not valid). <iq type='set' to='pubsub.shakespeare.lit' id='publish1'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='mom'> <item id='bnd81g37d61f49fgn581'> <body>say hi to mom</body> </item> </publish> </pubsub> </iq> But indeed if you want to start to put a bit more metadata in your first example (publication, edition date, id, summary, alternate link) well you'll quickly reach a similar structure (with the XML around). That is also the power of Pubsub. It is that it gives you the freedom to put what you want in it (it can be Atom posts like in your example, but also stock market tickets that are pushed each 5 sec, some server monitoring logs...). You define your own namespace, write a little parser for it and use the thing into your XMPP Pubsub library :)