# Providing Predictable Quality of Service in a Cloud-Based Web System
## 3 Web Cloud Earliest Deadline First Method and Web Switch
### Switching Section  
After leaving the scheduling section, the request \(r_{i}\) is passed to the switching section. This section distributes HTTP requests among web switches in the availability zones. The request is processed in this section as follows--first, the service time is estimated for each availability zone in the system, then the section makes a decision as to which zone should service the request. In most cases, the most loaded zone is chosen only if it is able to service the request within the time constraints. In the next step, the request is sent to the chosen zone. After finishing the service, the response is sent back to the switching section. The section measures the service time and load of the system. It also updates information about service times. In the end, the response is sent to the client. The switching section contains three types of modules--zone model, decision, and execution modules. The number of zone model modules is equal to the number of availability zones in the cloud. Each zone model corresponds to one zone. The zone model is responsible for estimating service time \(\widetilde{t}_{ki}^{w}\) of \(r_{i}\)th request for corresponding \(w\)th zone, where \(we[1,\ldots,W]\). The estimation is done based on the information of the load of the zone \(M_{i}^{w}\ =\ \big{[}e_{i}^{w},f_{i}^{w}\big{]}\), where \(e_{i}^{w}\) is the overall number of requests being currently serviced by the zone, and \(f_{i}^{w}\) is the number of serviced dynamic requests. The load \(M_{i}^{w}\) is collected by the executor module. The zone model adapts to the changing environment, after the request's service, by taking into account the measured service time \(\widetilde{t}_{i}\), only if the corresponding zone was chosen to service the request. The model owes its adaptation capabilities to the use of a fuzzy-neural mechanism. The module's fuzzy logic structure is based on the Mamdani model [45], and it allows the calculation of the service time on the basis of the load, while the neural nature of the module permits it to tune its parameters. The structure of the presented model is described in detail in [41] and it is used in the WCEDF switch due to its advantages, including good quality of time estimation and the possibility of adaptation to the changing environment. The structure of the neuro-fuzzy network used in the zone model is presented in Figure 2(a). Superscripts indicating the executor's number (w) have been omitted in the figure as well as in the other markings in the rest of the description of the zone model. Inputs for the neuro-fuzzy network are the load of the zone \(e_{i}\), \(f_{i}\), and the class \(k_{i}\) of the request, while the output is the estimated service time \(\hat{t}_{ki}\). The model parameters are stored in the database \(Z_{i}\ =\ [Z_{1i},\ldots,Z_{ki},\ldots,Z_{ki}]\), where \(Z_{ki}\ =\ [C_{ki},D_{ki},S_{ki}]\), \(C_{ki}\ =\ [c_{1 ki},\ldots,c_{lik},\ldots,c_{Lki}]\), and \(D_{ki}\ =\ [d_{1 ki},\ldots,d_{mki},\ldots,d_{Mki}]\) are input fuzzy set function parameters and \(S_{ki}\ =\ \begin{bmatrix}s_{1 ki},\ldots,s_{jki},\ldots,s_{jki}\end{bmatrix} \) are output fuzzy set function parameters. The parameters can change in time and the index \(i\) in the database indicates the state at the moment of arrival of the \(r_{i}\)th request. A different set of parameters is used in the fuzzy system for each class \(k\), \(k\ =\ 1,\ldots,K\). Therefore, there are \(K\) different sets and it can be considered as \(K\) different fuzzy-neural models in each zone model. The fuzzy set functions for input \(e_{i}\) are \(\mu_{F_{d}}(e_{i})\), \(l\ =\ 1,\ldots,L\), and for input \(f_{i}\) are \(\mu_{F_{fm}}(f_{i})\), \(m\ =\ 1,\ldots,M\). Figure 2(b) presents the triangular shape of functions \(\mu_{F_{d}}(e_{i})\) and the meaning of parameters \(c_{1 ki},\ldots,c_{lik},\ldots,c_{Lki}\). Functions \(\ \mu_{F_{fm}}(f_{i})\) have a similar shape and meaning to parameters \(d_{1 ki},\ldots,d_{mki},\ldots,d_{Mki}\).