Skip to the content.

Fog layers: fill the mist, then overflow outward

What it shows

A fog deployment is concentric: home gateways sit closest to the sensors, one neighbourhood edge data center sits behind them, and the cloud is the last resort. FogLayersOrchestrator encodes that intuition as a walk. It tries the layers in the fixed order mist, edge, cloud, stops at the first layer that holds a node able to run the task, and takes the least loaded node of that layer. The consequence is that the near gateways absorb as much work as they can and only the true overflow leaves the mist.

The orchestrator keeps its own picture of how many tasks are in flight on each candidate. find_computing_node walks PREFERENCE, calls _least_loaded_in for the first usable layer, and increments that node’s pending count; results_returned decrements it when the result comes back. A strict < in the inner loop keeps the first idle node of a layer when two are equally loaded, so a sensor’s tasks spread gateway by gateway instead of piling on one. Because the policy implements the hierarchy itself, no container registry and no delegated orchestrator are needed, and the sensors, which have no CPU, always exercise it: their task cannot run at home, so it starts at a gateway and only moves outward when the gateways are busy.

flowchart LR
    Sn["201 sensors, 0 MIPS<br/>generate only"] --> Ga["Mist: 99 home gateways<br/>4 cores, 20000 MIPS<br/>300 m range"]
    Ga -->|"every gateway busy"| Ed["Edge: 1 data center<br/>16 cores, 100000 MIPS"]
    Ed -->|"edge busy"| Cl["Cloud: 1 data center<br/>200 cores, 40000 MIPS"]
    classDef layer fill:#cfe8ff,stroke:#333;
    class Ga,Ed,Cl layer;

The scenario

settings/ describes a smart home:

Run it

From the repository root, after pip install -e .:

python examples/fog_layers/fog_layers.py

No-install variant:

PYTHONPATH=src python examples/fog_layers/fog_layers.py

What to look for

The console ends with the layer summary and the result row:

FogLayersOrchestrator - placements per layer: Mist=4129, Edge=2
FOG_LAYERS       devices= 300 tasks= 14515 ok= 10502 failed(delay)= 4013 avg_delay=0.316    cloud=   0 edge=  30 mist=14485 energy=40.1415
Layer Placement decisions Tasks executed
Mist (gateways) 4129 14485
Edge (data center) 2 30
Cloud 0 0

Raise the gateway share above 33 percent, or shrink edge_devices_range, to move the balance: more mist capacity lifts the success rate, a narrower range pushes more overflow to the edge.

Results go to examples/fog_layers/output/.

Files

Where to go next