Learning how to deploy and scale a meteor app

How To Deploy And Scale Your Meteor Apps

By on August 2, 2016

This is one of two topics of our 2nd Meteor Meetup on July 9th, 2016. The author is Tai Nguyen, a young talent member of Designveloper.

I believe that you already had a good preparation after digesting our previous blog What To Consider Before Deploying A Meteor App, right? Now, it’s time to get your hands dirty. Ready? I’m going to show you how to bring your app into practice.

Step 1: Create Servers

To begin with, I create 4 servers in AWS (Amazon Web Service) with 4 different IP addresses:

I have chosen the domain which is www.ami.com for the app. I use MongoDB because it is the default database of Meteor. There we’ve got:

    • MONGODB:,,,
    • METEOR APP: (sever-1.ami.com), (server-2.ami.com), (server-3.ami.com), (server-4.ami.com)
  • Step 2: Install MonggoDB Replication

    Replication sets provide redundancy and increase data availability on different database servers. Hence, I apply replication to increase the performance of reading operations.

    Learning how to deploy and scale a meteor app

    MongoDB Replication

    At first, I create an admin user following precise instructions on https://docs.mongodb.com/v2.6/tutorial/add-user-administrator/ and generate a key-file by doing exactly guides on https://docs.mongodb.com/v2.6/tutorial/generate-key-file/

    Next, I apply SSH (Secure Shell) to all of 4 servers and run these following commands

    >cd ~/
    > mkdir mongodb/
    > screen -S mongodb
    > mongod --dbpath mongodb/ --replSet Ami --auth --keyFile mongo-keyfile

    To close terminal session, I use the hotkeys “CTRL + a + d”.

    Then I turn into primary MongoDB by running these following commands:

    > mongo
    > use admin
    > db.auth(‘admin’, ‘password’)
    > rs.initiate()
    > rs.add(‘’)
    > rs.add(‘’)
    > rs.add(‘’)

    Step 3: Setup your application

    In order to set up the app, the first thing I need to do is to install meteor up by using npm. Below is the command line to use:

    > npm install -g mup

    Setting up is a must. To do this, use the cd path command to go to the folder which contains settings file of the application:

    > cd path/to/settings
    > mup init

    This is how I scale the app. In this file, I edit mup.json file by:

  • Adding servers
  • {
          "host": "server-1.ami.com",
          "username": "ubuntu",
          "pem": "./ssh.pem",
          "env": {
            "CLUSTER_ENDPOINT_URL": "https://server-1.ami.com",
            "CLUSTER_BALANCER_URL": "https://server-1.ami.com"
          "host": "server-2.ami.com",
          "username": "ubuntu",
          "pem": "./ssh.pem",
          "env": {
            "CLUSTER_ENDPOINT_URL": "https://server-2.ami.com",
            "CLUSTER_BALANCER_URL": "https://server-2.ami.com"
          "host": "server-3.ami.com",
          "username": "ubuntu",
          "pem": "./ssh.pem",
          "env": {
    "CLUSTER_ENDPOINT_URL": "https://server-3.ami.com",
            "CLUSTER_BALANCER_URL": "https://server-3.ami.com"
          "host": "server-4.ami.com",
          "username": "ubuntu",
          "pem": "./ssh.pem",
          "env": {
            "CLUSTER_ENDPOINT_URL": "https://server-4.ami.com",
            "CLUSTER_BALANCER_URL": "https://server-4.ami.com"
  • Adding MONGO_URL
  • MONGO_URL is one of environment variables in Meteor, which is used for connecting to Mongo in production environment. To add MONGO_URL, I run the following command:

    “MONGO_URL"        : "mongodb://lumin:XXXXXX@,,,"
  • Enable OPLOG
  • Oplog or operation log is a special collection that records all the write operations as they are applied to the database (you can find more helpful information at: https://github.com/meteor/docs/blob/version-NEXT/long-form/oplog-observe-driver.md)

    The command used to enable Oplog is as followed:

    { MONGO_OPLOG_URL: ‘mongodb://lumin:XXXXXX@,,, local?authSource=admin

    Step 4: Deploy

    Are you done all of these above steps? Let’s move to deploy our app. Firstly, I go to settings folder of the app.

  • Setup servers when using MUP for the first time
  • > mup setup
  • Bundle your project and deploy to servers
  • > mup deploy

    So far, I have deployed my app successful. MUP also support other useful commands to maintain your production app. After you’ve edited environmental variables of settings.json, you can reconfigure the app without deploying again:

    > mup reconfig 

    Check out other useful commands:

    > mup stop # stop all servers
    > mup start  # start all servers
    > mup restart  #  stop all running servers and start it again

    Congratulation! Your Meteor app is now ready to dance to your tune. Keep an eye out for our further blog on Meteor tutorials and you will find out more helpful information. I would love to know whether you deploy your app successfully or not in the comments below.

    About Author


    Hi, my name is Van. I’m a stubborn introvert, an iced milk tea drinker, a barefoot kitchen dancer, a singer of shower time and an enthusiastic copywriter dying to write about anything around my world.



    • Today Visitor: 48
    • Month Visit: 41,926
    • Total Posts: 77


    Facebook By Weblizar Powered By Weblizar