Real-time Data Architectures with MongoDB Cloud Manager and Verizon 5G Edge
Rate this tutorial
The network edge has been one of the most explosive cloud computing opportunities in recent years. As mobile contactless experiences become the norm and as businesses move ever-faster to digital platforms and services, edge computing is positioned as a faster, cheaper, and more reliable alternative for data processing and compute at scale.
While mobile devices continue to increase their hardware capabilities with built-in GPUs, custom chipsets, and more storage, even the most cutting-edge devices will suffer the same fundamental problem: each device serves as a single point of failure and, thus, cannot effectively serve as a persistent data storage layer. Said differently, wouldn’t it be nice to have the high-availability of the cloud but with the topological distance to your end users of the smartphone?
Mobile edge computing promises to precisely address this problem—bringing low latency compute to the edge of networks with the high-availability and scale of cloud computing. Through Verizon 5G Edge with AWS Wavelength, we saw the opportunity to explore how to take existing compute-intensive workflows and overlay a data persistence layer with MongoDB, utilizing the MongoDB Atlas management platform, to enable ultra-immersive experiences with personalized experience—reliant on existing database structures in the parent region with the seamlessness to extend to the network edge.
In this article, learn how Verizon and MongoDB teamed up to deliver on this vision, a quick Getting Started guide to build your first MongoDB application at the edge, and advanced architectures for those proficient with MongoDB.
Let’s get started!
Through Verizon 5G Edge, AWS developers can now deploy parts of their application that require low latency at the edge of 4G and 5G networks using the same AWS APIs, tools, and functionality they use today, while seamlessly connecting back to the rest of their application and the full range of cloud services running in an AWS Region. By embedding AWS compute and storage services at the edge of the network, use cases such as ML inference, real-time video streaming, remote video production, and game streaming can be rapidly accelerated.
However, for many of these use cases, a persistent storage layer is required that extends beyond the native storage capabilities of AWS Wavelength—namely Elastic Block Storage (EBS) volumes. However, using MongoDB Enterprise, developers can leverage the underlying compute (i.e.,. EC2 instances) at the edge to deploy MongoDB clusters either a) as standalone clusters or b) highly available replica sets that can synchronize data seamlessly.
MongoDB is a general purpose, document-based, distributed database built for modern application developers. With MongoDB Atlas, developers can get up and running even faster with fully managed MongoDB databases deployed across all major cloud providers.
While today does not support deployments within Wavelength Zones, can automate, monitor, and back up your MongoDB infrastructure. Cloud Manager Automation enables you to configure and maintain MongoDB nodes and clusters, whereby MongoDB Agents running on each MongoDB host can maintain your MongoDB deployments. In this example, we’ll start with a fairly simple architecture highlighting the relationship between Wavelength Zones (the edge) and the Parent Region (core cloud):
Just like any other architecture, we’ll begin with a VPC consisting of two subnets. Instead of one public subnet and one private subnet, we’ll have one public subnet and one carrier subnet —a new way to describe subnets exposed within Wavelength Zones to the mobile network only.
- Public Subnet: Within the us-west-2 Oregon region, we launched a subnet in us-west-2a availability zone consisting of a single EC2 instance with a public IP address. From a routing perspective, we attached an Internet Gateway to the VPC to provide outbound connectivity and attached the Internet Gateway as the default route (0.0.0.0/0) to the subnet’s associated route table.
- Carrier Subnet: Also within the us-west-2 Oregon region, our second subnet is in the San Francisco Wavelength Zone (us-west-2-wl1-sfo-wlz-1) —an edge data center within the Verizon carrier network but part of the us-west-2 region. In this subnet, we also deploy a single EC2 instance, this time with a carrier IP address—a carrier network-facing IP address exposed to Verizon mobile devices. From a routing perspective, we attached a Carrier Gateway to the VPC to provide outbound connectivity and attached the Carrier Gateway as the default route (0.0.0.0/0) to the subnet’s associated route table.
Next, let’s configure the EC2 instance in the parent region. Once you get the IP address (188.8.131.52) of the launched EC2 instance, SSH into the instance itself and begin to download the MongoDB agent.
Once you are in, download and install the packages required for the MongoDB MMS Automation Agent. Run the following command:
Once within the instance, download the MongoDB MMS Automation Agent, and install the agent using the RPM package manager.
Once you are logged in, create a new organization, and for the cloud service, be sure to select Cloud Manager.
With your organization created, next we’ll create a new Project. When creating a new project, you may be asked to select a cloud service, and you’ll choose Cloud Manager again.
Next, you’ll name your project. You can select any name you like, we’ll go with Verizon for our project name. After you give your project a name, you will be given a prompt to invite others to the project. You can skip this step for now as you can always add additional users in the future.
Finally, you are ready to deploy MongoDB to your environment using Cloud Manager. With Cloud Manager, you can deploy both standalone instances as well as Replica Sets of MongoDB. Since we want high availability, we’ll deploy a replica set.
Clicking on the New Replica Set button will bring us to the user interface to configure our replica set. At this point, we’ll probably get a message saying that no servers were detected, and that’s fine since we haven’t started our MongoDB Agents yet.
Click on the “see instructions” link to get more details on how to install the MongoDB Agent. On the modal that pops up, it will have familiar instructions that we’re already following, but it will also have two pieces of information that we’ll need. The mmsApiKey and mmsGroupId will be displayed here and you’ll likely have to click the Generate Key button to generate a new mmsAPIKey which will be automatically populated. Make note of these mmsGroupId and mmsApiKey values as we’ll need when configuring our MongoDB Agents next.
Head back to your terminal for the EC2 instance and navigate to the /etc/mongodb-mms/ and edit the automation-agent.config file to include your MongoDB Cloud Manager API Key.
In this example, we edited the mmsApiKey and mmsGroupId variables. From there, we’ll create the data directory and start our MongoDB agent!
Once you’ve completed these configuration steps, go ahead and do the same for your Wavelength Zone instance. Note that you will not be able to SSH directly to the instance’s Carrier IP (184.108.40.206/). Instead, you must use the parent region instance as a bastion host to “jump” onto the edge instance itself. To do so, find the private IP address of the edge instance (10.0.0.54) and, from the parent region instance, SSH into the second instance using the same key pair you used.
After completing configuration of the second instance, which follows the same instructions from above, it’s time for the fun part —launching the ReplicaSet on the Cloud Manager Console! The one thing to note for the replica set, since we’ll have three nodes, on the edge instance we’ll create a /data and /data2 directories to allow for two separate directories to host the individual nodes data. Head back over to and the Cloud Manager to complete setup.
Refresh the Create New Replica Set page and now since the MongoDB Agents are running you should see a lot of information pre-populated for you. Make sure that it matches what you’d expect and when you’re satisfied hit the Create Replica Set button.
Click on the “Create Replica Set” button to finalize the process.
Within a few minutes the replica set cluster will be deployed to the servers and your MongoDB cluster will be up and running.
With the replica set deployed, you should now be able to connect to your MongoDB cluster hosted on either the standard Us-West or Wavelength zone. To do this, you’ll need the public address for the cluster and the port as well as Authentication enabled in Cloud Manager. To enable Authentication, simply click on the Enabled/Disabled button underneath the Auth section of your replica set and you’ll be given a number of options to connect to the client. We’ll select Username/password.
Click Next, and the subsequent modal will have your username and password to connect to the cluster with.
You are all set. Next, let’s see how the MongoDB performs at the edge. We’ll test this by reading data from both our standard US-West node as well as the Wavelength zone and compare our results.
After laying out the architecture, we wanted to see the power of 5G Edge in action. To that end, we designed a very simple “race.” Over 1,000 trials we would read data from our MongoDB database, and timestamp each operation both from the client to the edge and to the parent region.
After running this experiment, we found that our MongoDB node at the edge performed over 40% faster than the parent region! But why was that the case?
Given that the Wavelength Zone nodes were deployed within the mobile network, packets never had to leave the Verizon network and incur the latency penalty of traversing through the public internet—prone to incremental jitter, loss, and latency. In our example, our 5G Ultra Wideband connected device in San Francisco had two options: connect to a local endpoint within the San Francisco mobile network or travel 500+ miles to a data center in Oregon. Thus, we validated the significant performance savings of MongoDB on Verizon 5G Edge relative to the next best alternative: deploying the same architecture in the core cloud.
While Verizon 5G Edge alone enables developers to build ultra-immersive applications, how can immersive applications become personalized and localized?
From real-time transaction processing, telemetry capture for your IoT application, or personalization using profile data for localized venue experiences, bringing MongoDB ReplicaSets to the edge allows you to maintain the low latency characteristics of your application without sacrificing access to user profile data, product catalogues, IoT telemetry, and more.
In our next post, we will demonstrate how to build your first image classifier on 5G Edge using MongoDB to identify VIPs at your next sporting event, developer conference, or large-scale event.
Joining Collections in MongoDB with .NET Core and an Aggregation Pipeline
Feb 03, 2023 | 7 min read
Currency Analysis with Time Series Collections #3 — MACD and RSI Calculation
May 16, 2022 | 8 min read