Mongo + Docker Swarm (Fully Automated Cluster)

Goran Jovanov
12 min readApr 8, 2019

When it comes to developing modern apps, working with MongoDB has become de-facto a standard among the NoSQL DBs, because of its flexible nature to easily start and rapidly develop apps. However, once your application’s user base starts to grow, the necessity for scaling your DB either due to Performance or to Redundancy (Data Availablity) becomes inevitable.

Besides the option to scale you DB vertically (more CPU, more RAM, more Disk, faster Network etc), MongoDB provides options to scale your DB horizontally via ReplicaSet (multiple copies of data), Sharding (splitting data among multiple servers) and Query Routers (multiple Routing instances that distribute the query to actual data storing instances).

The goal of this in-depth article is to describe the step-by-step process of creating production-ready fully automated MongoDB ReplicaSet Cluster deployed in Docker Swarm running on multiple VMs and do that by running a single command.

Lets dive into the technical aspects of it.

Automation

To achive automation, we will rely on:

--

--