iTranslated by AI
【IoT Orchestration & Edge Computing】Building Smart Cities with FIWARE and FogFlow
A quick snapshot for this article

FogFlow is a conductor that determines "where, what, and when to process" (created by ChatGPT).
Overview
In the previous article, I introduced a collection of components that support FIWARE's microservice architecture.
I covered a wide variety of components, including external data linkage features that leverage the notification capabilities of the Context Broker, security features such as API protection and access authentication, and data visualization.
While I understood the roles of most components, there was one (in my opinion) whose role I hadn't fully grasped yet.
FogFlow - A framework aiming to distribute computational resources between the cloud and edge devices through IoT orchestration. This article is a deep dive into FogFlow.
IoT Orchestration
First, let's outline the vision and technical motivation behind FogFlow.
In city-scale IoT platforms—IoT infrastructure providers for smart cities, smart industries, and connected cars—each sensor and IoT device is part of a large, geographically distributed infrastructure.
Now, suppose you are considering a service that "collects data from various devices and performs data processing such as analysis and analytics using the collected data." As for service quality, low latency, or the realization of rapid data processing, is essential.
How can we achieve low latency? ---
First, let's explain the technical background for why a distributed system is required to place processing on geographically dispersed edge devices.
For Example
As a simple example, consider a cloud-edge computing system with geographically dispersed edge devices connected to a cloud.
Let's organize the various elements in advance.
| Element | Role | Examples | Best Suited For |
|---|---|---|---|
| Sensor | Converts the real world into data | Temperature sensors, cameras, human sensors, vehicle GPS, etc. | Data collection and streaming |
| Edge | Processing near the site, low latency, bandwidth savings, responsiveness | Gateways, edge servers, factory PCs, intersection servers, etc. | Image inference, anomaly detection, local aggregation |
| Cloud | Heavy, wide-area, history-based processing, overall optimization, learning, aggregation | Large-scale analysis, machine learning training, urban-wide statistics | Large-scale analysis, machine learning training, urban-wide statistics |
| Actuator | Reflects results in the real world | Traffic lights, air conditioning control, alarm devices, digital signage | - |
Now, as a comparison, I present a centralized architecture (figure below).

This is a structure where multiple sensors and actuators are directly connected to the cloud. The division of roles seems to be collecting data from each sensor and processing it all on the cloud.
Weaknesses of this structure:
Feedback to actuators based on data processing in the cloud becomes slow (decreased throughput).
Because data from all sensors is aggregated and processed on the cloud, the processing load on the cloud tends to become excessive (the weakness of extreme centralization).
Therefore, especially in situations where rapid actuator operation is required based on information collected from sensors, the length of computation time in the cloud becomes a fatal bottleneck.
Furthermore, when handling diverse data like in a smart city, the decrease in throughput can become even more severe. For example, simply transmitting unstructured data (images, audio, video) to the cloud might take a significant amount of time.
The Key is "Task Allocation and Execution" Based on Resource Placement
So, how can we break through the challenges of the centralized architecture mentioned earlier...
One answer is: "Don't we have to leave everything to the cloud?" In other words, introduce a distributed processing architecture as shown in the figure below.

