Skip Navigation
Show nav
Heroku Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Working with Bundler
      • Rails Support
    • Python
      • Background Jobs in Python
      • Working with Django
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with Spring Boot
      • Java Advanced Topics
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Data For Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
  • Add-ons
  • All Add-ons
  • ObjectRocket for MongoDB
ObjectRocket for MongoDB

This add-on is operated by Rackspace Hosting

High-Performance MongoDB + Fanatical Support™ | objectrocket.com/mongodb-heroku

ObjectRocket for MongoDB

Last updated July 26, 2022

Table of Contents

  • Provisioning the add-on
  • Environment setup
  • Using with mongo Shell
  • Using with Rails 3.x
  • Using with Python/Django
  • Using with Node.js
  • Monitoring and alerts
  • Dashboard
  • FAQ
  • Removing the add-on
  • Support
  • Migration from Heroku mLab MongoDB

ObjectRocket for MongoDB is a fully managed platform for providing MongoDB. The ObjectRocket platform is built for scalability, speed, and safety. Each and every instance comes with 24x7x365 database admin support - free!

Provisioning the add-on

ObjectRocket for MongoDB can be attached to a Heroku application via the CLI:

A list of all plans available can be found here.

$ heroku addons:create ormongo:5-mmap
Creating ormongo-infinite-92036... done, (free)
Adding ormongo-infinite-92036 to serene-brushlands-93817... done
Setting ORMONGO_URL and restarting serene-brushlands-93817... done, v13
Use `heroku addons:docs ormongo` to view documentation.

Once ObjectRocket for MongoDB has been added, ORMONGO_URL and ORMONGO_RS_URL settings will be available in the app configuration and will contain the connection information for your new MongoDB instance. This can be confirmed using the heroku config:get command.

$ heroku config:get ORMONGO_RS_URL
mongodb://iad2-c99-1.mongo.objectrocket.com:12345,iad2-c99-0.mongo.objectrocket.com:12345,iad2-c99-2.mongo.objectrocket.com:12345/?replicaSet=431234544505471ea4867e30d14abc1f

Using the ORMONGO_RS_URL string is the preferred option, as it provides full replica-set information and enables better app resiliency. However, we still provide the ORMONGO_URL for some older applications that don’t accept the replica-set connection string format

Open the dashboard

Now we’ll go to the dashboard to create the app database and the app user for accessing the database. Let’s use the toolbox to open the dashboard.

$ heroku addons:open ormongo
Opening https://addons-sso.heroku.com/apps/serene-brushlands-93817/addons/fdb06610-23a3-4e50-af4f-296ae804ed03...

Your ObjectRocket for MongoDB dashboard opens onto the instance details.

Adding a Database and User

Scroll down to the Databases section and expand it. Now click on ‘Add Database’ and provide the database name you like, a user and the password for that user.

Add Database

After adding the database and user to your ObjectRocket for MongoDB instance you are ready to start writing and saving data. Scroll down for examples using the most common frameworks and drivers.

Environment setup

After provisioning the add-on it’s necessary to locally replicate the config vars so your development environment can operate against the ObjectRocket for MongoDB instance.

Use the Heroku Local command-line tool to configure, run and manage process types specified in your app’s Procfile. Heroku Local reads configuration variables from a .env file. To view all of your app’s config vars, type heroku config. Use the following command for each value that you want to add to your .env file.

$ heroku config:get ORMONGO_RS_URL -s  >> .env

Credentials and other sensitive configuration values should not be committed to source-control. In Git exclude the .env file with: echo .env >> .gitignore.

For more information, see the Heroku Local article.

Using with mongo Shell

The mongo shell provide quick command line access to your MongoDB instance and is generally included with the MongoDB distribution.

To connect via mongo shell (and any of the other clients below), you will need:

  • Your MongoDB connection string from ORMONGO_RS_URL, ORMONGO_URL, or the ObjectRocket dashboard
  • The database you created via the ObjectRocket dashboard above
  • The username and password you created via the ObjectRocket dashboard above
  • any other options you’d like to set, like ssl
$ mongo --username <YOUR_USERNAME> "mongodb://iad2-c99-1.mongo.objectrocket.com:12345,iad2-c99-0.mongo.objectrocket.com:12345,iad2-c99-2.mongo.objectrocket.com:12345/<YOUR_DATABASE>?replicaSet=431234544505471ea4867e30d14abc1f&ssl=true"

You will then be prompted for your password, before connecting to the mongo shell.

Using with Rails 3.x

Ruby on Rails applications will need to add the following entry into their Gemfile specifying the MongoDB client driver.

gem 'mongo', '~> 2.1'

Update application dependencies with bundler.

$ bundle install

Try it out in a simple script.

require 'mongo'

Mongo::Logger.logger.level = Logger::WARN

client_host = ['iad1-mongos0.objectrocket.com:12345']
client_options = {
  database: 'db1',
  user: 'example_username',
  password: 'example_password',
  ssl: true
}

client = Mongo::Client.new(client_host, client_options)

puts('Client Connection: ')
puts(client.cluster.inspect)
puts
puts('Collection Names: ')
puts(client.database.collection_names)

