The Best Way to Host MongoDB on DigitalOcean
Tags: mongodb, digitalocean, database, nosql
Published: 2019-12-16 20:12:36

---
title: The Best Way to Host MongoDB on DigitalOcean
published: true
description: The best way to host MongoDB on DigitalOcean, including advantages, Droplets, SSD disk types, replica sets vs. shards, and managed service providers. ScaleGrid Blog
tags: MongoDB, DigitalOcean, Database, NoSQL,
canonical_url: https://scalegrid.io/blog/the-best-way-to-host-mongodb-on-digitalocean/
---
<link rel="canonical" href="https://scalegrid.io/blog/the-best-way-to-host-mongodb-on-digitalocean/" />

<a style="color: #2da964;" href="https://scalegrid.io/blog/the-best-way-to-host-mongodb-on-digitalocean/"><img src="https://scalegrid.io/blog/wp-content/uploads/2019/12/The-Best-Way-To-Host-MongoDB-on-DigitalOcean-ScaleGrid-Blog.jpg" width="100%" height="auto"></a>
<p style="text-align: justify;"><a style="color: #2da964;" href="https://scalegrid.io/blog/2019-open-source-database-report-top-databases-public-cloud-vs-on-premise-polyglot-persistence/">MongoDB is the #3 open source database</a> and the #1 NoSQL database in the world. It’s a cross-platform document-oriented database that uses JSON-like documents with schema, and is leveraged broadly across startup apps up to enterprise-level businesses developing modern apps. While you may assume a great majority of the cloud database deployments are run on AWS, Azure, or Google Cloud Platform, small to medium-sized businesses in particular are gravitating towards the developer-friendly cloud provider, <a style="color: #2da964;" href="https://www.digitalocean.com/" rel="nofollow">DigitalOcean</a>, for their <a style="color: #2da964;" href="https://scalegrid.io/mongodb.html">hosting for MongoDB®</a> needs. In this post, we’ll walk you through the <a style="color: #2da964;" href="https://scalegrid.io/blog/the-best-way-to-host-mongodb-on-digitalocean/">best way to host MongoDB on DigitalOcean</a>, including the best instance types to use, disk types, replication strategy, and managed service providers.</p>

<h2 style="padding-top: 15px;">DigitalOcean Advantages for MongoDB</h2>
<p style="text-align: justify;">So, what makes DigitalOcean a compelling alternative to other popular MongoDB hosting providers like <a style="color: #2da964;" href="https://scalegrid.io/mongodb/aws.html">AWS</a> and <a style="color: #2da964;" href="https://scalegrid.io/mongodb/azure.html">Azure</a>? As mentioned above, DigitalOcean is highly developer-friendly with its simple and easy-to-understand platform - you do not need to become certified through this cloud provider to be able to get your deployment up and running with confidence. They offer SSD-based cloud hosting with straightforward pricing as well starting at just <a style="color: #2da964;" href="https://www.digitalocean.com/pricing/" rel="nofollow">$5/month</a>, which makes it ideal (and affordable) for developers to build, test and deploy their new applications seamlessly in the cloud. What’s most impressive is that you’re not compromising performance for cost. We ran performance tests for <a style="color: #2da964;" href="https://scalegrid.io/blog/comparing-mongodb-performance-on-public-clouds-aws-azure-digital-ocean/">MongoDB on DigitalOcean vs. AWS vs. Azure</a> and found that DigitalOcean performance was in line with, if not better, on both high throughput and low latency in the deployment.</p>