This avoids concentrating task processing on the cloud, distributes tasks across the entire architecture, and as a result, throughput is improved.
An example of task distribution is this---
"Process image data acquired by sensors at the edge, and pass only the necessary feature values to the cloud."
If you pass image data as-is through communication, it takes time to transmit. Moreover, there are tasks that do not necessarily need to be processed in the cloud.
In this way, if you can clearly separate "tasks that should be executed in the cloud and tasks that can also be executed at the edge" and let the cloud and edge focus on their respective specialties, you should be able to realize lower-latency services.
Let's organize the specialties of edge and cloud.
| Element | Role | Best Suited For |
|---|---|---|
| Edge | Processing near the site, + low latency, bandwidth savings, responsiveness | Image inference, anomaly detection, local aggregation |
| Cloud | Heavy, wide-area, history-based processing + overall optimization, learning, aggregation | Large-scale analysis, machine learning training, urban-wide statistics |
In short,
- At the edge: Things that can be handled locally. Tasks without dependencies on other processes. Lightweight processing.
- In the cloud: Things that require overall consideration. Large-scale data processing, etc.
You can divide roles like this.
FogFlow
Sharing the roles of tasks between the cloud and the edge -
This is the core idea of a distributed IoT architecture that achieves low-latency response.
By the way, the next problem is how to decide "who (cloud or edge) performs which task."
Traditionally, this work was shouldered by infrastructure providers (those kinds of people).
As business demands change rapidly over time, service providers now need to release new services at an ever-increasing speed.
However, designing and deploying IoT services in a cloud-edge environment faces extreme complexity and costs, and the burden of these operational tasks is only increasing.
This is where FogFlow wants to add value.
It is to significantly reduce the massive development and operational costs of traditional IoT platforms.
With FogFlow, service providers can easily program IoT services with minimal development effort and release new IoT services with a shorter time-to-market.

Layered Architecture
Let's look inside FogFlow from here.
Logically, FogFlow consists of the following three layers:
service managementcontext managementdata processing

service management
The layer responsible for task placement and management:
Converts service requirements into concrete execution plans and deploys (places) the generated execution plans to the cloud and edge.
This layer contains the following two components:
-
Task Designer: Provides a web-based interface for service providers to specify, register, and manage tasks and service topologies. -
Topology Master: Keeps track of when and which tasks need to be instantiated, dynamically configures them, and decides where in the cloud and edge to deploy them.
context management
The layer responsible for managing data (Context) flowing on FogFlow:
Manages all context information and makes them discoverable and accessible via flexible query and subscribe interfaces.
This layer contains the following components:
-
IoT Discovery: Manages all context availability information that has been registered, such as IDs, entity types, attribute lists, and metadata. Enables other components to query and subscribe to context availability information of interest viaNGSI9(e.g., responding to requests to find nearby IoT Brokers). -
IoT Broker: Each broker manages a subset of context entities published by nearby IoT devices and also provides a single view of all context entities for IoT devices to query and subscribe to needed entities.
(So to speak, an edge-like presence.)
data processing
The layer responsible for collecting data following task execution instructions from service management:
Launches data processing tasks and establishes data flows between tasks via the pub/sub interface provided by the context management layer.
-
Worker: According to the allocation from theTopology Master, each worker launches scheduled task instances in Docker containers on the local host. Configures inputs and outputs and manages all task instances locally based on task priority.
Intent-Based Programming
A major feature of FogFlow is that it "automatically places tasks you want to execute onto the edge and cloud, and executes distributed tasks in the appropriate locations and numbers."
This "automatically places" part is a big difference from the past.
Traditionally:
- This process on the edge
- This process on the cloud
- If the load increases, replicate (scale) it...
These were manually planned for deployment and scaling operations.
In FogFlow, by introducing "intent-based programming," as long as a person describes "under what conditions and what kind of data they want to process," the placement destination (edge/cloud), number of instances (number of workers), scaling, and lifecycle management are automatically adjusted by FogFlow.
"Under what conditions and what kind of data you want to process"... This part (processing intent = intent) can be declaratively defined by hand using the following two programming models:
FogFunctionService Topology
| Perspective | FogFunction | Service Topology |
|---|---|---|
| Purpose | Single processing | Entire workflow |
| Defined Object | Single operator | Graph of multiple operators |
| Processing dependency | None | Explicitly specified |
| Design complexity | Low | High |
| Execution Example | Threshold processing | Anomaly detection -> Aggregation -> Notification |
| Trigger | Data input | Intent object |
| Auto-segmentation | Per task unit | Composite task unit |
| Distributed placement | Left to FogFlow | Left to FogFlow |
These programming models can be defined through simple operations using the Web browser UI where FogFlow Designer is running.
Fog Function
FogFunction is a task definition targeting only a single processing unit.
It is an event-driven model for simple processing that specifies input Context (NGSI entities) and triggers the process when that data arrives. (See the image below)
To define a Fog Function, you only need to specify the following items:
-
Task(Process name / operator) -
EntityStream(Input NGSI type)-
SelectedType:Entitytype -
SelectedAttributes: Which of the attribute parameters of theSelectedTypeto retrieve -
GroupBy: The data granularity used for the trigger within theSelectedType. This granularity determines the number ofFog Functioninstances. Therefore, if you specify a unique ID (Entity ID), a task instance is generated for eachEntitycorresponding to the specifiedEntitytype. -
Scoped: Whether the entity data is location-specific. If it is unique, you are imposing a constraint so that it only accepts input from a specific location.
-
Once a Fog Function is defined, FogFlow automatically determines the scale and placement to execute it.
Service Topology
Service Topology is a method for defining the entire flow connecting multiple processes.
While FogFunction was a task definition targeting only a single processing unit, Service Topology allows you to define more complex processing.
Specifically, you create a service processing pipeline with explicitly defined input/output dependencies by combining multiple operators (processing units) in a graph structure.
In Service Topology, you specify elements like the following:
topology namedescription-
tasks(multiple processes)- Input / Output streams for each task
- GroupBy
- Scoped (granularity/scope)
- Connector (flow between processes)
Because you can design the dependencies between processes in a graph, you can express more complex application flows.
Additionally, Service Topology is started on-demand by sending an Intent object, and the FogFlow scheduler automatically splits and places the tasks for each operator.
Intent Object
Additionally,
Service Topologyis started on-demand by sending an Intent object, and the FogFlow scheduler automatically splits and places the tasks for each operator.
Regarding the above part: this means that FogFlow operates on-demand by intentionally sending triggers that cause data collection or data analysis.
To do this, the Topology Master waits for input streams for the tasks included in the defined Service Topology. (Waiting for an intent object to be sent while in standby mode.)
An Intent object has the following properties:
-
Topology: Specifies the topology targeted by the intent object -
Priority: Defines the priority level for all tasks within the topology -
Resource Usage: Defines how the topology can use the resources of edge nodes -
Objective: Sets maximum throughput, minimum latency, or minimum cost for task assignment at the worker level (these become the constraints for automatic placement) -
Geoscope: A predefined geographic region from which to select input streams
As soon as an intent object is sent and context data within the scope of the intent object is received, the task starts on the nearest worker.
That seems to be the mechanism. Note that this is not defined in the Fog Function model.
Example: In-store alert system
To help visualize task splitting and deployment from Service Topology, let me explain the example from the FogFlow documentation.