Output from above script should look like this.

Client Connection:
<Mongo::Cluster:0x70194211277920 servers=[<Mongo::Server:0x70194203419280 address=iad-c17-0.objectrocket.com:12345>, <Mongo::Server:0x70194203425760 address=iad-c17-1.objectrocket.com:49022>] topology=Replica Set>

Collection Names:
objectrocket.init
collection_1
collection_2

Using with Python/Django

PyMongo is the recommended Python driver for working with MongoDB.

Installation is simple and uses the following pip command.

$ sudo pip install pymongo

Try it out in a simple script.

import pymongo
from datetime import datetime

settings = {
    'host': 'iad-mongos0.objectrocket.com:12345',
    'database': 'example_db',
    'username': 'example',
    'password': 'example_pass',
    'options': 'w=1&ssl=true'
}

example_doc = { "start": datetime.utcnow(),
    "end": datetime(2015, 8, 22, 16, 22, 38),
    "location": "Texas",
    "official_game": False,
    "winner": "Javi",
    "players": [
        {
    "name": "Javi",
            "decks": [
                "Dinosaurs",
                "Plants"
            ],
            "points": 24,
            "place": 1
        },
        {
            "name": "Seth",
            "decks": [
                "Spies",
                "Zombies"
            ],
            "points": 20,
            "place": 2
        },
        {
            "name": "Dave",
            "decks": [
                "Steampunk",
                "Wizard"
            ],
            "points": 20,
            "place": 2
        },
        {
            "name": "Castro",
            "decks": [
                "Shapeshifters",
                "Ninjas"
            ],
            "points": 18,
            "place": 4
        }
    ]
}

try:
    conn = pymongo.MongoClient("mongodb://{username}:{password}@{host}/{database}?{options}".format(**settings))
except Exception as ex:
    print "Error:", ex
    exit('Failed to connect, terminating.')

db = conn.example_db
collection = db.test_collection

doc_id = collection.insert_one(example_doc).inserted_id

print "Heres the _id of the doc I inserted: %s." % doc_id

Output from above.

$ python pymongo_example.py
Heres the _id of the doc I inserted: 55ce1520f643f056fd1c9887.

Using with Node.js

Installing the Node.js driver is simple, using the usual npm install procedure.

$ npm install mongodb

Try it out in a simple script.

// Require mongodb
var MongoClient = require('mongodb').MongoClient;

// Connect
MongoClient.connect("mongodb://example:example_pass@iad-mongos0.objectrocket.com:12345/example_db?ssl=true", function(err, db) {
  if (err) {
    return console.dir(err);
  }
  var example_doc = {
        "start" : new Date(),
        "end" : new Date(2015, 9, 28, 14, 17, 23, 0),
        "location" : "Texas",
        "official_game" : false,
        "winner" : "Javi",
        "players" : [
        {
    "name": "Javi",
            "decks": [
                "Dinosaurs",
                "Plants"
            ],
            "points": 24,
            "place": 1
        },
        {
            "name": "Seth",
            "decks": [
                "Spies",
                "Zombies"
            ],
            "points": 20,
            "place": 2
        },
        {
            "name": "Dave",
            "decks": [
                "Steampunk",
                "Wizard"
            ],
            "points": 20,
            "place": 2
        },
        {
            "name": "Castro",
            "decks": [
                "Shapeshifters",
                "Ninjas"
            ],
            "points": 18,
            "place": 4
        }
    ]
  };
  var collection = db.collection('example_collection');
  collection.insert(example_doc, {w:1}, function(err, result) {
    if (err) {
      return console.dir(err);
    } else {
      console.log("Inserted a doc!");
      process.exit();
    }
  });

  collection.findOne({"winner":"Javi"},function(err, doc) {
    if (err) {
      return console.dir(err);
    } else {
      console.log(prettyjson.render(doc));
      process.exit();
    }
  });
});

Output from the script above should like similar to this.

$ node inserting_doc.js
Inserted a doc!

start:         Thu Sep 03 2015 12:22:26 GMT-0500 (CDT)
end:           Wed Oct 28 2015 14:17:23 GMT-0500 (CDT)
location:      Texas
official_game: false
winner:        Javi
players:
  -
  name:   Javi
  decks:
    - Dinosaurs
    - Plants
  points: 24
  place:  1
-
  name:   Seth
  decks:
    - Spies
    - Zombies
  points: 20
  place:  2
-
  name:   Dave
  decks:
    - Steampunk
    - Wizard
  points: 20
  place:  2
-
  name:   Castro
  decks:
    - Shapeshifters
    - Ninjas
  points: 18
  place:  4
_id:
_bsontype: ObjectID
id:        Uàé7ÿ¥8�L±

Monitoring and alerts

NewRelic integrations

ObjectRocket for MongoDB can send statistics about this instance to your NewRelic dashboard. It requires you to enter a valid NewRelic license key within the ObjectRocket dashboard, under the Instance Settings.

Instance storage usage

An alert can be sent to your email anytime your instances’s storage usage exceeds the percentage defined in the Instance Settings. Any number between 1 and 100 is valid. An empty or 0 value disables the notifications.

