Heroku
Overview
(Note from Arslan: Originally tried to use meteor-hero, but was unable to launch it following documentation. Error could have been on my part. Looking into other options, Meteor Buildpack Horse seemed to have positive reviews. Deploying to Heroku was breeze with it, and so that is what is documented here.)
Instructions assume meteor, git, and npm are installed on your system.
Install sample Meteor app
To start, clone the sample app meteor-application-template-react to your local computer.
Change directories to the app/ directory, and follow the template's installation instructions to verify everything is running well locally by running meteor npm install
and meteor npm run start
.
Install Heroku
First, sign up for a free account on Heroku at this page.
Next, download the Heroku CLI tool. You might need to restart your shell client after installation for it to take effect.
Create a new Heroku app
To create a Heroku app to host your Meteor app, you musts first log into Heroku through your shell client. Change directories to the app/ directory, then run heroku login
:
Now that you're logged in to Heroku, you can use the heroku create
CLI command to create a new empty application on Heroku, along with an associated Git repository at Heroku:
You can use the git remote command git remote -v
to confirm that a remote named heroku has been set for your app:
Install Meteor Buildpack Horse
Now we follow step two of the Meteor Buildpack Horse docs.
First, install the buildpack registry addon by running heroku plugins:install buildpack-registry
:
Next, run heroku buildpacks:set admithub/meteor-horse
to set the buildpack to the latest version.
Create a MongoDB instance
Before we can actually deploy the Meteor app, we need to set up a MongoDB database instance in which to store the data. Heroku does not provide MongoDB hosting, so we will use the free tier of MongoDB Atlas hosting service.
See Setting up a MongoDB Instance for instructions on how to create the MongoDB instance.
This process should yield a MONGO_URL connection string for use below.
Set the application and database URLs
First, set the url by running heroku config:set ROOT_URL="https://<appname>.herokuapp.com"
, changing <appname>
to whatever your app is called.
Second, set the MONGO_URL by using the connection string Atlas provided us and running: heroku config:set MONGO_URL="mongodb+srv://arslanr:MYPASSWORD@cluster0.rbdff.mongodb.net/MYDATABASENAME?retryWrites=true&w=majority"
. Make sure to modify the string with your atlas password and give your database a name.
Deployment (and redeployment)
Once that's done, you can deploy your app any time by pushing your application to heroku with git push heroku master
The website should be running at https://enigmatic-thicket-32549.herokuapp.com/. There are ways to rename the URL enigmatic-thicket-32549
part to anything you want.
warning
According to ROOT_URL, I think the application should be available at: https://meteor-application-template-react.herokuapp.com/, but it's not. Did you actually set the ROOT_URL correctly in these instructions?
Stress testing Heroku app
Before running a load test, install logging and monitoring add-ons on load testing app. You’ll use these tools to evaluate results:
A logging add-on, to view app and database logs from the test An application performance monitoring (APM) add-on, such as New Relic, Scout, or AppOptics, to identify slow endpoints and services An infrastructure monitoring add-on, such as Librato or AppSignal, to measure load on the app and database
Logging add-on:
lets install LogDNA. Theres no particular reason for this, it was simply the first one Heroku recomended. Go to the add-on page Click Install add-on on the right Verify you have the free version Search for your app Click "Provision add-on"
Infastructure Monitoring add-on:
Lets install Librato Follow same instructions as above
We will be stress testing our meteor-template-react app with New Relic APM. It is advertized to "Monitor, troubleshoot, and tune production web applications. Starting at $0/mo.". Great! If its free then its for me.
First, log into your Heroku account, Click "Install New Relic APM" on the New Relic APM Page linked above. Verify that the "Add-on plan" is free Search for your app Click "Provision add-on" Heroku will ask you for a credit card at this point, even though the service IS free.
Click on the "New Relic APM" Link towards the bottom of the page, and it will take you to their website where you will accep their terms and conditions
Select The service we want "New Relic APM" Select "Node.js" Follow instructions on the page to set up your project
Obtain your license key
Install the New Relic Node.js agent
npm install newrelic
Configure the newrelic.js file
Copy newrelic.js from node_modules/newrelic into the root directory of your application.
Set a value for app_name.
Replace the license_key value with your New Relic license key from Step 1.
Require New Relic
Make this the first line of your app's startup script:
require('newrelic');
Deploy your application
See data in 5 minutes: In a few minutes, your application will send data to New Relic and you'll be able to start monitoring your application's performance. You will also be automatically upgraded to New Relic PRO for a limited time.
You won't see any data in your dashboard until restart has completed.