When creating a Meteor app., Mongo is installed by default and runs automatically when I run my app. In the past, with other non-Meteor apps, I have always tried to place my app code files and database on separate servers to ensure that I can scale them independently. It feels as though this default Mongo install is a convenient way simply for Meteor to use a database out-of-the box, just to get you going. Thinking ahead, I want my app to scale, so should I start thinking about using a Mongo instance on separate server and, if so, what process do I go through to detach this default Mongo instance from my Meteor app?
Asked
Active
Viewed 99 times
1 Answers
1
The instance of mongodb that comes with meteor is only for use when developing your app. In a production environment, you should either install your own mongo instance or use a service.
I strongly recommend using compose.io in production. We've had a really good experience with them and the most basic deployment comes with access to the oplog which is critical for scaling your app.
Either way, in production you will provide two URLs to your app via environment variables:
- MONGO_URL
- MONGO_OPLOG_URL (this is optional but strongly recommended)
If you go with compose, here is the guide for integrating with meteor.

David Weldon
- 63,632
- 11
- 148
- 146
-
If setting the environment variable, I take it this will mean that any other apps running on the app server will only be able to connect to the same Mongo instance defined by this variable? Can I use, for example: var database = new MongoInternals.RemoteCollectionDriver("mongodb://127.0.0.1:3001/my-database"); in my Meteor application to switch between Mongo servers? – JoeTidee Mar 31 '15 at 22:23
-
That would be true if you were setting the env vars globally (.bashrc, .profile, etc). The recommended way is to export the variables in a script which then starts the app so they don't leak into the outer environment. See [this question](http://stackoverflow.com/questions/21447818/keep-meteor-running-on-amazon-ec2) for more details. No, please don't set the connection values in the code. – David Weldon Mar 31 '15 at 22:27
-
... but what if I wanted to switch between two Mongo instances in my app? – JoeTidee Apr 01 '15 at 20:54
-
While it's running? I'd recommend reading [this](http://joshowens.me/environment-settings-and-security-with-meteor-js/). You really don't want to add things that look like production credentials to your code. – David Weldon Apr 01 '15 at 20:58