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 *.meteor.com, 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:
- 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.
- 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
- Install Meteor
curl https://install.meteor.com | /bin/sh
- Install MongoDB:
sudo apt-get install mongodb
- 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 https://github.com/SachaG/Telescope.git), for example in
- 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
- 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=http://ec2-23-20-113-59.compute-1.amazonaws.com/ node bundle/main.js
- Install meteorite (a package manager for Meteor) if your Meteor app requires it:
npm install -g meteorite
Then you can just replace every
meteorcall with Meteorite’s command line,
mrt bundle, etc.)
- If you want your server to not terminate when you close your connection to your server, you can use
PORT=80 MONGO_URL=mongodb://localhost:27017/sidebar ROOT_URL=http://ec2-23-20-113-59.compute-1.amazonaws.com/ nohup node bundle/main.js &
Of course, you can use less basic “daemonizing tools”, like
- 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!Google+