Start and stop publishing

Is it possible to temporarily stop publishing and re-start it?

During an import of large amouts of data, I don’t want Meteor to attempt to publish each insert to all clients until the import is complete. Right now, it is causing server to crash when importing > 1000 docs.

My theory is, that stopping publish during import, then re-starting it after, will prevent the CPU tap out. But, that is just a theory.

I’m also looking into bulk insert options also. But that may or may not stop meteor from crashing the modulus.io server.

Thanks,
Don

1 Like

You can call .stop() on the publish function

http://docs.meteor.com/#/full/publish_stop

2 Likes

Hi @dkerr

I followed you here from Bulk.insert() without using loops/collection.insert :smiley:

I have the same dilemma i.e need to Batch insert data without the clients knowing. How did it go for you? Does temporarily stopping the publication work? How about re-subscribing then?

What do you mean by without the clients knowing ?

Database part, oplog, propogation to clients will be still same, even if you delay the propogation, it will be still same load.

Only thing I can think of would be signaling the clients itself to keep cursors non-reactive till import finished.
So data will still be distributed, but clients will pause re-rendering.
And that can be done by using reactive: false in cursors on clients.
Same with observes - queue the recomputing till import finishes.

And that publish .onStop() has nothing to do with stopping the publication itself, it means stop subscription and clearing after that.

What do you mean by without the clients knowing ?

I mean without the clients recieving the update (10k+ new docs) and likely crashing. So is there a way to temporarily disable pub/sub until the import is done? Is there a way to disable pub on the server? How does the server tell clients to…

keep cursors non-reactive

Is reactive:false fixed?