Deploying Meteor Apps on Modulus
A little while ago we released Demeteorizer, which is a tool that converts a Meteor app into something that more closely resembles a regular Node.js application. Since then Demeteorizer has been used to successfully deploy many Meteor application to the Modulus platform.
Update - February 6th, 2013
Modulus now integrates Meteor deployment directly into the Modulus command line tool. Demeteorizer is no longer a required step. Please read our official Meteor deployment guide for instructions.
Even though Demeteorizer makes deploying a Meteor application much simpler, there are still several steps that must be taken in order to make things go smoothly. This article provides a step-by-step guide on how to deploy a Meteor application to the Modulus Node.js hosting platform.
The Meteor App
There’s nothing special you have to do to the Meteor application itself. For this article I’m going to use Meteor’s leaderboard example.
meteor create --example leaderboard
This gives us an application that looks like this:
Once you’ve got a Meteor application, it needs to be converted so it can be deployed as if it were a regular Node.js application. We’re going to use Demeteorizer for this. Modulus is currently running node version 0.8.15, which means we must specify that as an option to demeteorizer.
> cd ~/leaderboard > demeteorizer -n 0.8.15 By default, Demeteorizer puts the converted app into the “.demeteorized” folder. Use the -o option to override this to put the converted app in a custom location.
When Demeteorizer completes, we’ll have something that looks like this:
Meteor applications require a MONGO_URL environment variable in order to run. Environment variables can be specified using the Modulus command line tool or through the web interface.
> modulus env set MONGO_URL mongodb://user:pass@host:port/dbName ?autoReconnect=true&connectTimeout=60000
Environment variables can be defined in the Administration tab on your project dashboard.
Modulus works with any database provider, however we do offer an integrated Mongo solution that will work very well.
Once your application is converted and you have the proper environment variables setup, deploying it to Modulus is very straightforward. The easiest way to deploy is by using the Modulus command line tool.
> cd ~/leaderboard/.demeteorized > modulus deploy
If you’re more comfortable using the web interface, you can zip the contents of the .demeteorized folder and upload it through the project dashboard.
It’s important to note that Meteor itself is not horizontally scalable. It uses in-memory state information that is not shared across multiple instances of the application. Depending on the type of application you’ve created, this may or may not have a large impact on usability if you attempt to scale beyond a single instance.
Modulus implements session affinity, which means a user will stay connected to the same instance. With session affinity it is possible to scale Meteor to more than one instance, however only users connected to the same instance will get notified of data changes. For example, a user on instance B updates a piece of data, all other users connected to instance B immediately get notified of the change. Users on instance A will not receive any notification. Their data will update when Meteor synchronizes with the Mongo database, which occurs every 10 seconds.
Meteor is a very compelling technology and we want to do everything we can to provide a home for these amazing applications. Demeteorizer is a first step in making the Meteor deployment process as streamlined as possible.
If you’ve got any comments or questions regarding Meteor deployment, please leave a comment here or drop us a line.