5G Edge infrastructure auto-scaling with Verizon ThingSpace and AWS CloudWatch: A Tutorial

Verizon 5G Edge Blog
6 min readOct 20, 2022

--

  • Kevin Xu — Corporate Strategy, Verizon & Joshua Markham — Solutions Architecture, Verizon

Use network intelligence in edge application orchestration

From horizontal and vertical scaling to cool-down periods and health checking, application orchestration plays a critical role in infrastructure right-sizing, resiliency, high availability, and even security. Take horizontal scaling as the simplest orchestration example: today you have 1 virtual machine and, at some certain threshold, you would like to scale to 2 virtual machines.

In the case of mobile edge computing involving large numbers of mobile IoT devices, device proximity to edge computing resources could be the primary driver for application orchestration in configuring the auto scaling policies.

In Verizon 5G Edge, network intelligence can be leveraged by the application orchestrator on MEC (such as on AWS Wavelength) to build the knowledge of the real-time distribution of IoT devices across the network and use that as a customer metric to drive the auto scaling action.

Tutorial Overview

In this simple tutorial, we’ll step through how to auto scale a fleet of EC2 instances using AWS Auto Scaling Group (ASG), AWS CloudWatch, and Verizon’s ThingSpace Manage APIs. For this ASG policy, we’ll use a new custom metric that aggregates the number of active 4G LTE devices within a geographic region and sets a user-defined threshold to add instances (scale out) or remove instances (scale in).

ThingSpace is a Verizon IoT platform that gives you access to APIs and tools so you can manage your device lifecycle, including connectivity, security, location, software and data streaming all in a single platform. ThingSpace includes Connectivity Management APIs that allow you to add and activate devices, check their status, monitor their usage, monitor their reachability for Data and SMS communication as well as their connection status, and perform other device connectivity management tasks through a RESTful API. To learn more about Connectivity Management, visit the ThingSpace docs.

AWS CloudWatch provides a rich set of tools to monitor health and resource utilization of various AWS services. The metrics CloudWatch collects can then be used to set up alarms, send notifications, and trigger actions upon alarms firing.

What are we building?

There are three components to this tutorial:

Part 1 | Device Metrics

  • In Part 1, we’ll use the ThingSpace location API to extract latitude/longitude coordinates of our Verizon devices. In this way, we can extract the network intelligence needed for our Auto Scaling policy. At the end of this section, we’ll push the data to CloudWatch.

Part 2 | CloudWatch Alarm

  • In Part 2, we add an alarm to CloudWatch that tells AWS to trigger a notification when a certain threshold is reached. In this case, when the device is 100 miles from our specified geo-radius (let’s say Boston, if we’re looking to scale the Boston Wavelength Zone), we want our 5G Edge resources in Boston to scale by 1 virtual machine.

Part 3 | Auto Scaling Group

  • In Part 3, we’ll walk through how to spin up your first Auto Scaling Group in an AWS Wavelength Zone. Next, we’ll connect the CloudWatch alarm we just created in part 2 and connect the scaling policy we created as a trigger for the alarm.

To view the full code repository, visit our Github repo or checkout the guided walkthrough below.

Getting Started

Ensure you have boto3 downloaded and an active ThingSpace device with an associated account. To learn more about ThingSpace, check out this link on how to get started using the ThingSpace API services.

Step 1: Build CloudWatch custom metric using ThingSpace APIs

First we set up a few variables, including your device ICCID/IMEI values which you’ll get from the ThingSpace console and coordinates for your “geofence”:

Then, we instantiate a CloudWatch object using the boto3 package:

We will also need a helper function, calculateDistance, to calculate the distance between two locations: our geofence coordinates (i.e,. Boston) and any new lat/lon pair that the ThingSpace Location API returns from our device fleet:

Next, define a function that periodically queries ThingSpace device locations and returns the device’s latitude and longitude:

Then, using the lat/lon pair of the “geofence” you set above (i.e., Boston), pass the recently extracted lat/lon data from ThingSpace to the helper function, calculateDistance, which determines the distance between the two points:

Lastly, if the distance is within a predefined range (e.g., 250 km as defined by ‘geofence_dist’), push the number of devices that are within the range to CloudWatch as a custom metric. Note here, we use the random number between 50 and 200 to simulate the number of devices in the range since we only had one device available to use in our test. In reality, the ‘Value’ in the custom metric should be set to the actual count of devices that are in the range from the MEC:

Step 2: Create auto scaling group

First, define a launch configuration and an auto scaling group. The launch configuration is the unit of resource for auto scaling, in our example an EC2 instance, and the auto scaling group will create a launch configuration instance when the auto scaling action is triggered:

Then, we install an auto scaling policy for the defined auto scaling group:

Step 3: Define and connect CloudWatch alarm to auto scaling policy

Define a CloudWatch alarm to be fired based on the desired threshold for the device to MEC distance we computed in step 1, and connect this alarm to the auto scaling policy such that the auto scaling action will take place upon the firing of the alarm:

That is it. Now we have a custom defined CloudWatch metric, based on network intelligence via ThingSpace services, with an alarm that fires based on a user-defined threshold which then triggers the auto scaling policy to act. Currently there are 19 AWS Wavelength zones as Verizon’s public mobile edge computing (MEC) platforms throughout Verizon’s network, for access to AWS Wavelength zones please refer to this Wavelength Getting Started Guide.

Additional information

You can learn more about ThingSpace by checking out this tutorial for Getting Started on ThingSpace or by visiting the docs.

--

--

Verizon 5G Edge Blog

Powering the next generation of immersive applications at the network edge.