Possible memory leak + Scaling


#1

Hello everyone,

I’m still kind of a noob to Meteor, but I had a few question that I just can’t seem to find the answer anywhere online. Any form of answers to my questions would be a great help.

________Memory Testing:

What is the best way to figure out how much memory the website that I am writing is using. The below tests are local only and not server memory. I might have a leak but am confused about which one to trust, Kadira and Google Task manager scare me. Yet who do I trust, I mean 190MB on mobile memory is a lot.

Kadira: 197 Mb

Google Task manager:
	Memory: 190 MB - 450 Mb
	Javascript Memory: 30 MB (27 MB live)

Firefox Plugin: 26.7 MB 

________Templates:

1- Are templates in the global namespace, meaning that Template.instance() is also in the global namespace.

2- How does memory get allocated to templates, also when onDestroyed runs does this mean that Template.instance() is on it’s way to be garbage collected so memory returns to the user, or does the reference stay held.

________Mongo Db

1- What is more efficient for database iteration

dB.collection.find({}) 
db.collection.findOne({})

both would have specific search terms in them but which iterates quicker.

________Exports/Imports

Are exports global namespace since I import them into any file. Does this mean that the memory allocated to them is always in use, if so then is it better to use template instance for method/reactiveDict/null collection creation:

Template.foo.onCreated(function(){
	this.add = (x, y) => {
		return x + y
	}
})

________Scaling/Users

When I first tested meteor by making a simple chat app, I uploaded the mongoDb with meteor to the same EC2 instance on Amazon.

1- How do I save the DB to a different EC2 instance that way different apps can DDP to the same Mongo DB. I only need to DDP so my admin app can be on different server. If the db gets too big the EC2 instance can just get bigger. Or is that when people multithread. If I do switch db to different address how does that affect security when logging into user with meteor Account methods, I mean will alanning:roles still allow the admin user the same right through a DDP connection.

2- How does docker help, I still don’t understand it, what does it actually do that makes the website serve itself better to the clients, or does it do something on the server. What is it actually sharing that helps.

3- Oplog, I totally understand why this needs to be enabled, but does oplog take extra server space because it needs to know the difference of the collections.

Tnx :slight_smile: