On Little’s Formula in Multiphase Queues

: The structure of this work in the ﬁeld of queuing theory consists of two stages. The ﬁrst stage presents Little’s Law in Multiphase Systems (MSs). To obtain this result, the Strong Law of Large Numbers (SLLN)-type theorems for the most important MS probability characteristics (i.e., queue length of jobs and virtual waiting time of a job) are proven. The next stage of the work is to verify the result obtained in the ﬁrst stage.


Introduction
Interest in the field of multiphase queueing systems has been stimulated by the theoretical values of the results, as well as by their possible applications in information and computing systems, communication networks, and automated technological processes. The investigation methods of single phase queueing systems are provided in [1][2][3]. The asymptotic analysis of queueing systems in heavy traffic models are of special interest (see, for example, in [4][5][6][7]). The papers [8,9] describe the research start of diffusion approximation relative to queueing networks. Intermediate models-multiphase queueing systems-are considered rarer due to serious technical difficulties (see, for example, book [10]).
In this paper, we present a survey of articles issued between 2010 and 2021 that investigate heavy traffic networks. In [11], a multiclass queueing system was investigated-we consider a heterogeneous queueing system to consist of one large pool of identical servers. The arriving customers belong to one of several classes, which determines the service times in the distributional sense. In [12], a class of multiclass networks was analyzed-a class of stochastic processes known as semi-martingale reflecting Brownian motions is often used to approximate the dynamics of heavily loaded queuing networks. In [13], a model of approximation of resource sharing games was developed. In [14], the problem of scheduling in queueing networks was analyzed. In [15], a model of parallel multiclass queues was investigated. The model of input queued switch operation was analyzed in [16]. In [17], the stationary distribution was investigated. The authors justified the steady-state diffusion approximation of a generalized Jackson network in heavy traffic. Their approach involves the so-called limit interchange argument, which has since become a popular tool and has been employed by many others who study diffusion approximations. A survey of stochastic network analysis was presented in [18]. In [19], MapTask scheduling in heavy traffic optimality is analyzed. In [20], the authors investigate the departure process in open queuing networks. The delay process is analyzed in [21]. Motivated by the stringent requirements on delay performance in data center networks, the authors study a connection-level model for bandwidth sharing among data transfer flows, where file sizes have phase-type distributions and proportionally fair bandwidth allocation is used. In [22], universal bounds are investigated. In [23], the load balancing policy problem in heavy traffic was developed. In [24], the MaxWeight 23 scheduling algorithm is considered. Our paper on SLLN in MS is one of the first works in this area.
The study of generalized networks can be traced back to their namesake [25,26], who considered networks with inputs and exponential service times and showed that the invariant probability for the process has a simple product form. The foregoing assumptions on the arrival streams and service times were made to greatly simplify the analysis of these networks. Relaxing these assumptions was the subject of the work by Borovkov [27], where a model similar to Markovian network is considered. The finite buffer case is treated in Konstantopoulos and Walrand [28], and general point process arrival streams and general service processes are considered for networks without feedback [29].
We will next present some definitions in the theory of metric spaces (see, for example, [30]). Let C be a metric space consisting of real continuous functions in [0, 1] with a uniform metric of the following.
Let D be a space of all real-valued right-continuous functions in [0,1] having left limits and endowed with the Skorokhod topology, induced by the metricd (under which D is complete and separable). Moreover, note thatd(m, n) ≤ρ(m, n) for m, n ∈ D. In this paper, we constantly use an analog of the theorem on converging together (see, for example, [30]).
There is one service device in each phase of the MS; the service discipline is FCFS (i.e., first come, first served). Service time distribution and the incoming flow of jobs to the first phase of the MS are both common. We investigate here an x-phase MS (i.e., when a job is served in the ith phase of MS, it proceeds to the i + 1 phase of MS, and it leaves MS after the job has been served in the x-phase of MS). Let us denote the time of arrival of the kth job by t k . The service time of the kth job in the ith phase of MS is denoted by S Z j ≤ t} (number of jobs that arrive at MS until the time moment t).
Next, we denote the number of jobs by σ i (t) after service departure from the ith phase of MS until the time t; the queue length of jobs by Q i (t) in the ith phase of MS at the time moment t; u i (t) = ∑ i j=1 Q j (t), i = 1, 2, . . . , x, and t > 0. Let inter-arrival (Z k ) at MS and service times (S (i) k ) in each phase of MS for i = 1, 2, . . . , x be mutually independent and identically distributed random variables.