<h2 style="padding-top: 15px;">DigitalOcean Droplets</h2>
<p style="text-align: justify;">DigitalOcean specialized in SSD-based virtual machines called <a style="color: #2da964;" href="https://www.digitalocean.com/products/droplets/" rel="nofollow">Droplets</a> that are broken down into four simple categories. The most basic Droplet is their Standard instance which uses shared CPU starting at just $5/month. While adequate for low-traffic applications, small databases, and dev/test environments, we recommend against leveraging shared clusters for your MongoDB production deployments. They also offer a dedicated CPU-Optimized Droplet which is sufficient for CPU-intensive workloads, but offer low memory which is not ideal for MongoDB hosting.</p>
<p style="text-align: justify;">If you are deploying a medium-sized MongoDB workload, we would recommend their most popular General Purpose Droplet which is a dedicated instance that offers 4GB of memory for each vCPU. This is typically more than adequate for production deployments and high-traffic applications, and starts at <a style="color: #2da964;" href="https://www.digitalocean.com/pricing/#Compute" rel="nofollow">$60/month</a> for 8GB of memory, 2 vCPUs, 4TB of transfer and 25GB of SSD disk space. DigitalOcean also recently launched their Memory-Optimized Droplets which are dedicated instances that are designed for RAM-intensive applications and high-performing databases, making it an attractive solution for heavy-workload MongoDB applications.</p>
<p style="text-align: justify;">You can deploy MongoDB on DigitalOcean in <a style="color: #2da964;" href="https://www.digitalocean.com/docs/platform/availability-matrix/" rel="nofollow">12 datacenter regions</a> across the world, including the United States (New York City and San Francisco), Canada, the Netherlands, Singapore, the United Kingdom, Germany, and India.</p>

<h2 style="padding-top: 15px;">DigitalOcean Disk Types</h2>
<p style="text-align: justify;">One of the reasons MongoDB performs so well on DigitalOcean is because of their SSD disks, which are ideal for cloud database deployments. They provide great throughput that offers significant benefits for running an index on your database or repairing a machine, saving you a significant amount of time over a standard MongoDB deployment on AWS. They even offer amazingly <a style="color: #2da964;" href="https://scalegrid.io/blog/mongodb-on-digital-ocean/">low latency</a> from Amazon AWS US-East to the DigitalOcean New York datacenter, which is great for applications that are running their front on mid-tier on AWS, but would like to use DigitalOcean for their MongoDB clusters.</p>

<h2 style="padding-top: 15px;">MongoDB Replication Strategies</h2>
<p style="text-align: justify;">If you’re running MongoDB on DigitalOcean in production, it’s best practices to deploy using a replica set to ensure high availability and data redundancy for your clusters. DigitalOcean, along with AWS and Azure, offer a 99.99% uptime SLA, but while that sounds close to perfect, that 0.01% equates to 52.6 minutes of downtime in one year. That’s almost one hour where your database becomes inaccessible to your customers, visitors and employees which can have a significant impact on your customer retention and brand reputation.</p>

<h3 style="padding-top: 15px;">MongoDB Replica Sets</h3>
<p style="text-align: justify;">Fortunately, you can highly mitigate the risk of your deployment going down with a loss of a datacenter by setting up a geographically distributed 3-node replica set for MongoDB on DigitalOcean. There are a couple options for setting up this configuration, the first being a Primary-Secondary-Arbiter setup which provides 2 data-bearing nodes and an arbiter which acts as a voting member to determine which replica should take over in the event one becomes unavailable. This is the most affordable option as the arbiter does not hold any data and costs less to deploy, but also offers 1 less node that can take over in a failover event. The optimal replication strategy would be a Primary-Secondary-Secondary setup which leverages 3 data-bearing nodes and allows you to failover to 2 separate datacenter in the event your primary region goes down.</p>

<h3 style="padding-top: 15px;">MongoDB Sharding</h3>
<p style="text-align: justify;"><a style="color: #2da964;" href="https://scalegrid.io/blog/mongodirector-now-supports-shards/">MongoDB sharding</a> is an advanced form of deployment that allows you to horizontally scale out your data across multiple machines. This is a very complex configuration to setup and manage, as each shard contains multiple replica sets, and can be distributed across different datacenter locations for high availability. Sharding is ideal for very large data sets or high throughput deployments that require more capacity that you can get with a single server. Where the typical deployment scales vertically by adding more capacity to a server when needed, sharding allows you to scale horizontally by dividing your data and load across multiple machines. Once you have your sharded environment setup, you can add more shards as needed to support your application growth.</p>
<p style="text-align: justify;">At ScaleGrid, we offer <a style="color: #2da964;" href="https://scalegrid.io/pricing.html?db=mongodb&amp;cloud=cloud_digital_ocean&amp;replica=deployment_standalone&amp;instance=micro#section_pricing_dedicated">Standalone</a>, <a style="color: #2da964;" href="https://scalegrid.io/pricing.html?db=mongodb&amp;cloud=cloud_digital_ocean&amp;replica=deployment_mongodb_2+1&amp;instance=micro#section_pricing_dedicated">2 Replicas + Arbiter</a>, <a style="color: #2da964;" href="https://scalegrid.io/pricing.html?db=mongodb&amp;cloud=cloud_digital_ocean&amp;replica=deployment_mongodb_3&amp;instance=micro#section_pricing_dedicated">3 Replicas</a> and advanced <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mongodb-new-cluster-dedicated-hosting#section-step-3-shards">Sharding configurations</a> for hosting MongoDB on DigitalOcean under our Dedicated Hosting plan starting with a Micro plan size at $35/month up to a X4XLarge plan with 16 cores, 48GB of RAM and 950GB of storage. You can also customize your MongoDB replica set with an unlimited number of replicas for your application needs.</p>