The flow defined by Service Topology is as follows:
-
Anomaly Detector: This operator detects anomaly events based on data collected from retail store power panels. It requires two types of inputs.-
New Rules: Detection rules provided and updated by the operator. The detection rule input stream type is associated withbroadcast, and the rules are required for all task instances of this operator. The granularity of this operator is based onshopID, meaning dedicated task instances are created and configured for each shop. -
PowerPanel: Sensor data from power panels.
-
-
Counter: This operator counts the total number of anomaly events for all shops in each city. Therefore, the granularity of that task iscity. Its input stream type is the output stream type of the previous operator (Anomaly Detector), requiring output from all shops in the city.
Service Topologyof the in-store alert system
This example appears to be handling data for three stores in one city. Therefore, based on the Service Topology defined by the user, FogFlow automatically creates the following Execution Plan and Deployment Plan.

Image of task decomposition -> deployment plan for the in-store alert system
Process A (=Counter). Process B (=Anomaly Detector)
To explain the automatic task distribution in colloquial terms:
- Based on the
Service Topology, process A (=Counter) generates task instances equal to the number of cities (=1), and process B (=Anomaly Detector) generates task instances equal to the number of stores (=3). - The generated task instances (= TA0, TB0, TB1, TB2) generate a distributed execution flow for tasks in a DAG, following the logical structure of the original
Service Topology. - Tasks are placed in the edge or cloud. For example, since task A0 must wait for the results of all instances of process B, it is placed in the cloud, while other task instances are placed at the edge close to the geographically dispersed shops... and so on.
- If there are geographic distance or computational resource constraints, multiple task instances are aggregated on an edge (e.g., TB0 + TB1 -> edge 1).
Tutorial Sample
I have provided an explanation based on documentation so far.
However, since the image is still not quite clear, let's actually try using FogFlow.
Preparation for startup
As a prerequisite, FIWARE runs on Docker, so please prepare Docker on your PC.
To get it running quickly, clone the code according to the FIWARE tutorial.
$ git clone https://github.com/FIWARE/tutorials.NGSI-LD.git
$ cd tutorials.NGSI-LD/
$ git submodule update --init --recursive
Now, navigate to the directory for each tutorial.
This time, we will touch tutorials.Edge-Computing.
$ cd <tutorial-name>
$ git checkout NGSI-LD
$ ./services start # Containers start running
After checking that it is running with docker ps, let's look at FogFlow.
Checking the dashboard
Once the Docker container is started, check your browser at http://<my_hostip>/index.html. It's OK if a screen like the one below is displayed.

