# Scalable Fog Computing Orchestration for Reliable Cloud Task Scheduling
## 3 The Proposed Fog Computing Orchestration Mechanism  
In this section, we provide our scalable fog computing orchestration algorithms that enhance the reliability of cloud tasks. The proposed algorithms are composed of two parts: a task scheduling algorithm that schedules a new task for IoT and IIoT devices and a task migration algorithm that transfers existing tasks to another edge server and container. Figure 2 shows the process and flow of the proposed algorithms. There are eight stages in the performance of our proposed orchestration schemes. First, task scheduling is initiated when a new task for IoT and IIoT devices has arrived. Second, when a task is assigned an edge server and its container, the user's mobile application is associated with the edge server. Third, the central cloud center periodically monitors the edge servers and containers in the cloud computing environment. Fourth, based on monitoring information, the system may trigger task migration in a reliable fashion. Fifth, the central cloud center collects data and has the target edge server prepare for migrations. Sixth, the source edge server and destination edge server are synchronized for migrations. Seventh, the migration data are transferred from the source edge server to the destination edge server. Finally, the eighth stage is the re-registration of the user's mobile application to the destination edge server, which is transparent to the user. Algorithm 1 shows the task scheduling algorithm. This algorithm is triggered when a new task for IoT and IIoT devices has arrived. The input is _Tuple_i_, and the output is mapping information for the tuple (_Map_i_), that is, _Tuple_i_, _Edge_j_, and _Container_k_. The algorithm uses location and requirement information based on _Tuple_i_. To compose the  
Figure 2: The process and flow of the proposed algorithms (c.f., Algorithms 1 and 2). assign_tuple_ function, several variables are used: _signal_strength_, _target_edge_, _target_container_, and _found_. It first finds connectable edge servers based on the location. Then, it retrieves the signal strength (_current_signal_strength_) of each edge server by iterating the loop. When _current_signal_strength_ is greater than _signal_strength_, the _signal_strength_ variable is updated with _current_signal_strength_, and that edge server is assigned to _target_edge_. After selecting a target edge server, it traverses each container of the target edge server to check whether _Tuple_i_ can be assigned to an existing container. When one of the existing containers meets the requirement, it assigns _Tuple_i_ to the container. If it cannot find a container that meets the requirement, it triggers a new container provision for the _target_edge_. Algorithm 2 shows the task migration algorithm. The input of the algorithm is _Map_i_, and the output is _New_Map_i_. Both _Map_i_ and _New_Map_i_ contain tuple, edge server, and container information. For the task migration, several variables are initialized (_location_, _signal_strength_, _mobility_speed_, _mobility_property_, _target_edge_, and _bool_migration_). Before it schedules the task migration, the _check_condition_ function is called. Note that the _check_condition_ function is called at a regular interval. The _check_condition_ function traverses neighbor edge servers of _Edge_i_. After retrieving _signal_target_ for _Edge_i_, it calculates the threshold value for the condition. The threshold value is a result of the threshold function with three parameters (_signal_strength_, _location_, and _mobility_speed_). If _signal_target_ is greater than the threshold value (_val_threshold_), _Edge_i_ is assigned to _target_edge_.