is slower compared to REST API

Hi Everyone,

I am working on a project in which I have to fetch data from multiple collections. The strange thing I experienced is fetching data takes lots of time compared to fetching data from REST API using axios or any other.

Does the same behaviour experienced by any other or there is some coding issue. It would be great if someone could clear my thoughts on this if I am wrong in this.

Meteor Methods run in a context which by default has this.userId, the Meteor object, various middleware, security, database, the pub/sub engine, and other functionality available. It requires some overhead for those things.

Unlike a REST API which is sort of amnesic and you have to build everything up from first-principles or the smallest lego blocks each time; Meteor Methods know they’re part of a Meteor app and that there’s a client, and they’re suppose to handle certain types of information in certain ways. If you added all of that extra logic to a REST endpoint, it would eventually slow down.

1 Like

So, could you tell me what are the possible reasons for Meteor.Methods being slow?

I just did. Maybe you’ve added a package that borks the Meteor.users collection lookup; maybe your pub/subs are crunching through a mountain of data; maybe you’re polling the server elsewhere and the Meteor object is timesharing between tasks; could be any number of things.

But it’s slower than REST by default. That’s normal.

(Meteor isn’t designed as a share-nothing stateless client, with massive parallelism. So it’s simply not going to scale up in quite the same way as other stacks in that regard. It’s designed as a stateful, reactive webapp.)