Pausing or debouncing subscription updates at server


#1

Is there a way to temporarily stop the server from pushing data to the clients?

I have server tasks that updates many many documents of which many are subscribed by clients. When the first document is updated, DDP starts pushing data the the clients, and by the time it is done, there’s a gazillion other updates waiting to be handled by the client, leaving it hanging until it is done. An update that takes 300ms on the server may freeze the client for 30s.

If I could only tell the server to back off until my updates where done, the client could have its new data in a second.

I need a DDP.pause() or a DDPRateLimiter on the server…

I know I could fiddle with putting a reactive {reactive: false} on each find client side as suggested here Pause updates to clients?, and then invoking that from the server, but frankly, that sucks.

So, any trick I’m missing?


#2

Hi, there is something which might be invokable on each connected session:

See my own stackoverflow answer on how to iterate and publish / broadcast.

I could imagine, that you you may use something similar to disable for a while.


#3

Client slowdown is usually caused by Blaze, not by the subscription mechanism. A generic fix is to stop Blaze rendering until the subscription is ready (you can display a spinner meanwhile).


#4

@Steve you are right: If I remove the templates from my app and keep the subscriptions, there is no freezing. I guess I was mislead by the fact that even displaying one single document in a template (found by sort and limit, though!) will make it freeze as Blaze will recompute for each change received.

The subscription.ready() does not change state while this is going on, so I’m missing a way to control this automatically.

@tomfreudenberg, my guess is pausing DDP probably won’t matter anyway, as the updates eventually will hit the client one by one.

So, I need a Blaze.pause() instead:

In the meantime I will have to flip a mayRender-bit in a designated “State” collection from the server, and wrap most of my templates an {{#if mayRender}} or the like. This flickering will however look unnecessarily dramatic to the user :-/


#5

That is weird. I have experienced Blaze slowdown, but only for large amounts of data. If you can reproduce this with minimal code, consider filing an issue on GitHub.