# Profit-Efficient Elastic Allocation of Cloud Resources Using Two-Stage Adaptive Workload Prediction
## 5 Cloud Resource Allocation Policy Based on Maximum Cloud Service Profit
### Maximum Cloud Service Profit Resource Allocation Method  
Let \(C=[C_{1},C_{2}]\) represent the VM rental cost (\(C_{1}\)) and task profit (\(C_{2}\)). The cloud service profit in time slot \(t\) can be calculated as follows:  
\[Profit(t)=m\cdot N_{v}(t)\cdot\left[C_{2}\cdot\overline{\lambda(\Delta_{\tau} )}-C_{2}\cdot\overline{\lambda_{loss}(\Delta_{\tau})}-C_{1}/m\right], \tag{22}\]  
where \(C_{1}\cdot\overline{\lambda(\Delta_{\tau})}\) represents the total task profit per VM in time slot \(\Delta_{\tau}\), \(C_{2}\cdot\overline{\lambda_{loss}(\Delta_{\tau})}\) is the task profit loss of each VM in time slot \(\Delta_{\tau}\), and \(C_{1}/m\) is the rental cost of each VM in time slot \(\Delta_{t}\). Thus, the term \(\left[C_{2}\cdot\overline{\lambda(\Delta_{\tau})}-C_{2}\cdot\overline{ \lambda_{loss}(\Delta_{\tau})}-C_{1}/m\right]\) represents the cloud service profit of each VM in time slot \(\Delta_{\tau}\). In the cloud service, the profit of a service is important for the development of the Internet. Thus, maximization of the profit of the service is the optimization objective considered in this study; that is, the cloud service profit is used as the optimization objective. Additionally, we also need to guarantee the QoS provision (i.e., deadline requirements) and system stability. Thus, the optimization objective is presented as follows:  
\[ \begin{array}{l}\text{Maximize }Profit(t)\\ \text{s.t. }W_{s}(\Delta_{t})\leq dp^{max},\ \rho_{e}(\Delta_{t})<U^{max},\end{array}  \tag{23}\]  
where \(dp^{max}\) is the maximum allowed processing time of the task, and \(U^{max}\) is the maximum allowed system load of a VM. In Equation (23), \(\lambda(\Delta_{\tau})\) denotes the arrival rate from the Internet; therefore, \(\lambda(\Delta_{\tau})\) is a determined number that cannot be affected by the system. Thus, the cloud service profit is affected by the task loss and VM rental costs (i.e., the cloud service costs). The objective in Equation (23) can be transferred to minimize the cloud service costs as follows:  
\[ \begin{array}{l}\text{Minimize }Cost(t)=N_{v}(t)\cdot m\cdot\left[C_{1}/m+C_{2} \cdot\overline{\lambda_{loss}(\Delta_{\tau})}\right],\\ \text{s.t.}W_{s}(\Delta_{\tau})\leq dp^{max},\ \rho_{e}(\Delta_{\tau})<U^{max}. \end{array}  \tag{24}\]  
Notably, the convex property of Equation (24) is also affected by the task loss and VM rental costs. It is assumed that \(m=36,000\), the average task execution time is 5 ms, and the maximum allowed processing time for a task is 100 ms. According to Amazon's VM rental price, the rental cost of a VM is RMB 1.2179 per hour. There are three cases with different task profits, as follows:  
1. High task profit: Due to the typical high load of the Wikimedia service (the workload of the task arrival can be on the order of \(1\times 10^{7}\)), we first assume that the task profit is RMB 0.01. Thus, the task loss becomes the main element that affects the cloud service cost, rather than the rental cost of VM. To reduce the cloud service cost, we need to allocate enough VMs to reduce the cost of task loss. Thus, the cloud service cost decreases rapidly when the number of VMs increases. When the number of VMs becomes redundant, the cloud service cost increases slowly. The cloud service cost is a weakly convex function, as shown in Figure 14.
2. The low task profit: We next assume that the task profit is 0.000001. Thus, the rental costs of VMs become the main element affecting the cloud service cost. In this case, the optimization resource allocation strategy uses the smallest number of VMs; that is,one VM. Thus, the cloud service cost is a monotonic increasing function, as shown in Figure 15.
3. The medium task profit: Compared to the previous two cases, we then assume that the task profit is 0.00001, which means that the task profit and the rental costs of VMs both affect the cloud service cost. In this case, when the number of VMs increases, the task loss decreases but the rental costs of VMs increase, and vice versa.