## 4 Workload and Data Center Modeling
### Analytical Modeling Approach
#### 4.1.1 Workload Modeling
In Google traces, it is clear the demand has a bell shape curve during time intervals with some skew to the left or right, as in Figures 2 and 3. As we investigated in our previous work [40], the number of submitted jobs and their tasks during one time window are counted as workload characteristics for the scaling time slot. However, in Alibaba trace, it is clear that the Gaussian random distribution is not the best representation. The shape of the trace is more triangle, which means the best distribution is Triangular distribution, as can be seen in Figures 5 and 6. \[ \begin{split} P(J_{st}(j))&=\frac{1}{\sqrt{2\pi }\sigma_{j}}e^{\frac{-(j-\mu_{j})^{2}}{2\sigma_{j}^{2}}},\\ P(T_{st}(i))&=\frac{1}{\sqrt{2\pi}\sigma_{i}}e^{ \frac{-(i-\mu_{j})^{2}}{2\sigma_{i}^{2}}}.\end{split}  \tag{7}\]  
The sample mean of the jobs and tasks \(\mu=\bar{x}\) and variance \(\sigma^{2}=s^{2}\) are found statistically, as given by Equation (8). The values of the mean and variance are updated in each time window to be used in the next window prediction. This makes the system adaptive to changes. The vector variables \(J_{st}(j)\) and \(T_{st}(i)\) specify submitted jobs and tasks, and their numbers are referenced by a continuous index. The number of submitted jobs \(J_{st}\) and number of submitted tasks \(T_{jt}\) are found from the length of their vectors. The total number of jobs \(J=\sum_{t=1}^{CT}J_{st}\) and the total number of tasks \(T=\sum_{t=1}^{CT}T_{st}\) are found statistically from the trace log and maintained cumulatively. \[ \begin{split}\bar{x}_{J}=\frac{1}{CT}\sum_{t=1}^{CT}J_{st},\ s_{ j}^{2}=\frac{\sum_{t=1}^{CT}(J_{st}-\bar{x}_{J})^{2}}{J-1},\\ \bar{x}_{T}=\frac{1}{CT}\sum_{t=1}^{CT}T_{st},\ s_{T}^{2}=\frac{ \sum_{t=1}^{CT}(T_{st}-\bar{x}_{T})^{2}}{T-1}.\end{split}  \tag{8}\]  
In task \(i\) of job \(j\), \(R_{ij}\) is the requested resources vector modeled by a uniform probability distribution. The requested granular resource units are similar because the minimum demand resource vector units are fixed, such as for database query or response web servers. The random variable expected value \(E(X)\) is used in Equation (9) to find the resource vector for submitted task \(R_{ij}\) and ended task \(RE_{i}\), which is equal to one resource unit if uniformly distributed. \[RE_{i}=R_{ij}=E(R_{ij})=\frac{(R_{ij(t+T_{w})}+R_{ijt})}{T_{w}}. \tag{9}\]At each time window, the number of ended tasks is a Gamma distribution model, as depicted in Equation (10). The events that happened follow a Gamma distribution, where the number of ended tasks out of the total submitted tasks needs to be found. Tasks that ended within the time constraint and occurrences are modeled using a Gamma distribution with two parameters, \(\lambda\) and \(r\), called scale and shape, respectively. In a Gamma distribution, \(\lambda\) is an important attribute, which, when found statistically, can be used to define the mean \(\mu_{\Gamma}=\frac{r}{\lambda}\) of the population, and \(r\) is the number of events (in our case, \(r=T_{et}\) out of \(T_{st}\)). The similarity in this case between Google tasks and Alibaba instances is the same type of distribution. \[ \begin{split}\Gamma(T_{et})=\int_{t=1}^{T_{w}}{(T_{st})^{(T_{et}- 1)}e^{-(T_{st})}dT_{st}},& T_{st}>0,\\ P(T_{et})=\frac{\lambda^{T_{et}}T_{st}{(T_{et}-1)}e^{(-\lambda \ T_{st})}}{\Gamma(T_{et})},& T_{st}>0.\end{split}  \tag{10}\]  
There are two cases for ended tasks \(T_{et}\). Type one is the tasks that are completed and finished, normally \(T_{cft}\), where the allocated resources are permanently released. Type two (\(T_{net}\)) is the tasks that end before completion and are not terminated normally. These tasks will be resubmitted \(T_{re}\) to the next time window. A hypergeometric distribution is used to describe \(T_{net}\) tasks that are not finished normally as a probability ratio of failure to success tasks in the submitted tasks batch (\(T_{ret}=T_{s(t-1)}-T_{cf(t-1)}\)) without any order, as Equation (11) depicts.