SLLN for the Queue Length of Jobs in MS
One of the main results of this paper is a theorem on SLLN for the summary length of jobs in MS.
Theorem 1 (SLLN for the summary length of jobs in MS). If conditions (2) are fulfilled, then the following is the case.
From (8) and (9), we obtain the following: for i = 1, . . . , x, s > 0. Forε > 0, we derive the following: In addition, note that the following is the case: almost everywhere for i = 1, . . . , x (see [31]). Thus, similarly as in [31], we prove that the second item in (11) also tends to zero. Thus, we obtain that forε > 0, the following is the case.
Using the convergence together theorem (see, for example, [30] and (13)), we complete the proof of the theorem.
The theorem on SLLN for the queue length of jobs is proved similarly as Theorem 1.
Theorem 2 (SLLN for the queue length of jobs in MS). If conditions (2) are fulfilled, then the following is the case.
Using the convergence together theorem (see, for example, [30] and (14)), we complete the proof of the theorem.

SLLN for the Virtual Waiting Time of a Job in MS
In this section, we present the proof of Little's formula in MS. The main tools in proving this fact are SLLN for the queue length of jobs and the virtual length of a job in MS.
Definitions of the random variables t k , Z k , S (i) k , e(t), and m i (t) for i = 1, 2, . . . , x are the same as in the proof of Theorems 1 and 2. Let us defineβ i = ES In addition, let us define V i (t) as a virtual waiting time of a job in the ith phase of MS at time t. Denote S i (s) as the time, that is, the summary service of jobs arriving at the ith phase of MS until time t for i = 1, . . . , x and s > 0. Note If S i (0) = V i (0) = 0, then the following is the case (see [1], p. 41).
V i (s) = f s (n i (· )) for i = 1, . . . , x and s > 0 Thus, we prove a theorem about SLLN for the virtual waiting time of a job in MS.
Theorem 3 (SLLN for the virtual waiting time of a job in MS). If conditions (2) are fulfilled, then the following is the case.
Since it is proven ( (12)), the following is the case.
Pr lim Thus, the first item in inequality (16) tends to zero (see (17)). In addition, we prove that the second item in inequality (16) also tends to zero (see, for example, [4]) (if conditions (2) are fulfilled). Therefore, we apply the limit theorem for a complex renewal process (see, for example, [5]). Thus, the third item in inequality (16) also tends to zero.
We have proven that all of the items on the inequality (16) converge to zero. Thus, we achieve that for each fixedε > 0, the following is the case.

