• No results found

Self-managed Self-optimized Methods

5.5 Research Summary

5.5.3 Self-managed Self-optimized Methods

A publish-subscribe solution which uses brokers to disseminate notifications often relies on a broker topology on a higher level than that of the physical network. This may lead to non optimal performance of the system as the system does not make use of the inherited locality of brokers that are handling similar types of subscriptions. If the locality of brokers are not considered when creating an overlay topology of brokers, the propagation of a notification may take longer routes which increases the number of TCP hops and the time it takes for the solution to disseminate the notification.

What follows is a description of a self-organising algorithm which tries to dynamically arrange TCP connections between pairs of brokers using only the routing tables of the brokers[1]. This preserves the scalability properties of a regular publish-subscribe solution as the algorithm only relies on local knowledge provided by the brokers. The goal of this algorithm is to improve the performance and scalability of a publish-subscribe solution by reducing the number of TCP hops for a notification dissemination. This study focuses on reducing the number of hops by grouping brokers that manages similar subscriptions and does not address grouping brokers that are physically close to each other on the underlying network.

The algorithm defines a measurement for subscription similarity called associativity. This metric is used to describe the intersection of two broker’s zones of interest. A notification matches a subscription if the point it represents falls inside the geometrical zone identified by the subscription. If follows that the larger the intersection between two broker’s zones of interest, the more notifications that will be received by one broker but not by the other one. The associativity for a zone Z with respect to another zone Z0 is defined as:

ASZ(Z0) = |Z∩Z|Z|0|

Let Biand Bjbe two brokers whose zones of interest are Ziand Zj, then the associativity of Bi is defined as ASi(Bj) = ASZi(Zj). From this, the associativity of a broker Bi with respect to its neighbours, is defined as:

AS(Bi) =P

Bj∈NiASi(Bj)

The associativity of the whole publish-subscribe system can similarly be defined as:

AS :P

Bi∈{B1,...,BN}AS(Bi)N

58 Chapter 5. Publish-Subscribe Pattern

The algorithm is realized the same way in every broker, where the goal, for each broker, is to detect a possible rearrangement of the TCP links to increase its associativity while not decreasing the overall associativity of the system AS. A possible rearrangement is where two brokers, B and B0, may directly connect to each other with a TCP link instead of using a path of brokers between them. If a broker B finds a rearrangement that will increase its associativity with another broker B0 while not decreasing the overall associativity of AS, then the algorithm proceeds by connecting B and B0 and deciding on a link in the path between B and B0 that must be tear down in order to ensure no cycles.

The algorithm assumes that each broker can open a bounded number F of TCP links at the same time. The number of links available at broker B is defined as alB where 0 ≤ alB < F . Each link li,j between two brokers Bi and Bj is associated with a weight w that reflects the associativity between the brokers and is used to measure the associativity that two brokers gain or lose when a link is created or teared down. The weight is a measure of the number of notifications that will pass through that link that are of interest to both brokers. The weight wi,j of a link li,j is defined as:

w(li,j) = wi,j= ASi(Bj) + ASj(Bi)

Using the definition of weights for a link, a hop sequence can be defined as an ordered set of pairs of a broker id and a weight denoted as:

HS(B0, Bl) = {(B0, 0), (B1, w0,1), ..., (Bi, wi−1,i), ..., (Bl, wl−1,l)}

which represents the path between B0 and Bl with the associated weights.

The algorithm consists of four phases: triggering, tear-up link discovery, tear-down link selection and reconfiguration. What follows is a description of these phases.

Triggering

Triggering refers to when a broker B detects a possibility of increasing its associativity. Let Zi be the zone of broker Bi, before the arrival of a new subscription S, and Zi= Zi∪ S be Bi’s new zone of interest. The algorithm is triggered if the following predicate, Activation Predicate or AP, is verified:

AP : Zi ⊃ Zi∧ ∃li,j: ASZi(Zi,j) > ASZi(Zi,j)

For each li,jsatisfying this predicate, a tear-up discovery procedure is invoked along that link, as Bi suspects that behind it could be a broker which can increase its associativity.

5.5. Research Summary 59

Tear-Up Link Discovery

