How to deploy Meteor on Amazon EC2

Update – April 19, 2012: I’ve reworked this post into a new, improved remote deploy script for Meteor, named Meteoric. You can read about it and install it from Github and soon in the Meteor Book.

Meteor is an ambitious open source real-time Web framework, based on Node.js and MongoDB.

Meteor hit version 0.5 a week ago and some people are starting to use it for production apps. Telescope and Sidebar are examples of such apps that were recently launched (both were created by Sacha Greif). However, the hosting options for production-ready Meteor apps are still limited, with most people opting to host their apps on Meteor’s own hosting platform *, or on Heroku.

Performance-wise, as Meteor apps generate lots of real-time data exchange between server and clients, we’re still in a bit of a grey area. I thought it would be interesting to deploy a Meteor app on EC2 and test the app’s performance. So here’s how you can deploy a Meteor app on EC2:

  1. Launch a 64-bits EC2 instance.
    I launched a Medium instance running Ubuntu Server 12.04.1, the latest Long-Term Support release of Ubuntu Server. Then connect to your instance in the usual way.
  2. Install Node and npm:

    sudo apt-get install python-software-properties 
    sudo add-apt-repository ppa:chris-lea/node.js 
    sudo apt-get update 
    sudo apt-get install nodejs npm
  3. Install Meteor
    curl | /bin/sh
  4. Install MongoDB:
    sudo apt-get install mongodb
  5. Checkout your Git repo. At that point, you can install git (apt-get install git) and clone your Meteor app’s repository (for example for a Github repo: git clone, for example in /home/meteor.
  6. Bundle your app. This is where it gets a bit trickier. You have to bundle your Meteor app, i.e. according to the canonical documentation : “generate a fully-contained Node.js application in the form of a tarball”. As you’re running the Node app on this very server, you don’t have to upload the tarball anywhere however – you just have to untar it there (it would actually be handy to be able to “bundle as a directory, not a tarball”).
    cd mymeteorapp 
    meteor bundle bundle.tgz 
    tar -zxvf bundle.tgz 
  7. Run the app. At this point you have your bundled Node.js app in the bundle/ directory, and you’ll run it as any Node server. In particular, if you want your app to be accessible via HTTP you need to specify port 80. You also need to specify your MongoDB installation’s location, and you may have to specify your app’s ROOT_URL as well.
    PORT=80 MONGO_URL=mongodb://localhost:27017/sidebar ROOT_URL= node bundle/main.js


  1. Install meteorite (a package manager for Meteor) if your Meteor app requires it:
    npm install -g meteorite  

    Then you can just replace every meteor call with Meteorite’s command line, mrt (mrt bundle, etc.)

  2. If you want your server to not terminate when you close your connection to your server, you can use nohup:
    PORT=80 MONGO_URL=mongodb://localhost:27017/sidebar ROOT_URL= nohup node bundle/main.js &

    Of course, you can use less basic “daemonizing tools”, like Forever (Node) or monit.

  3. If you want to import a dump of your MongoDB data (say from Heroku): your dump is most probably in BSON form, so you should do:
    mongorestore --db yourmeteorapp dump/

EC2 Meteor Community AMI

Here’s an Ubuntu-based Meteor AMI if you need one: Meteor Community AMI.

If you liked this article, feel free to comment on Hacker News!