Meteor session size constraint?

I’ve searched here, google, and SOF for the answer to this question:

In Meteor what is session size contstraint?

Is it like Rails; should I keep it small?

Can I make it 1mb?

If I make it 1mb will it want to write to server?

1 Like

A session is just a ReactiveDict with a name in the constructor to preserve it’s contents through a hot code push. After reading through the ReactiveDict source there appears to be no size limitation. With that being said, it is advised to keep the session size small. Sessions are typically used to maintain state for UI elements as per the session package README. If you are looking to write something to the server I would advise against using sessions. If you need the data to be reactive then you should use a different reactive data source IMO.

Collection cursors are reactive and the most obvious choice to write something to the server from the client.

You can also create your own reactive data source by creating a new Tracker.Dependency. Then you are able to use trackername.depend() in your getter and a trackername.changed() in your setter which will keep that data source reactive.

If reactivity is not necessary then you can simply use meteor methods and calls to send data to and from the client.

Just to add to @khamoud’s excellent reply. There’s one very good reason for not using Session on the server - it’s not available there. That means you will either need to “unpack” it for use with a Meteor.call() or unpack it into a shared collection. Each Session.get() you execute to do the unpacking will reactively run associated computations, which could get expensive.

1 Like