When a tear-up discovery procedure is triggered for a broker Bi, Bi sends a request message along the link li,j with the following information: Zi, the new subscription S, and the hop sequence HS, initialised to (Bi, 0). When a broker Bjreceives a request message, it computes the associativity between itself and Bi, it updates HS by adding (Bj, wl) and computes the following Forwarding Predicate, FP:

FP : ∃lj,h6= l : ASZi(Zli,j) > ASZi(Zj)

The predicate is used to indicate whenever there is a possibility that a higher associativity can be discovered with a broker behind lj,h: if no links exist such that FP is satisfied, then a reply message is sent back to Bi along the path stored in HS. For each lj,h satisfying FP, Bj forwards the request and then waits for the corresponding reply. When Bj receives a reply from each link, it computes the maximum among all the values, including its own, and sends back a reply to Bi using the reply message from the broker with the calculated maximum.

Tear-Down Link Selection

This phase focuses on identifying and selecting a link that has to be teared down during the reconfiguration phase. This phase is started every time a broker Bi receives a reply for a tear-up discovery procedure that itself started. The reply contains the hop path HS and the identifier Bl of the broker behind the link l that the request was sent on. The link to be potentially teared-up Bi and Bl as ltu.

If all = 0 ∧ ali = 0 the link ltu cannot be created and thus no links exist that can be teared down and ltd= N U LL. If this is not true then there exist two cases:

1. ali > 0 ∧ all > 0: in this case both Bi and Bj have available connections and thus they can establish the link ltuwithout removing one of their existing links.

2. all= 0, ali > 0(resp.ali = 0, all > 0): in this case ltd must be one of Bl’s (resp. Bi) links.

Reconfiguration

This phase focuses on tearing down a link that has been selected by the tear-down link selection phase. As the tear-down procedure must avoid creating a partition of the broker network, the procedure introduces a locking mechanisms that ensures that there is only one tear-down happening at a time along the path from Bi to Bl. The locking mechanism works by first sending a lock message along the path to Bl where a broker B between the endpoints execute the following algorithm:

– When receiving a lock message: if B is involved with another concurrent reconfigura-tion phase on the same link it received the lock message from, it replies with a NACK message. Otherwise we have two cases:

60 Chapter 5. Publish-Subscribe Pattern

1. if B = Bl, B sends an ACK message to the next node towards Bi

2. if B 6= Bl, B sends a LOCK message to the next node towards Bl

– When receiving a ACK message: B forwards the ACK message to the next node towards Bi

– When receiving a NACK message: B forwards the NACK message to the next node towards Bi and removes the lock

Once the path is locked Bi sends a close message to Bj which tears the link down. After that Bj sends back an unlock message where then the routing table for all brokers in the path are updated.

Results

A report containing an implementation of this study[1], uses Siena as a base for the publish-subscribe functionality and Java with J-Sim to simulate a real-time network which the pro-totype was run on top of. In total, a network of 100 nodes were simulated with one broker running on top of each network node. Simulation scenarios were sequences of subscrip-tions changes and notification publicasubscrip-tions, over a bi-dimensional space with two numerical attributes. Notifications are generated using an uniform distribution over the space.

One aspect that was tested in this implementation was the routing performance which referred to the number of TCP hops per notification required for the dissemination. This aspect was tested and compared using the messaging system with and without the self-organising algorithm. This test showed a reduction of forwards by 70% which is close to the minimum.

Another aspect that was tested was the overhead of the self-organising algorithm better routing performance comes at the price of additional network traffic introduced by the algorithm itself. The overhead was measured using the average number of messages per operation against the pub/sub ratio R. Such messages include all the messages generated by the system for notification diffusion, subscription routing and self-organisation. For a ratio as low as R = 10:1 the self-organisation cost is not outweighed by its benefits. As the ratio increases, the cost decreases of about 30% with respect to the case when no self-organisation is performed.

Discussion

The material covered in this section shows that a setup of decentralised brokers can incorpo-rate a self-managing algorithm so that the brokers may autonomously organise themselves without the need of any manual intervention. This section serves as a good example of how a decentralised messaging solution can still feature a more manageable system which still provides a high expressiveness and throughput.

The test results show on better routing performance when using the algorithm. This highlights the problem of using brokers that are not aware of the underlying network system.

The addressed self-organising algorithm is a very simple algorithm that only consists of some few, very distinct phases. This bodes well for the continuation of the development and introduction of such an algorithm which can be easily implemented using the steps previously described.