Postponing DDP the connection

I maintain a high-traffic meteor app in which 99% of the clients interact with the app in read-only mode. For performance and cost-saving reasons, the clients pull initial data data from CDN. If/when the user logins, changing data becomes possible via newly-created subscriptions.

My understanding (correct me if wrong) is that in Meteor, a DDP connection is established immediately after the initial load. In my app this connection is not actually required until the user logs in. Problem is, the idle websockets are just wasting load-balancer resources and ec2 instance resources, which forces unnecessary horizontal scaling. Also generally, its a no brainer that having the bulk clients hold an idle websocket is just inefficient architecture and bad practice.

Thus my question is:
How do I prevent the Meteor client from opening a websocket right after starting?
There’s which closes the DDP, but I can’t seem to find anything in the docs which disables DDP to begin with. Such settings will solve my problem, but other advice is also welcome.

You can’t (currently) disable DDP, so I’m just throwing out some ideas - maybe you could override the default DDP connection URL to point to a dummy URL before the app starts, using the DDP_DEFAULT_CONNECTION_URL environment variable. You could then have your app make a proper DDP connection (with a proper URL) when it needs to.


That an interesting idea. It’s a bit of a hack though and I was hoping to find out an official setting.

I’m not too fond of the idea that when using an invalid value for DDP_DEFAULT_CONNECTION_URL the client will retry and fail the connection (multiple times) (each retry results in a ddp-client.js:910 GET http://null/sockjs/info?cb=... net::ERR_NAME_NOT_RESOLVED" console error)

I guess I can combine approaches: set it to an invalid value and call meteor_disconnect. That should work until there’s an official option to disable it. FYI I’ve opened an issue