Container Application Migration Algorithm in Internet of Vehicles

Internet of Vehicles (IoV) is a popular application scenario that combines edge computing and the Internet of Things. Among them, service migration caused by IoV application mobility is a research hotspot in this field. This paper studies the migration strategy of container applications based on edge computing in the IoV business scenario. In order to solve the difficulty in selecting the target server of the application to be migrated in the crossroads scenario, this paper converts the migration decision to the shortest path problem based on dynamic programming, and obtains the best migration choice at the current time by finding the migration path with the least total cost in a limited observation time, then use the container live migration technology to implement application pre-deployment, thereby greatly reducing service downtime, and enabling user-unaware application migration. Simulation results show that the dynamic programming method proposed in this paper reduces the long-term average migration total cost by 33.88% and 24.53%, respectively, compared to the nearest selection method and the local optimal method.


Introduction
In recent years, the rapid development of the Internet of Things has resulted in massive data generated by network edge devices [1,2]. However, the efficiency of cloud computing nowadays is insufficient to process all of this data. It is because the cloud data center is far away from the business terminal, and today's network bandwidth level is difficult to match the surge in data volume [3]. Therefore, the industry proposes edge computing technology [4,5], which aims to reduce the burden on cloud data centers by delegating some data processing rights to network edge nodes and then running applications or processing some calculation tasks near business terminals. Thereby the edge computing has the potential to reduce latency, improve processing efficiency, reduce energy consumption, and save bandwidth.
Internet of Vehicles (IoV) is one of the most popular application scenarios combining edge computing and the Internet of Things. Edge computing technology is hoped to solve the ultra-low-latency business needs of IoV applications [6], while the IoV applications must be migrated frequently between different edge servers due to the fast-moving speed of connected vehicles and the limited coverage of each edge server. To ensure service continuity and minimize migration costs, the application migration should be performed by using virtualization technology. The container has excellent characteristics such as seconds-level startup and a small number of migration operations in virtualization technology. Therefore, compared to virtual machine migration, container migration is more suitable for IoV application migration scenarios [7][8][9][10][11]. Fig. 1 depicts the migration scenario of IoV applications based on edge computing and container technology. Containers host applications on edge servers and vehicles access the nearby edge server to obtain the corresponding service. Each edge server has a limited-service domain. When the vehicle moves outside the local service domain, the communication with the local server E 1 will be disconnected, and the service may be interrupted. In order to ensure service continuity, the application must be migrated from the source server E 1 to other servers (such as E 3 ), and then the vehicle can obtain the service again by accessing the new server.
Through the above scenario description, the research content of this paper can be divided into the following three questions: (1) When will the migration action happen? i.e., to define the triggering conditions for the migration decision; (2) Where will the application be migrated? i.e., to judge the best target edge server; (3) How to carry out the migration process? i.e., to design the migration model and migration algorithm.
The organization of the rest paper is as follows: Section 2 describes the process of establishing a container application migration model based on edge computing in the IoV business scenario. Section 3 introduces the process of designing a container application migration algorithm based on dynamic programming. Section 4 shows the results of simulation experiments and compares the algorithm proposed in this paper with the other two algorithms. Section 5 summarizes the research work of this paper and discusses some subsequent problems to be solved.