Pr lim
Using the convergence together theorem (see, for example, [30] and (18)), we complete the proof of the theorem.
Finally, we derive the corollary of proved theorems (Little's formula). The formula L = λW (Little's law) expresses the fundamental principle of queueing theory: Under very general conditions, the time-average or expected time-stationary number of customers in a system, L (e.g., the average queue length), is equal to the product of the arrival rate A and the customer-average or expected customer-stationary time each customer spends in the system, W (e.g., the average waiting time). The relation L = λW is very useful because the assumptions are minimal; it applies to other stochastic models in addition to queues; it applies to queueing networks and subnetworks as well as individual queues; it applies to subclasses as well as the entire customer population; and it is remarkably independent of modelling details, such as service disciplines and underlying probability distributions. Moreover, there are extensions of L = λW -the continuous, distributional, ordinal and Central Limit Theorem versions, that enable us to analyze many seemingly unrelated problems.
Corollary 1 (Little's formula in MS). If conditions (2) are fulfilled, then the following is the case.
Proof. At first, we used Theorems 2 and 3 on SLLN for the queue length of jobs and virtual waiting time of a job in MS. Thus, the following is the case.
The proof is complete.

Overview of Similar Simulations
We have investigated many articles in order to find a similar simulation. Although we found many articles on the same topic (MS), only a few of them described the precise simulation. While investigating a similar simulation in many articles, model descriptions have been found but most of them only described the theoretical model using formulas and algorithm block schemes.
Nevertheless, a few software models or simulations have been found. The simulations that we found can be divided into two groups: (1) simulations made with particular software packages; and (2) simulations created as programs using programming languages and/or other programming tools. We can observe that these two directions of research are developing successfully (here, we can mention the recent work on modeling retrial queue systems [32][33][34], etc.).
In [35], the intelligent management system and the expert system are described. The authors describe the architecture of these systems, but no code or other details were provided. In [36], the authors apply SimEvents MATLAB-Simulink and describe the block scheme of their model. However, no programming code or details were provided.
In [37], the authors reviewed the popular simulation software, such as GPSS World, AnyLogic, and Arena environments. In the authors' opinion, these software packages could make any simulation process very long and expensive because they are not optimal for such a simulation and are mostly used for business process simulations. In addition, most of them are commercial. Therefore, the authors decided to use their own neural network model, but no details were provided.
In [38], a real simulation model created using the Python programming language was described. The authors also provided the programming code. This simulation is described in detail, and all of the Python libraries that were used are provided.
After this review, some conclusions can be drawn:

1.
Commercial models do not meet the requirement to make MS simulations. In addition, they are usually expensive.

2.
None of the provided models meets the requirement to make all of the necessary simulations and experiments.
Consequently, we decided to create our own model that fits all of the requirements, can run on one computer and any operating system, and works in multi-threading mode.

Simulator
To implement the experiment, a Multiphase Queueing System (MS) simulator was created. The Python programming language (version 3.6.9) and its multiprocessing programming library were used. The simulator runs on any operating system that supports the Python programming language. The main new features of this simulator are the following: • Real asynchronous processes that are not dependent on each other; • Possibility to stop simulation at a particular time and not only when all clients are served (as [38]); • Possibility to measure any moment of time: -Client enters MS t k (and also Z k = t k+1 − t k -time between two clients' arrival); -Waiting time V i of each client in every queue; -Service time S (i)k of client k in the ith service of the queue; -Amount of clients Q i (t) in each queue after time t (when the process stopped after time t); • Client proceeds to the consumer process not only after it pass all services (as [38]) but also immediately if MS stopped after the specified time t; • All of the values to be measured are stored in synchronized variables for eliminating their undefined states (some issues could appear because of the operating system, the Python programming language, or hardware errors); • Each service really stops after all of the clients pass away or after the specified time t; • Clients enters the consumer process from any place of MS if it stops after the specified time t. For example, a client cannot pass all of the services or could even be in a waiting queue for one of the services; • All of the calculations are performed, and only then is MS stopped or when all the clients pass through or after the specified time ends.
As shown in Figure 1, the simulator has input (producer process) and output (consumers process) storage and I (configurable) phases in the queue between them. K (configurable) clients created by producer process with random (configurable) time interval between them proceed to the first phase and then, after they have been served there, they proceed to the next phase. Each phase has its own serving time and waiting time before serve. The process continues until the last queue is stopped, after which the client comes to the consumer process.
The main difference in this model is the possibility to stop the simulation after a particular time t (configurable) interval. Imagine that somebody wants to stop the simulation after time t. Then, after the specified time, all of the phases are stopped in the state that they are in and the consumer process collects all of the clients from all of the phases. Here, all the calculations could be performed, including client number in the phase at the moment t.
In this simulation, when it finishes after the specified time t, all clients have their own states and other information, such as the following: • All times between jobs' arrivals to MS; • All service times of all jobs in all queues (where they had time to gain); • All jobs waiting times in all queues and the number of jobs in all queues at time t (when the simulation stopped). All of the measurable parameters of the model are listed in Table 1.

Parameter Description
Client's waiting time before service in the ith phase S i Client's service time in the ith phase Q i Clients amount in the ith phase at the moment t After the model stops, the consumer process performs all of the computations for the values listed in Table 2.

E(V i )
Estimated waiting time before service in the ith phase E(S i ) Estimated service time in the ith phase Q i /t Clients amount in the queue i at time t, divided by t Z k+1 Estimated time between two clients entering MS E(Z) Estimated time between clients on entering MS

Experiment
The experiment results were obtained using this simulation with the following parameters: • Time interval of 15 s (measurements were made each second from 1 to 15); • Five phases in MS; • 100,000 clients received from the producer.
During the experiment, the MS system was stopped at each second, and all of the calculations were made. In each phase, the following is the case: • Q 1 -Q 5 -numbers of clients in all five phases divided by t; • E(V 1 )-E(V 5 )-estimated waiting times in each phase are calculated and divided by t; • Q 1 /V 1 -Q 5 /V 5 ratios for each phase are calculated.
The list of hardware and software used in the experiment is provided in Table 3. The results of calculation ratios Q 1 /V 1 , Q 2 /V 2 , Q 3 /V 3 , Q 4 /V 4 , and Q 5 /V 5 in 1-15 s simulations are provided in Table 4. The ratios mentioned in Table 4 are provided in Figures 2-6, respectively.

Description of the Results
As described in the theory, each Q i /E(V i ) ratio should converge into a constant. This was an expected result-each Q i /E(V i ) ratio after some period of time converges into a constant value or becomes almost stable after some period of time and remains fairly stable for a certain period of time. In the theory, we have an infinite flow of clients, really independent phases, and infinitely large computational resources. In other words, we really have the ideal conditions and no faults or errors.
In reality, this model runs on one computer where there is one processor with real and virtual cores, memory, and storage limits. Under these conditions, some unstable work of the system is present because it is impossible to eliminate all of the faults and errors. A more important point is that the computer's operating system shares resources between processes using its own algorithms, and it can be difficult to allocate the required amount of hardware resources to a particular process.
Another significant problem is the lack of resources, which produces some limitation for any model work (e.g., to have an infinite flow of jobs). Each phase could also be "clogged" with clients when another one is waiting for them. In addition, during the experiment, other restrictions appeared in the current configuration. For example, in theory we need to use the infinite number of clients, but in reality using even 1,000,000 is difficult.
In the real condition, there are some faults and errors in multi-threading libraries when using the Python programming language, and there are some undefined states. Some other mistakes could appear due to the calculation accuracy and time measurement because approximations are used. The lack of resources especially affects measurements of time because the system could lag.
The most expected result is to find a stable interval for every phase where the equilibrium of model load and theoretical conditions are satisfied and to create the experiment where all listed theorems could be checked. A stable time interval should be found for each ratio, in this interval the ratio of Q j /E(V j ) should be the same or very similar.
All of the calculation results for each ratio are listed above. In every chart of each ratio, we can observe the state and the time when the ratio becomes stable or changes a little. Each phase becomes a stable state at a different time period. This could happen because of different times of the critical load and also because of no load for each phase.
For example, the first ratio Q 1 /E(V 1 ) becomes stable after 2 s (4 s value is an issue) and remains stable until 13 s. The second ratio is more stable from 3 to 11 s, the third from 6 to 12, the fourth from 7 to 12, and the fifth is more stable at the beginning but less stable at the end. It is difficult to find a stable period for the fifth (or last) phase because it becomes clogged after all of the other phases are empty or almost empty. When a large flow of clients arrives, the period of stability should begin, but the phase becomes empty very soon. In addition, for this configuration, all clients pass MS at the 14 th second, and all phases become empty.
This experiment result shows that each phase has its own stability period; thus, it could be considered that the ratio of Q j /E(V j ) converges to a constant, as proved in the theory.

Corollary 2 (Validation of Little's formula in MS)
. At this stage of the work, we confirm that the results of the first stage are correct.

•
We observe that the heavy traffic condition used in the proof of the theorems on SLLN is fundamental. Abandoning this condition makes the proof of the theorems very complicated. In the future, it would be interesting to examine the situation under light traffic. • By using another method to prove theorems and normalizing boundary processes differently than compared to SLLN (e.g., probability limit theorems or the law of the iterated logarithm-but this is implicated only in the single-phase case, and there is no research in the multiphase case), Little's law becomes the successful process or becomes its law of the iterated logarithm analog. With SLLN, the boundary process is constant-this process can be modeled. • The theoretical results cannot be directly verified by modeling them, which is evidenced by the modeling block diagram. Modeling has its own explicit specifics; thus, a comprehensive review of the literature in this area was required. • The ideas of the modeling part are related to the often cited work [38]. In this work, for the first time, the modern possibilities of the Python programming language were applied in order to model the queuing system. Continuing this topic, the Python concept was used to test the theoretical results of the first stage. • The first and second parts of this paper deal with similar but completely separate subject areas. As much as possible, efforts were made to bring them closer together and to present them as a single study.