Meteor MongoDB Hosting

Introduction

There are several ways to host a mongoDB for your meteor application. In the following text I want to highlight advantages and disadvantages of the different solutions out there.

Glossary

DBaas: database-as-a-service

vps: virtual private server. In this article there is no determination between vps and cloud hosting.

DBaas

There are a few DBaas providers out there. If i missed an important one, please let me know in the comments. In general they have one main advantage over self hosted DBs - a competent support team and the people managing the DB know what they are doing. Additionally, most DBaas offer database analytic tools which allow you to figure out which queries are the slowest and other useful metrics.

Compose.com/io

pros

Compose is the official galaxy suggestion. There's a nice support team. They give a 30day trial. They have a really small instance to start with: 102mb ram, 1gb storage, 2 replicasets, daily backups for 31$/month. For a little meteor application this can already be enough. Scaling is easy via a comfortable backend.

cons

If you need it at a bigger scale it get's really expensive in no time. If you want e.g. 2gb ram you have to pay 375$/month.

MongoDB atlas

pros

MongoDB atlas has obviously the best price/value rate. For around 60$/month you get 2gb ram, 10gb storage, wiredtiger, backups and 3 replicasets. It's deployed on AWS, so you can select between us/eu/ap regions. MongoDB atlas is the official mongoDB product. They promise to ship new updates via patches in the running system. Similar to compose scaling is easy via a comfortable backend.

cons

The 2gb ram, 10gb storage instance is the smallest plan/instance available. So it won't get cheaper than 60$/month even if you don't need that much power.

mLab|mongoLab

pros

mLab is the only provider which offers a completely free tier which can be used for testing (Oplog access is only available for payed plans, so you can't really use this for production). There are some smaller plans for around 15$.

cons

If you want ssl encryption you need the 180$ plan and you have to pay additional fees. The 180$ plan is 1.7gb ram and 40gb storage with 2 replica sets.

scalegrid

pros

Scalegrid offers a standalone server(without replicasets) for 20$/month. An instance with 3 replicasets, 600mb ram, 10gb storage costs around 50$.

cons

For 1.7gb ram and 40gb storage with 3 replicasets(i think this is the best comparison to mongoDB atlas) you have to pay 115$/month - the same with more ram would cost less than 80$ at mongoDB atlas.

Self hosting

DIY. Probably cheaper than DBaas in most cases, but also more complicated. Take care when doing this - you have full reponsibility and no support team you can call. When doing self hosting you have to care for everything yourself - backups, replicasets, sharding and even recovery/rollbacks. There are a lot of pitfalls you probably never heard of before you're trapped into. So make sure to only go that path, if you 1. don't care or 2. are absolutely certain that you know what you do.

mupx

Mupx has an option "setupMongo": true to automatically setup the mongo database. This is fine if you want to get started, but also bears some problems.

pros

The setup is really easy, just set a flag in your mup.json.
The database is on the same server as your application.

cons

The mongoDB is inside the docker container and has no replicasets.
There are no automated backups, so a server crash could result in loosing user data.
Scaling isn't really easy at the moment, but there's currently a refactor going on - so let's see how it evolves.

Real Self Hosting

As an alternative to mupx you could host your mongoDB on any vps you want. On digitalocean you could get a 500mb ram instance for 5$ a month. Keep in mind, that the vps hardware and os are not optimized for database only systems. A huge part of the 500mb will be used by the system - on DBaas in comparison 100mb ram database actually means 100mb ram for the database.

pros

You have total control. You can use wiredTiger, replicasets, oplogTailing, automated backups and everything you can imagine.

cons

You have total control. You have to setup everything properly and can't blame someone else for the problems you introduced. If you're not already experienced with setting up mongoDB servers - and I assume you're not, when reading this article - keep in mind that it's not as easy as typing apt-get install mongodb. The complicated part comes after that.

Other solutions

There are some providers which bundle meteor hosting with mongoDB hosting. For small applications (not too many concurrent users), you probably wont have the same comfort than on a DBaas, but for most use cases this will also be enough.

NodeChef offers a 1gb storage, 100mb ram db container for just 9$/month. There are also some others like bluemix which has a free tier or modulus which is a tad expensive, but was the way to go before nodechef and bluemix announced meteor support.

edit 09.07.2016: Ther's another provider mentioned in the comments: Scalingo. Scalingo is a combined provider like NodeChef but with a 512mb free tier. It supports oplog tailing and mongoDB 3.2 with wiredtiger. Currently they are only offering hosting in France and the mongoDB doesn't provide replicasets - both is planned for Q4 2016, I'll try to keep this post updated.

Conclusion

Choosing the right database provider isn't as easy as it seems. It's totally up to you. You should not chose a provider without oplog tailing - everything else is only important if you have really sensible data or massive user spikes. Metrics provided by services like Compose can be really useful. In reality most meteor applications use kadira anyways - so you already have some really good metrics.
For most applications a mixed provider like Scalingo or NodeChef is the perfect price/value fit. If the application grows unexpected fast and returns enough revenue it shouldn't be too hard to switch the provider.

Lukas Strassel

Read more posts by this author.

Subscribe to Meteor University

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!