Publishing takes longer time even though xmpp.pubsub.multiple-subscriptions is disabled

Recently we encountered issue where openfire was taking long time to publish event on a node which has got more than 20K subscriptions. Even though we had disabled xmpp.pubsub.multiple-subscriptions’ property.

After analysis I observed that, while publishing event notification to subscribers openfire, for each affiliate Node.getSubscriptions(JID owner) iterate over all subscriptions for a node. This result into 20,000*20,000 iteration while doing single publish.

Rather than directly iterating over all subscriptions for a node, Node.getSubscriptions(JID owner) API should decide which map(subscriptionsByID or subscriptionsByJID) to be used based on isMultipleSubscriptionsEnabled().

Implementation of Node.getSubscriptions(JID owner) should look like:

public Collection getSubscriptions(JID owner) {
Collection subscriptions = new ArrayList();
if(isMultipleSubscriptionsEnabled()){
for (NodeSubscription subscription : subscriptionsByID.values()) {
if (owner.equals(subscription.getOwner())) {
subscriptions.add(subscription);
}
}
}else{
NodeSubscription subscription = getSubscription(owner);
subscriptions.add(subscription);
}
return subscriptions;
}

Bug is logged as OF-416.

In the future, tag your bugs with bug_report

Thanks. From heap optimization prospective we should not load Node.subscriptionsByID when multiple subscriptions are disabled.

We have 34million subscriptions within openfire database. Key of this map will take - 40(key length)*2(size of each character)*34,000,000 bytes i.e. 2.7gb.

In order to get hold of subscriptions for a node, we can use Node.subscriptionsByJID.values().

Thanks,

  • Ujval