# An Approach for Deployment of Service-Oriented Simulation Run-Time Resources
## 4 System Model and Problem Formulation
### Time Cost Model  
#### 4.2.1 Service Response Model  
In terms of service response, we consider two factors: the network communication time between users and servers and between tasks; the queuing time of tasks at their corresponding instances calculated by \(M/M/c\) queuing model, where \(c\geq 1\).  
* Service communication model: Without the loss of generality, we assume that a \(j\)-th type of service request \(S_{ij}\) from user \(U_{i}\) is always first scheduled to \(R_{U_{i}}(t_{ijl})\) to process the initial task \(t_{ijl}\), for \(\forall i=1,\cdots,u\) and \(\forall j=1,\cdots,m\). The data size from \(U_{i}\) to \(R_{U_{i}}(t_{ijl})\) is \(ms^{in}_{tms_{ijl}}\). Subsequently, each task \(t_{ijk}\) after \(t_{ijl}\) will be scheduled to \(R(t_{ijk})\) in topological order, and the data dependency scale between this task and its predecessor task \(t_{ijp}\) is \(ms^{trs}_{pk}\). When the service request is finished, the result, i.e., the output of \(t_{ijr}\) is sent to user \(U_{i}\). Therefore, the communication time caused by the service request \(S_{ij}\) is \[t^{C}_{ij}=\lceil\frac{a_{in}}{a}\rceil\frac{ms^{in}_{tms_{ijl}}}{BW}+\sum_{k =2}^{N_{S_{ij}}}\sum_{t_{ijp}\in\textit{prod}(t_{ijk})}\lceil\frac{a_{R(t_{ijp }),R(t_{ijk})}}{a}\rceil\frac{ms^{trs}_{pk}}{BW}+\lceil\frac{a_{out}}{a} \rceil\frac{ms^{out}_{tms_{ijl}}}{BW}\] (2) where \(a_{in}=a_{R(U_{i}),R_{U_{i}}(t_{ijl})}\) and \(a_{out}=a_{R_{U_{i}}(t_{ijr}),R(U_{i})}\). \(N_{S_{ij}}\) represents the number of small tasks in this request and \(a\) and \(BW\) are the network distance of one hop and the network bandwidth, respectively. In the network environment uniformly configured for training simulations, they are all constants.
* Service queuing model: If a task is scheduled to a busy instance, it will suffer a long queuing time. To simplify the problem without the loss of generality, we assume that the calculation time of all MS instances is consistent, which is equal to \(\mu\). Thus, the waiting time of task \(t_{k}\) is calculated by \(M/M/c\) queuing model as \[t^{W}_{k}=\frac{\rho_{k}c^{\chi_{k}+1}p_{k}}{\lambda_{k}(c_{k}-1)!(c_{k}-\rho _{k})^{2}}\] (3) where \(\lambda_{k}\) represents the arrival rate of tasks of the same type as \(t_{k}\) and \(\rho_{k}=\lambda_{k}/\mu\leq 1\). \(c_{k}\geq 1\) indicates the number of instances that can process \(t_{k}\) deployed on the current server. Note that if a task is scheduled to the cloud rather than an edge server, we ignore its queuing time but emphasize the data transmission time. The parameter \(p_{k}\) that can be calculated as \[p_{k}=(\sum_{n=0}^{c_{k}-1}\frac{\rho_{k}{}^{n}}{n!}+\frac{\rho_{k}{}^{c_{k}} }{c_{k}!}\frac{c_{k}}{c_{k}-\rho_{k}})^{-1}\] (4) Therefore, the total queuing time of all tasks in the \(j\)-th type service request from user \(U_{i}\), \(S_{ij}\), can be represented as \[t^{W}_{ij}=\sum_{k=1}^{N_{S_{ij}}}t^{W}_{ijk}\] (5)Based on the proposed service communication model and service queuing model, the total data transmission time caused by users' service requests can be formulated as  
\[t^{S}=\sum_{i=1}^{u}\sum_{j=1}^{m}d_{ij}(t^{C}_{ij}+t^{W}_{ij}) \tag{6}\]  
where \(d_{ij}\) represents the demand for service request \(S_{j}\) of \(U_{i}\).