<h2 style="padding-top: 15px;">Managed MongoDB Hosting on DigitalOcean</h2>
<p style="text-align: justify;">Now we get down to the ultimate question - should you self-manage your <a style="color: #2da964;" href="https://scalegrid.io/mongodb/digitalocean.html">MongoDB on DigitalOcean</a> deployments or leverage a fully managed Database-as-a-Service (DBaaS) platform? The answer boils down to your time, knowledge, and all-time accessibility to handle any critical issues that come up with your deployment.</p>

<h3 style="padding-top: 10px;">Management &amp; Maintenance Tasks</h3>
<p style="text-align: justify;">MongoDB DBaaS platforms allow you to automate all of your time-consuming management and maintenance operations like version upgrades, scaling, free backups, restores, provisioning, deprovisioning, replication, compacting, index management, OS patching and log rotations. Depending on the size of your deployment, this may take you 1-2 days per month, up to a full-time army of MongoDB experts working around the clock. A huge benefit of leveraging a DBaaS platform is that you eliminate the risk of human error as the management operations are automated for you. It also keeps your MongoDB clusters on DigitalOcean fully secured and up-to-date so you do not open your deployments up to potential bugs or threats that can present with a neglected database.</p>

<h3 style="padding-top: 10px;">Monitoring Performance</h3>
<p style="text-align: justify;">Monitoring is also a huge component to managing a MongoDB deployment. With a DBaaS platform, you can automate <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mongodb-alerts-and-rules">alerts</a> on all of your key MongoDB metrics so you’re informed the moment an undesired threshold is met, and access an advanced <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mongodb-monitoring-console">monitoring console</a> to analyze all of your MongoDB and OS metrics across your primary and secondary instances and over any period of time. Additionally, with a DBaaS like ScaleGrid, you can leverage the Slow Query Analyzer which allows you to visualize slow-running queries and optimize them before they start affecting your deployment performance.</p>

<h3 style="padding-top: 10px;">Troubleshooting Support</h3>
<p style="text-align: justify;">Last, but absolutely not least, is the accessibility to support. If you have been woken up at 4:00am by a frantic call from your boss wondering why your application is down and how quickly you can get it back up, you know exactly what I’m talking about. Each minute of downtime can cause you thousands of dollars of business, and much worse, a security breach could shut your business down altogether and put an everlasting stain on your reputation. By leveraging a DBaaS platform, you can get ahead of over 90% of these critical issues, and have a team of MongoDB experts at your side 24/7 for the unavoidable 10% to help you quickly identify and resolve the issues to get your deployment back to a healthy, running state.</p>
<p style="text-align: justify; padding-bottom: 20px;">At ScaleGrid, we identified DigitalOcean as an up-and-coming rockstar for hosting MongoDB and cloud computing in general back in 2013, and were the first DBaaS platform to launch support for MongoDB DigitalOcean. Still today, we are the only fully managed DBaaS platform that allows you to automate your hosting for MongoDB on DigitalOcean and leverage enterprise-grade database management tools to optimize your deployment performance, security and availability in the cloud. If you’re interested in trying out some of the advanced capabilities of a DBaaS for MongoDB on DigitalOcean, you can start a <a style="color: #2da964;" href="https://console.scalegrid.io/users/register">free 30-day trial</a> with no credit card required to explore the automation tools, and check out the <a style="color: #2da964;" href="https://scalegrid.io/mongodb/hosting-comparison.html">Compare MongoDB Providers</a> page to see how we stack up against MongoDB Atlas, mLab, ObjectRocket and Compose for MongoDB.</p>