Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

publish subscribe - What would be the behavior of subscriptions and notifications in an Orion Load-Balancing scenario?

Based on this answer about how to scale Orion Context Broker with load balancing https://stackoverflow.com/a/33068119/3706998 what should be the behavior of subscriptions and also notifications?

Witch server should it come from? What is the workflow?

Could it cause some disturbe or cloned subscriptions ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Let's consider different cases, depending on subscription cache usage. Let's consider two Orion nodes (A and B) without loss of generality, both sharing the same MongoDB instance.

Using subscription cache (i.e. -noCache is not set)

The subscription creation request is dispatched to some of the nodes (let's assume it is node A). Node A will persist the subscription in the shared DB and in the local (i.e. node A) subscription cache. Note that node B doesn't get aware of the new subscription until next subscription cache refresh, which means. That is as much an interval of seconds equal to -subCacheIval parameter.

Let's consider now an update (on an entity/attribute which matches subscription conditions to trigger notification) arrives. Depeding to which node the load balancer dispatches the update and the moment in which it arrives (with regards to subscription creation request time) it can happen one of the following cases:

  • Update arrives at node B, before next subscription refresh (i.e. as much as -subCacheIval seconds). Given that node B doesn't know anything about the subscription, notification is not sent.

  • Update arrives at node B, after next subscription refresh (i.e. as much as -subCacheIval seconds). Node B is aware of the new subscription as a consecuence of the refresh, so the notification is sent.

  • Update arrives at node A, no matter wether before or after next subscription refresh. Node A was the one creating the subscription, so its cache is up to date since the very begining. Thus, the notification is sent.

Colorary: waiting -subCacheIval after subscription creation will ensure that subscription has been propagated to all CB nodes, thus notification will be always sent. However, note that setting a too small -subCacheIval value could have negative effects. The trade-off is analyzed in the Orion performance documentation section.

Finally, regarding throttling, pay attention to the following remark in the Orion implementation notes:

In addition, Orion implements throttling in a local way. In multi-CB configurations, take into account that the last-notification measure is local to each Orion node. Although each node periodically synchronizes with the DB in order to get potentially newer values (more on this here) it may happen that a particular node has an old value, so throttling is not 100% accurate.

Thus, if you need precise throttling, it is better to implement it at notifier reception endpoint than using the one provided by Orion.

Not using subscription cache (i.e. -noCache is set)

In this case, subscription evaluation is always done querying the DB. Thus, no matter which node (either A or B) created the subscription, as it is stored in DB. Thus, no matter if A or B processes the update, as it will check in the DB for matching subscriptions and notification is always sent in that case.

However, note that this mode (not using subscription cache) could have severe performance drawbacks (especially in the case of using pattern-based subscriptions) so it is not recommended.

I'm not fully sure, but the throttling issue decribed for the other scenario probably doesn't happen in this case.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...