DDP vs Straight MongoDB access for synching large amounts of data

后端 未结 2 1236
借酒劲吻你
借酒劲吻你 2020-12-21 14:10

We are building an app in Meteor that will be participating in an education ecosystem. There are a number of applications (e.g. a GradeBook, a Student Information System, a

相关标签:
2条回答
  • I think nate's answer goes perfect on what you should do especially considering the volume of data. And if you need to display a whole lot of data if you're using pages to use a paginated subscription so that you can enjoy the realtime functionality (if you decide to use it) without downloading it all at once. Keep in mind though that at the moment the data is sent down like this (for each session, so if the tab is closed and reopened it will be redone):

    1 - Connect to DDP Server/Proxy (Long Polling now due to websocket issues with chrome)
    2 - Establish a 'subscription'
    3 - Fetch all data relevant to subscription (initial download)
    4 - Subscription is complete, now the client will 'listen' for changes
    5 - Any updates (remove/update/insert, etc) are sent down to the client
    

    There really isn't a sync system at this point where old data is kept offline (in a localstorage or indexed db or anything) so that step no 3 can be avoided and only the syncs from that point would occur.

    This is mind, if there is a connectivity interruption (e.g losing connectivitiy for a short peroid of time Meteor will lose connection to the DDP wire and when it reconnects it download everything again as if it were from scratch.

    0 讨论(0)
  • 2020-12-21 14:38

    based on this http://meteor.com/blog/2012/03/21/introducing-ddp

    Distributed Data Protocol. DDP is a standard way to solve the biggest problem facing client-side JavaScript developers: querying a server-side database, sending the results down to the client, and then pushing changes to the client whenever anything changes in the database.

    it seems clear that any new DDP client, receives all data and then deltas as the data changes.

    i would suggest that if your 'client' doesnt need reactivity / realtime updates / 2 way synching, you should pull the data directly from mongo and avoid the overhead of 'syncing'. for a 'reporting system' this should be perfectly acceptable, grab a bunch of data, generate reports. you shouldnt care about changing data in this context, just a snapshot and reports from that snapshot.

    if you do need the more real time features, DDP is likely worth the overhead and initial setup difficulty.

    0 讨论(0)
提交回复
热议问题