Deploying Meteor Apps on AWS Opsworks

After learning to develop with Meteor, I ran into the issue of finding the right platform to host my applications.  The Meteor team has free hosting for applications, but the free tier is not good enough to host a production-ready application.  Current implementations for running Meteor on a regular server are not automated and require the developer to SSH into the server to configure and start the application.  One service, Meteor-Up, allows for almost seamless server configuration and deployment without needing to SSH; however, it is not fully automated and requires deployments come from a designated developer machine.

Following the model I used for the Ruby on Rails AWS guide I wrote, I developed a similar mechanism for utilizing Opsworks for deploying Meteor apps.  I did not write a robust guide like I did for Ruby on Rails, mainly because 90% of that guide still applies to deploying Meteor apps.  Some key differences for deploying Meteor apps is that the developer must compile the Meteor app into a Nodejs app using the "meteor build" command.  This must occur locally and specify the server architecture being used.  Then they must upload the tarball output to S3 for Opsworks to deploy.  Additionally, the Nodejs startup and stop scripts for Opsworks do not work for Meteor apps, because the environment variables in the Meteor app must be included in the start command.  I have written directions and custom cookbooks free for anyone to use on Github.

I also used a combination of these two guides for configuring Meteor apps to scale horizontally with AWS Elastic Load Balancer.  In short, I clicked Enable Load Balancer Generated Cookie Stickiness with an Expiration Period of 0 seconds created by leaving the field blank.  HTTP requests on Port 80 forward to HTTP on Port 80.  HTTPS requests on Port 443 orward to HTTP on Port 80. 

These 2 links provide additional context.

  1. https://meteorhacks.com/load-balancing-your-meteor-app/ 
  2. http://www.ripariandata.com/blog/creating-an-aws-elastic-load-balancer

This guide was written before the Meteor Development Group launched Galaxy.  Galaxy uses containers on AWS to deploy applications.  It is very simple to use and has a lot less overhead to deal with.