Deploying and scaling an app with Meteor + Mongo

Meteor is the hot new framework for developing realtime write-once, run on server+client web apps. Since Pogoapp runs anything, we decided it better run meteor too.

Luckily there's already a buildpack for running meteor on Heroku + MongoLab. Since we've got an existing Mongo addon this should be pretty simple. We made a small fork to get the buidpack working outside the Heroku/EC2/MongoLab ecosystem.


Let's setup the Meteor Wordplay demo.

Install meteor (or meteorite as a meteor version/package manager) if you haven't already:

curl | /bin/sh
# or
npm install -g meteorite

Then use the meteor command (or mrt if you installed meteorite) to create the demo app and commit the code into a git repository:

meteor create --example wordplay
cd wordplay
git init && git add -A && git commit -m "initial"


Create a new app on Pogoapp and add a Mongo DB

pogo create wordplay --remote pogoapp --buildpack git://
Creating wordplay... done, stack is alpha |
Git remote pogoapp added

pogo addons:add mongo:dev          
Adding mongo:dev on wordplay... done, (free)
Addon created: p943default

And now we push our code, trigger a build and our first deployment:

git push pogoapp

remote: Pogoapp build hook for 'wordplay' - processing f0e14c5774b3109394e0458d91b1956e43603769 by
remote: Subscribing to build channel: f0e14c5774b3109394e0458d91b1956e43603769
remote: Building... 
remote: Launching build process... done 
remote: Preparing app for compilation... done 
remote: Fetching buildpack... done 
remote: Detecting buildpack... done, Meteor app 


remote: Done building 'wordplay'
remote: Slug: 50 MB
remote: Deploying 1 process... done.

Et voila!

Here's our live demo. And here's the app available to clone/fork.


Update on this: timhaines pinged me on #meteor IRC to point out it's not so simple. This stackoverflow answer looks like the best summary of the situation, but basically scaling meteor to more than one process is currently a tricky affair, so while the instructions below will work get you a second process, your app may not sync state very well between users. Caveat emptor, you're probably better off with just 1 process until something like this is implemented in Meteor.

Every app on Pogoapp runs as one or more processes (similar to a Heroku "dyno"), each in its own isolated Ubuntu 12.04 LXC container, so scaling up is easy. If we wanted to add a second web process, we just:

pogo ps:scale web=2 
Scaling web processes... done, now running 2

Incoming traffic to your app will immediately start being routed to both processes by our front-end nginx servers. (but see update above!)

Meteor doesn't use WebSockets by default, but Pogoapp supports them so we could easily toggle them on for an app with more data being streamed (e.g. blackboard, which is also on Pogoapp).

For peace of mind this app uses our shared SSL so your important game moves are transmitted with strong 256-bit encryption :)