# Task Scheduling Mechanism Based on Reinforcement Learning in Cloud Computing
## 3 System Model
### Stage 1: Task Allocation  
In the first stage of task allocation, we first assign each task to a server that is suitable for processing that type of task.  
As shown in Figure 1, A cloud data center can have a large number of servers, usually hundreds or thousands. Due to the nature of the cloud data center and the diversity of user requests, we chose to implement a scheduling program based on task type in the first stage of QMTSF. A GQ is used in the cloud data center to buffer all incoming user requests. The task dispatcher continuously monitors and manages unfinished user requests and takes timely action to assign them to each server node for processing. If the task assignment process fails, the task is re-added to GQ and waits for reassignment.  
In the cloud environment, multiple users generate different types of task processing requests. Each task that arrives at the cloud data center contains information, such as the task type, deadline, task size, etc. Due to the complexity and diversity of the cloud  
Figure 1: QMTSF stage one: task allocation.  
environment, there may be different types of user task requests, such as video tasks, voice tasks, text data analysis tasks, etc. How to allocate different task requests to suitable servers for processing is an important optimization problem in cloud computing.  
As shown in Figure 1, in the first stage of QMTSF, tasks are classified and assigned initial values based on the actual situation of the cloud environment. Then, based on the specific information of each server in the cloud data center, such as CPU, memory, bandwidth, processing speed, network location, etc., the processing priority of each server for its task category is set. Finally, an update interface is provided in the system to update the task category processing priority of servers at any time when a new task type arrives. Task classification in the cloud environment is dynamically generated and updated. When a cloud data center receives a new task, it first looks up the _Task_Type_Prio_ table to check whether the task type already exists. If it does, the task is allocated based on the algorithm described in Section 4. If the task type does not exist, the processing time for the task is calculated based on the task size and the processing speed of each server. Subsequently, priority values for this task type on different servers are generated, a new record is added to the _Task_Type_Prio_ table for each server, and the value is updated for the entire table.  
For example, in a cloud environment with L task categories, we set the task categories as follows: \(VIDEO\_TASK=0,VOICE\_TASK=1,\ldots,TEXT\_TASK=L\). The task category priority of any server in the cloud data center is an L-dimensional tuple _Task_Type_Prio_, indicating which type of task the server is suitable for processing. In actual task allocation, the task category priority of each server is searched to find the most suitable server for processing the task and allocate the task to it. If all suitable servers are already allocated or if no suitable server is found, the task is allocated to the server with the next lower priority task category, and so on. Assuming that the priority tuple of a server i is \(Task\_Type\_Prio_{i}=<L,1,\ldots,0>\), this means that server i is most suitable for processing text data analysis tasks, followed by voice tasks, and least suitable for processing video tasks. Because the task classification of servers in the cloud environment is closely related to the actual situation of the cloud environment, in this article we focus on using reinforcement learning to schedule tasks when tasks are allocated from servers to VMs. Therefore, the actual situation of task classification is not described in detail in this article. However, we provide a priority update interface for the dynamic expansion of task categories in the later stage of implementation. A detailed description of the algorithm is provided in Section 4.