Hi folks - I thought I would do some market research for MDG Currently, Meteor allows us to write reactive database queries by tailing MongoDB’s operation log. However, MongoDB recently announced a feature called Change Streams which paves the way for a more scalable but limited solution.
LiveQuery (Current Solution - aka oplog tailing)
Meteor observes the operations log of the entire MongoDB database and looks for changes. When changes happen in the database, Meteor notifies clients of them.
Pros: database queries can be reactive
Cons: expensive, limited scale
LiveDocument (Proposed Solution)
MongoDB can notify the Meteor server of changes using Change Streams. This is more efficient than sifting through logs but has limitations. MongoDB Change Streams can only provide updates on specific documents. It cannot let the application know that the documents in a query have changed.
However, maybe we can use it with publications that use
findOne, and in general, recommend people to fetch
find queries via Methods instead.
Cons: not suitable for database queries
Pros: better perform and greater scale
Meteor should implement reactivity for individual documents subscriptions and not queries.
Based on experience and what I’ve read on the forums, I can say:
- Methods are much faster and more efficient at fetching large queries
- Pub/sub is much faster and more efficient when subscribing to one document
Thus, maybe developers who are focused on scale can disable LiveQuery, use pub/sub for single document queries powered by “LiveDocument”, and use Methods/Apollo/etc for larger data sets.
What do you think?
- I am fine using Pub/Sub as it is for reactive queries
- I am for using Change Streams + Pub/Sub for one document queries and using Methods/Apollo/etc for the rest
- I will use a different real-time database (like Redis or RethinkDB) and/or data layer (like Apollo) in the future