Reduce Bandwidth and CPU Waste
Iron Router normally unsubscribes all previous subscriptions when entering into a new route.
Actually, this is not an Iron Router issue. It’s a feature of Meteor’s Deps package. Read this article to learn more about this.
Although this is a nice feature it causes two main issues.
- User has to wait between routes, even for a recently visited route.
- There is an increase in subscription rate, which introduces cpu and network issues.
With meteor APM you can identify the subscriptions that have this issue and apply a fix.
First visit the PubSub detailed view. Then sort publications by “Shortest Lifespan”. Next, Select publications with the short lifespan and high throughput.
Publications identified by the above selection criteria have the shortest lifespan and high subscription rates, which means they change very rapidly. The following fixes can be applied to resolve the issue.
Fixing this issue is not that hard. Simply using Subscriptions Manager, you could be able to avoid this issue. This is how you can fix the issue with Subscriptions Manager. Instead of using
Meteor.subscribe, create a Subscriptions Manager and subscribe with that.
var subs = new SubsManager();
See Subscriptions Manager docs for more info.
If you have a lot of users, simply fixing this issue will help you greatly reduce CPU cycles and Bandwidth.