w3c / wot-discovery

Repository for WoT discovery discussion
https://w3c.github.io/wot-discovery/
Other
20 stars 17 forks source link

Add More Scalable Event Mechanism(s) #468

Open mmccool opened 1 year ago

mmccool commented 1 year ago

Currently SSE is required to be used for event notifications, but it's not very scalable, and an alternative like Web Hooks would be useful when a TDD is implemented as a cloud service.

See also Issue #417

egekorkan commented 1 year ago

Just make sure to know that Web Hooks implies Consumers having Server functionality so it adds another type of requirement. It would make the TDD more cloud compatible but make the Consumer implementations complicated, i.e. no browser could be a TDD consumer with Webhook events. Why not mention websockets in this case?

farshidtz commented 1 year ago

SSE and WebSockets aren't much different in this context. SSE on HTTP/2 is actually more scalable than WebSockets because of the multiplexing capabilities. One major problem with both is the implementation of QoS which is necessary for sleeping devices and a burden for servers.

IMO, a broker-based pub-sub protocol such as MQTT is most appropriate and widely used. See also #134.

relu91 commented 1 year ago

I agree with what has been said above. To me, those are all valid use cases we should try to make the spec flexible enough to include MQTT-based TDDs or Webhook (rather than cloud I think webhooks should apply better in any microservice scenario).

On the other hand, this complicates the implementation of a generic consumer but this is not the first time that we introduce optional methods for similar functionalities (e.g. for search we have XPath and JSONPath).

benfrancis commented 1 year ago

Having looked at HTTP-based event mechanisms in great detail for WoT Profile, it isn't quite as straightforward as Webhooks being more scaleable than Server-Sent Events. There are circumstances under which Webhooks scale terribly or simply aren't possible.

Server-Sent Events:

Webhooks:

WebSockets:

In short, Server-Sent events works best for subscribing to high frequency events from a small number of Things whereas Webhooks work best for low frequency events sent from a large number of Things (but only if the Consumer can act as a web server). WebSockets have the benefit of being able to share a single connection between all interaction affordances of a Thing (or even multiple Things/Directories from the same origin), but still require a separate connection per origin.

Although it would certainly have scalability benefits for events, a non-web protocol like MQTT is not well suited to all of the other interaction affordances exposed by a directory. Requiring directory consumers to support both HTTP and MQTT would add significant implementation complexity. Also bear in mind that specifying multiple event mechanisms may harm interoperability, if some directories or some consumers only support a subset of the mechanisms.

mmccool commented 7 months ago

The current document says the following: "The rest of this section describes the implementation details on top of the SSE protocol. Realizing the notification functionality using other protocols such as MQTT are possible and may be formalized in future versions of this specification."

So - how about MQTT for eventing? This was also mentioned as an option for heartbeats, see #164

mmccool commented 7 months ago

One possible solution here:

lu-zero commented 7 months ago

The current document says the following: "The rest of this section describes the implementation details on top of the SSE protocol. Realizing the notification functionality using other protocols such as MQTT are possible and may be formalized in future versions of this specification."

So - how about MQTT for eventing? This was also mentioned as an option for heartbeats, see #164

I think CoAP Observe might be simpler, but any protocol that has an observe pattern as primitive should do.