# Profit-Efficient Elastic Allocation of Cloud Resources Using Two-Stage Adaptive Workload Prediction
## 5 Cloud Resource Allocation Policy Based on Maximum Cloud Service Profit  
### Task Processing Modeling in the Cloud Service  
As shown in Figure 2, the cloud resource pool is composed of VMs. Each VM in the resource pool is run in a target physical server, and the computing resources of the VM are abstracted by the virtualization layer and presented as vCPU, vMemory, and vNetwork, as shown in Figure 13. When a task arrives at the VM, it is buffered and queued in the memory of the VM. Next, the tasks are processed by the vCPU according to the first-in-first-out (FIFO) service policy. If the task cannot be completed within the deadline, it will be dropped from the VM. To obtain enough revenue, most cloud services, such as AWS, Rackspace, and Aliyun, schedule resources and set the billing interval to one hour, which is the same as the workload monitoring interval. Thus, some methods based on a real-time queueing model or a short time slot may not be suitable for cloud center resource management. Based on previous research [36; 37; 38; 39], although the workload of the Wikimedia service does not follow the homogeneous Poisson distribution in one-hour intervals, the workload with a small time slot of one hour follows a uniform Poisson distribution. Let \(\Delta_{\tau}\) denote a small time slot of one hour. Based on the theoretical analyses in previous research [40; 41], we assumed that the task length (i.e., the instruction length) follows an exponential distribution, which can be obtained from the statistics of historical tasks completed by the cloud service. Therefore, the task execution time also follows an exponential distribution. Overall, in a small time slot \(\Delta_{\tau}\), the task process in the VM can be presented using the M/M/1/K queueing model, which follows the first-come-first-served policy. In the M/M/1/K model, \"1\" represents one processing unit (i.e., one VM has one vCPU), and K represents the task queueing length. If the task queueing length exceeds K, the task will be lost. According to the QoS deadline, K can be calculated as follows:  
\[\text{K}=\frac{dp^{max}}{\overline{e}t}, \tag{12}\]  
Figure 13: Structure of the task processing queueing model in virtual machines (VMs). where \(dp^{max}\) is the maximum allowed processing time of the task, which is the maximum allowed processing time interval between the time when the task arrives at the VM and its deadline, and \(\overline{ct}\) is the average task execution time in the vCPU. According to the average task execution time (i.e., \(\overline{et}\)), the average number of tasks that are processed by the vCPU of the VM in time slot \(\Delta_{\tau}\) can be calculated as follows:  
\[\mu=\frac{\Delta_{\tau}}{\overline{et}} \tag{13}\]  
The system load of the VM in time slot \(\Delta_{\tau}\) can be calculated as follows:  
\[\rho(\Delta_{\tau})=\frac{\overline{\lambda(\Delta_{\tau})}}{\mu}, \tag{14}\]  
where \(\overline{\lambda(\Delta_{\tau})}\) is the task arrival rate in time slot \(\Delta_{\tau}\). The task loss ratio of the M/M/1/K model can be calculated as follows:  
\[P_{loss}(\Delta_{\tau})= \begin{cases}\frac{1-\rho(\Delta_{\tau})}{1-\rho( \Delta_{\tau})^{K+1}}\cdot\rho(\Delta_{\tau})^{K},\rho(\Delta_{\tau})\
eq 1\\ \frac{1}{1+K^{\prime}}\rho(\Delta_{\tau})=1\end{cases} . \tag{15}\]  
Thus, in time slot \(\Delta_{\tau}\), the actual task arrival rate (i.e., the average number of task arrivals) of the VM is as follows:  
\[\overline{\lambda_{e}(\Delta_{\tau})}=\overline{\lambda(\Delta_{\tau})}\cdot [1-P_{loss}(\Delta_{\tau})]. \tag{16}\]  
Furthermore, the average number of lost tasks can be calculated as  
\[\overline{\lambda_{loss}(\Delta_{\tau})}=\overline{\lambda(\Delta_{\tau})} \cdot P_{loss}(\Delta_{\tau}). \tag{17}\]  
Thus, the actual system load is as follows:  
\[\rho_{e}(\Delta_{\tau})=\frac{\lambda_{e}(\Delta_{\tau})}{\mu}. \tag{18}\]  
The average task response delay in time slot \(\Delta_{\tau}\) is calculated as follows:  
\[\mathrm{W}_{s}(\Delta_{\tau})=