<my_hostip> is set in config.json. A default address is included during cloning, but you need to enter your host PC's IP address here. (Important)
{
"my_hostip": "XXX.XXX.XXX.XXX", // Change to host PC IP address
"physical_location":{
"longitude": 139,
"latitude": 35
},
"site_id": "001",
"logging":{
"info":"stdout",
"error":"stdout",
"protocol": "stdout",
"debug": "discard"
},
Trying out FogFunction
Once the dashboard is open, let's register a simple task process.
Click on Fog Function in the top tab.

Screen after clicking
Fog Function
Then, click register on the screen.
You will then move to a screen where you can configure the Fog Function.
Please see the tutorial for details, but here we are creating a "task to determine vehicle speed limit violations." We define a framework where a process to "determine vehicle speed violations" is dropped into a task from a pre-created Docker image, and waits for a Vehicle entity to be sent.

Screen after defining the task flow
After registration, the Fog Function will be in a state waiting for updates to the target data (Vehicle) on the server.
So, let's forcibly register data in the Broker to check how the Fog Function behaves.
`Vehicle` sensor entity registration example
// Check your own <Fogflow_Broker_IP>. If default, it's `localhost`
curl --location --request POST '<Fogflow_Broker_IP>:8070/ngsi-ld/v1/entities/' \
--header 'Content-Type: application/json' \
--header 'Accept: application/ld+json' \
--header 'Link: <{{link}}>; rel="https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"; type="application/ld+json"' \
--data-raw '{
"id": "urn:ngsi-ld:Vehicle:A100",
"type": "Vehicle",
"brandName": {
"type": "Property",
"value": "Mercedes"
},
"isParked": {
"type": "Relationship",
"object": "urn:ngsi-ld:OffStreetParking:Downtown1",
"observedAt": "2017-07-29T12:00:04",
"providedBy": {
"type": "Relationship",
"object": "urn:ngsi-ld:Person:Bob"
}
},
"speed": {
"type": "Property",
"value": 80
},
"createdAt": "2017-07-29T12:00:04",
"location": {
"type": "GeoProperty",
"value": {
"type": "Point",
"coordinates": [
-8.5,
41.2
]
}
}
}'
When you register the Vehicle sensor entity with the above command, an instance of the Fog Function will appear in Task Instance on the dashboard.

You can see that the Fog Function started automatically because the data was updated.
Summary
In this article, I explained FogFlow, which achieves distributed edge computing.
As it is called an IoT orchestra, it is a mechanism to improve the throughput of task processing, such as machine learning, by appropriately distributing task execution processing to various resources such as the cloud and edge, considering the conditions for acquiring data necessary for task processing.
Keywords
Here are the outlines and reference articles for some of the technical names that appeared.
RabbitMQ
Software to realize asynchronous communication between applications using message queues. RabbitMQ uses a protocol called AMQP to connect message senders and receivers. Note that this AMQP, unlike MQTT and others, is a protocol for enterprise-to-enterprise communication, providing secure communication based on the reliability of the sender.
Discussion