By default we set the threshold to 90 for all new Heroku instances.

Dashboard

The ObjectRocket for MongoDB dashboard allows you to easily view your instance health, disk usage, schedule weekly stepdown and disk compaction windows, and set a disk space alert.

The dashboard can be accessed via the CLI.

$ heroku addons:open ormongo
Opening https://addons-sso.heroku.com/apps/serene-brushlands-93817/addons/c70c7791-0a45-4f71-8c02-11c69ff21178...

or by visiting the Heroku Dashboard and selecting the application in question. Select ObjectRocket for MongoDB from the Add-ons menu.

FAQ

Why can’t I connect to my MongoDB instance?

You will not be able to access your MongoDB instance until you have created a database and added a user to access it with.

Each instance comes pre-configured with a wildcard ACL. Removing this will prevent you from connecting.

How do I enable SSL/TLS on my MongoDB instance?

All ObjectRocket MongoDB instances support SSL connections.

To use SSL, add ssl=true to the connection string or use the appropriate setting in your MongoDB client driver.

Example for ORMONGO_URL

mongodb://iad2-c99-0.mongo.objectrocket.com:12345/<DATABASE_NAME>?ssl=true

Example for ORMONGO_RS_URL

mongodb://iad2-c99-1.mongo.objectrocket.com:12345,iad2-c99-0.mongo.objectrocket.com:12345,iad2-c99-2.mongo.objectrocket.com:12345/<DATABASE_NAME>?replicaSet=434463744505471ea4867e30d14c481f&ssl=true

Can I customize the ACLs on my MongoDB instance?

As noted above, by default we create a wildcard ACL, but you are free to customize this range if you’re using a private space or using an add-on that provides static IP addresses. You can specify additional IPs/CIDRs or remove existing ranges in the the ObjectRocket Dashboard. Please see the warning above if you’re not sure which ranges you’ll be connecting from.

This Heroku Help Article provides more information on determining which IPs to whitelist.

Can I use The ObjectRocket for MongoDB with Heroku Private Spaces?

Currently, the ObjectRocket for MongoDB add-on is not available in Heroku Private Spaces, but you can connect from an application in a Private Space to an ObjectRocket for MongoDB instance running in a common runtime region.

The Heroku Dev Center provides excellent documentation on how “datastore” Add-ons operate in Private Spaces.

Where is my instance hosted?

Our US plan is hosted in a Rackspace data center located in Northern Virginia next to AWS US-East and utilizes AWS DirectConnect to ensure minimal latency while still taking advantage of our optimized hardware.

What version of MongoDB will my instance be?

ObjectRocket for MongoDB instance are currently running version 3.6.12 by default for MMAPv1 plans and 4.0.10 for WiredTiger if a version is not specified in the create call.

How do I add users to my instance?

You can add users by going to the ObjectRocket dashboard, navigating to the database and adding the wanted user.

How often are backups and how long is the retention period?

Each instance is protected by replication. Should any component fail, the replica set architecture of MongoDB provides the primary level of high availability, fault tolerance, and uptime. However as a last resort and for overall data protection backups are taken daily and the default backup retention is two weeks.

What is a stepdown and compaction and why is it important?

A compaction is simply a way to keep MongoDB’s space usage in check by rebuilding the data files to ensure it’s only using as much space as it needs. We explain in more detail in our What is a Compaction? guide.

Stepdown and compaction can be automated via the instance options in the dashboard.

How do I upgrade my plan?

You may upgrade your ObjectRocket plan using the Heroku CLI or Dashboard.

The ObjectRocket dashboard may take a few hours to display the new size. Please contact support via Heroku Support channels if you encounter any issues.

Removing the add-on

ObjectRocket for MongoDB can be removed via the CLI.

This will destroy all associated data and cannot be undone!

$ heroku addons:destroy ormongo --confirm [your-app-name]
Destroying ormongo-infinite-92036 on serene-brushlands-93817... done, (free)
Removing vars for ORMONGO from serene-brushlands-93817 and restarting... done, v14

ObjectRocket for MongoDB will retain your instance data for up to 24 hours in the event an instance was accidentally deleted. Submit an issue via the Heroku Support channels if you need assistance in restoring a instance that was deleted in error.

Support

All ObjectRocket for MongoDB support and runtime issues should be submitted via one of the Heroku Support channels. Any non-support related issues or product feedback is welcome at sales@objectrocket.com. ) is a fully managed platform for providing MongoDB. The ObjectRocket platform is built for scalability, speed, and safety. Each and every instance comes with 24x7x365 database admin support - free!

Migration from Heroku mLab MongoDB

We have built an automated MongoDB Migration Tool that is fully self-serve and requires no downtime to assist Heroku mLab MongoDB customers with migrating their MongoDB instance(s) over to ObjectRocket. Please make sure that you read the full documentation before leveraging this tool.

Keep reading

  • All Add-ons

Feedback

Log in to submit feedback.

Ziggeo okta

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Podcasts
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

Your email address:

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies
  • Cookie Preferences