Application Migration Model
This section introduces the process of establishing the migration model that used in this paper. This part defines the trigger conditions for migration.
Define the pre-judgment radius as d pre (d pre , d thr , where d thr is the coverage radius of the edge server service domain). When the distance from the connected vehicle to the center of the local service domain exceeds d pre , the vehicle tends to continue driving away from the local service domain, and the vehicle has no stopover halfway (i.e., the vehicle's speed should be greater than or equal to V , usually set V ¼ 30km=h in urban road scenarios [12,13]), the connected vehicle has reached the migration trigger condition, then immediately preparing for migration.
This part describes how to select the target server. This paper mainly discusses two driving road scenes. One is a straight road scene without branch roads, as is shown in Fig. 2a; the other is a crossroad scene including T-shaped branch roads, as is shown in Fig. 2b.
For the straight road scene, since the connected vehicle can only keep going ahead (as is shown in Fig. 2a), the target server is easily determined, which can be directly selected as the next available server along the road. For the crossroad scene, since there are four driving options for the vehicle at the intersection (as is shown in Fig. 2b): go straight, turn left, turn right, and turn around, thereby the target server is not easy to be chosen. It needs to combine the actual traffic conditions, navigation, and other perception information to make prediction judgments [14,15].
This part introduces three ideas to design the migration strategy [16,17]. In the migration scenario of single-vehicle and single-application, this paper focuses on the migration scenario of crossroads. For vehicles that are on the edge of crossroads and are about to undergo application migration, based on the acquired vehicle trajectory data, this paper considers three selection standards: The first is the nearest selection method: select the available edge server closest to the connected vehicle at the current time as the target server.
The second is the local optimal method: select the available edge server with the least migration cost at the current time as the target server.
The third is the dynamic programming method: select the next-turn edge server corresponding to the migration path that minimizes the total migration cost in the future limited observation time as the target server.
This paper proposes the third one, the dynamic programming method. Based on the goal of minimizing the total migration cost, to design the migration model (in Section 2.2) and migration algorithm (in Section 3) and then compare the third method with the first and the second method (in Section 4).

Model Building
First, make some definitions. Set the time slot t ¼ 1; 2; 3; . . ., the length of each time slot is s. The driving trajectory in the time slot t is LðtÞ. The maximum tolerable delay of the vehicle application m is D max . Considering the urban road scene, suppose that there are N edge servers in the edge network of a certain area. Define a matrix p with a dimension of Q Â N, and use it to represent the application deployment in consecutive Q time slots, where the value of the matrix elements can only be 1 or 0. For example, the matrix element p t;n ¼ 1 means that the application is deployed on the edge server n in the time slot t. Otherwise, p t;n ¼ 0 means that the application is not deployed on this server. In this way, obtain the migration situation of the application by observing the changes in the values of the two adjacent elements of the matrix p , i.e., the matrix p represents the migration decision in consecutive Q time slots, and pðt; t þ 1Þ represents the migration decision of two consecutive times. Define some indicators and parameters as follows: (1) Communication delay (a) Transmission delay where m;n represents the amount of data packets sent by the migrating application; g L t ð Þ represents the maximum data transfer rate between the connected source and target edge servers; D extra represents additional costs such as queuing delay.
where ' m represents the calculation demand of the data packet sent by the application; E m;n represents the amount of bits that the target edge server can process for the application in each time slot; D queue represents the queuing delay.
In summary, define the communication delay as follows: (2) Migration delay where h m represents the amount of migration data generated by the application migrating from the source edge server to the target edge server; D frozen represents the freezing time of the container during the process of migrating the application.
(3) Target server status In order to avoid service interruption, when performing the migration decision, consider the communication delay and the migration delay and also consider whether the target server can provide enough resource space for the migrating application.
Suppose that the application m needs to occupy bandwidth capacity b m and storage capacity c m . For the source server src and target server dst, represent the current idle bandwidth capacity respectively by B src and B dst , and represent the storage capacity represented by C src and C dst . The changes in the process of migrating the application m from the source server to the target server are as follows: C src ¼ C src þ c m (7) (4) Direction of movement In addition to the above factors, the moving trend of vehicles will also affect the migration decision. Suppose the vehicle moves from point A to point B in unit time t, and define the direction vector from point A to point B as the moving direction of the vehicle at time t, denoted asm t , then express the moving direction of the vehicle at the previous time t À 1 asm tÀ1 . Use the projection ofm t onm tÀ1 to measure their direction consistency, as follows: where Â is the angle between the moving directions of the vehicle at two adjacent times. When the projection value is positive (m t j jcos Â . 0 ), the vehicle's moving directions are considered to be basically the same, and positive feedback is given to the execution of the migration decision; when the projection value is not positive (m t j jcos Â 0 ), it is considered that the moving directions of the vehicle are reversed, and negative feedback is given to the execution of the migration decision.

(5) Optimization problem
Define the cost function as: where C t ð Þ represents the delay of single application migration, and let C t ð Þ D max . Besides, the following prerequisites should be met: The above formulas show that the migration decision is meaningful only when the target server has sufficient resource space for the migrating application and the vehicle follows the direction of driving away from the local service domain. This paper takes a limited time T to represent the long-term time. Then the long-term total cost is defined as: Then the optimization problem can be expressed as: This problem can be converted into the shortest path problem and use dynamic programming to solve it.

Dynamic Programming Migration Algorithm
This section introduces the design process of the migration algorithm based on dynamic programming. Define all possible deployment schemes of pðtÞ as set H , and then there are at most N elements in this set (N is the number of edge servers). Define vectors r ¼ p t ð Þ and l ¼ pðt À 1Þ , r 2 H and l 2 H , to represent the application deployment situation at the current time and the previous time, respectively. Define sets H cur H and H pre H to record the effective deployment schemes which meet the constraints at the current time and the previous time, respectively. Define variable g x to represent the sum of CðtÞ from time t 0 to the current time when the application deployment is x and the application deployment is optimal until the current time. Define variable d x to represent the sum of CðtÞ from time t 0 to the previous time when the application deployment is x and the application deployment is optimal until the previous time. Define vectors p x and q x to respectively cache the optimal migration strategy from time t 0 to the current time and the previous time when the application is deployed as x. Suppose the initial position of the connected vehicle is Lðt 0 À 1Þ, the trajectory result of the vehicle in the next T time is Lðt 0 ; . . . ; t 0 þ T À 1Þ , and the initial application deployment is p t 0 À 1 ð Þ . The process of application migration algorithm using dynamic programming to select the optimal strategy is as follows: When the initial state p t 0 À 1 ð Þ is determined, for all effective deployment schemes x 2 H cur at the current time slot t 0 , to establish a state transition relationship for subsequent iterative multiplexing. According to the constraints, put the deployment solutions that meet the conditions in the set H cur . For each deployment situation in the set H cur , obtain the optimal migration solution from the previous time slot to the current time slot by solving the Bellman equation, cache the optimal migration strategy (i.e., the deployment matrix) up to the last time slot and calculate the sum of C t ð Þ up to the last time slot for subsequent multiplexing. Through T iterations, seek the deployment solution r Ã that minimizes the total cost C (i.e., the sum of C t ð Þ), and return to its corresponding migration decision matrix p r Ã , then locating the current time slot to obtain the best migration decision.

Parameter Value
The values of the model parameters used in this experiment are shown in Tab. 1.
This experiment randomly generated 20 sets of data to form the data transmission rate matrix g LðtÞ in the range of [4,20] Mbps, and thus 20 sets of simulation experiments were carried out. The problem of finding the optimal migration decision based on dynamic programming is equal to the shortest path problem. The graphshortestpath function in MATLAB can be used to visually display the migration path, as is shown in Fig. 3 (only show the first group of simulation results as an example).
In Fig. 3, the node number corresponds to the number of the edge server, the weight between the two nodes represents the migration cost from the previous node (i.e., source server) to the next node (i.e., target server), and the red line indicates the shortest path from the start point to the endpoint, which is the global optimal solution for the migration decision, and then track the path can get the best migration choice at every moment.

Results Analysis
(1) Total migration times As is shown in Fig. 4, in this experiment, the total migration times of DPMA remain at 4, the total migration times of NRMA remain at 6, and the total migration times of LOMA fluctuate between 4 and 7. Since the application migration process will inevitably consume resources and might cause network faults or service interruptions, theoretically, in order to reduce latency, save consumption, and improve network stability, so make the migration times as few as possible.
(2) Total migration cost and long-term average total cost As is shown in Fig. 5, the total migration cost generated by DPMA and NRMA does not fluctuate much, while the total migration cost of LOMA fluctuates greatly. In addition, the long-term average total cost of the three algorithms is shown by dashed lines in Fig. 5. The comparison shows that the long-term average total cost of DPMA is 33.88% and 24.53% lower than NRMA and LOMA, respectively.
(3) Average single migration cost The standard of LOMA is to select the target server with the least migration cost at the current migrating moment, so in most cases, its value of the cost that averages to a single migration is the smallest (as is shown in Fig. 6).  However, LOMA is easy to fall into the local optimal deadlock (as is shown in Fig. 7). That is, the local optimal migration choice at the current moment may cause negative impacts on the migration choice at the later moment and eventually consume more migration costs.

Experiments Summary
In summary, the container application migration algorithm based on dynamic programming can ensure the minimal total migration cost and the minimal total migration times, as well as, it can adapt to different network channel capacity conditions. Therefore, it is suitable for single vehicle and single application migration scenarios. The comparative analysis of DPMA, NRMA and LOMA is shown in Tab. 2:

Conclusions
This paper builds a container application migration model based on edge computing in the IoV business scenario, uses time delay to measure the migration cost, divides the migration cost into communication delay and migration delay, and considers the target server status and vehicle movement trends to judge whether to perform the migration decision. Then, this paper designs an application migration algorithm based on dynamic programming and uses the shortest path principle to obtain the global optimal solution of the migration decision. Finally, the simulation experiments show that the long-term average migration cost of the dynamic programming migration method proposed in this paper is significantly lower than the other two migration algorithms used for comparison, i.e., the dynamic programming migration method performs better.
The future research work would consider the migration scenarios of multiple vehicles and multiple applications.
Acknowledgement: The work is supported by the Science and Technology Project of State Grid Zhejiang Electric Power Co., Ltd (5211XT19006F).
Funding Statement: The authors received no specific funding for this study.

Conflicts of Interest:
The authors declare that they have no conflicts of interest to report regarding the present study.