Základy teorie front Mgr. Rudolf B. Blažek, Ph.D. prof. RNDr. Roman Kotecký, DrSc. Katedra počítačových systémů Katedra teoretické informatiky Fakulta informačních technologií České vysoké učení technické v Praze Rudolf Blažek & Roman Kotecký, 2011 Statistika pro informatiku MI-SPI, ZS 2011/12, Přednáška 16 Evropský sociální fond Praha & EU: Investujeme do vaší budoucnos@
Introduction to Queueing Theory Mgr. Rudolf B. Blažek, Ph.D. prof. RNDr. Roman Kotecký, DrSc. Department of Computer Systems Department of Theoretical Informatics Faculty of Information Technologies Czech Technical University in Prague Rudolf Blažek & Roman Kotecký, 2011 Statistics for Informatics MI-SPI, ZS 2011/12, Lecture 16 The European Social Fund Prague & EU: We Invest in Your Future
Random Processes White Random Processes White Random Processes 3
Random Processes White Random Processes White Random Processes Definition!!!!!!!!!!!!!!! Bílý šum White noise random process is a process whose power spectral density is constant for all frequencies S X ( )= 1 2 N 0, for 1< < 1 Notes N0 > 0 is a fixed constant May or may not be Gaussian white noise This process does not exist in real life, but is useful for theory 4
Random Processes White Random Processes White Random Processes The Autocorrelation Function of the White Random Process If the power spectral density is constant for all frequencies S X ( )= 1 2 N 0, for 1< < 1 then the autocorrelation function of the process (the inverse Fourier transform of SX) is given by R X ( )=F 1 (S X )= 1 2 N 0 ( ) where δ(τ) is the Dirac delta function ( pulse at 0). 5
White Random Processes White Random Processes The Dirac Delta Function Definition The Dirac delta function ( pulse at 0) is defined as +1 if t =0 such that (t) = Z " 0 otherwise, " (t) dt = 1, 8" > 0. The integration notation is only a symbolic convention Such function δ does not exist as an ordinary function 6
Random Processes White Random Processes The Dirac Delta Function δ(t) Dirac delta function δ(t) is the ( pulse at 0) 0 t 7
Random Processes White Random Processes We Can Find the Autocorrelation Function Backwards Assume S X ( )= 1 2 N 0, for 1< < 1 Then 1 2 N 0 = S X ( ) = Z 1 1 R X ( ) e i d. Does not depend on ξ That only works for τ = 0 We will try δ(τ) (infinite pulse at 0) Z 1 1 Z 1 1 2 N 0 ( ) e i d = 1 2 N 0 1 ( ) e i d = 1 2 N 0 1 for τ = 0 8
Random Processes White Random Processes White Random Processes The white random process is not physically realizable It would have infinite average power: R X (0) = 1 2 R 1 1 S X ( ) d = 1 2 Its autocorrelation function is the Dirac Delta which itself does not exist as an ordinary function It is useful for theoretical calculations R 1 1 1 2 N 0 d = 1 If it is passed through a filter, the output is an observable random process Gaussian white noise (GWN) is often assumed in problems where we need to filter-out noise from signal 9
Random Processes Final Remarks Sampling of Continuous Random Processes Originally electronic filters used to be analog circuits The input signals were processed continuously The output of filters was really an integral of the input Today we use mostly digital circuits Input signals are periodically sampled at times T, 2T, 3T,... ( ( ( ( ( X [k] = X(kT ), k = 1, 2, 3,... Stationarity of X(t ) implies stationarity of X [k] The mean and autocorrelation fn. can be sampled as well: EX[k] =EX(kT )= X (kt ) R X [k 1, k 2 ]=EX(k 1 T )X(k 2 T )=R X (k 1 T, k 2 T ) 10
Random Processes Final Remarks Important Types of Random Processes Second-Order Stationary Processes Wide Sense Stationary Processes Gaussian Processes, White Noise,... (Multi)Linear Systems (filtering and detection of signals) Ergodic Processes (we will discuss them later) Autoregressive Moving Average Processes (ARMA) Autocorrelation function is hard to find directly via densities It becomes easy if we define ARMA as linear systems and use spectral densities to find the autocorrelation function 11
Introduction to Queueing Theory Základy teorie front Alternative Spelling: Queuing 12
Literature Textbook Chee-Hock Ng & Soong Boon-Hee Queueing Modelling Fundamentals With Applications in Communication Networks John Wiley and Sons, Inc., 2 edition, 2008 13
Literature Textbook Richard Durrett Essentials of Stochastic Processes Springer Texts in Statistics 1st ed. 1999 Corr. 2nd printing edition (November 2, 2010) 14
Basic Principles and Terminology Queueing Systems ( ( Systémy hromadné obsluhy Activities today are highly interdependent and intertwined Sharing of resources is common in all walks of life Sharing leads to waiting for resources in queues In data communications (e.g. the Internet) Data packets are queued in switch/router buffers for transmission In computer systems Jobs are queued for processing by CPU or I/O devices 15
Basic Principles and Terminology Queueing Theory Originally developed for telephone networks A.K. Erlang (Danish engineer, published a paper in 1909) D.G. Kendall (British statistician, Oxford, Cambridge, introduced notation in 1953) In modern packet switching networks L. Kleinrock (American engineer, MIT, UCLA, main work in early 1960s) Poisson Process The most common model for customer arrivals 16
Basic Principles and Terminology Basic Principles and Terminology Customers Arrive according to an arrival process Want to obtain service from a service facility Networking: Data packets, data frames,... Computing: Jobs, transactions, user requests,... Service facility Contains one or more servers Each server can serve one customer at a time Customers join a queue if all servers are occupied 17
Basic Principles and Terminology Queueing System Diagram Fronta Waiting Queue Obsluha Service Facility Customer Population Arriving Customers Vstupní tok požadavků Departing Customers Výstupní tok požadavků Prvky systému hromadné obsluhy 18
Basic Principles and Terminology Basic Principles and Terminology Queueing System Arrival process Service Facility Waiting Queue Systém hromadné obsluhy Vstupní tok požadavků Obsluha a její režim Fronta a její režim We need a mathematical description of The input process The system structure Queueing policy; Service policy The output process 19
Basic Principles and Terminology Characteristics of the Input Process Charakteristiky vstupního toku požadavků (i) The size of arriving population Finite or infinite Infinite is easier to solve arrival rate not affected by size We often assume infinite arriving population It approximates a very large population (ii) Behavior of arriving customers May leave forever if the queue is full May leave randomly if the queue is too long 20
Basic Principles and Terminology Characteristics of the Input Process Charakteristiky vstupního toku požadavků (iii) Arriving patterns M: ( Markovian or Memoryless Poisson Process ( ( (I.e. exponential & independent interarrival times) D:( Ek:( G:( GI:( Deterministic, constant interarrival times Erlang distribution of order k of interarrival times General probability distribution of interarrival times General & Independent distribution of interarrival times Default Assumption: Poisson Process 21
Basic Principles and Terminology Characteristics of the System Structure (i) Physical number and layout of servers One or more; identical or different; serial or parallel We will focus on parallel identical servers I.e. customers can go to any free server and then leave (ii) The system capacity ( System capacity = waiting customers + served customers Non-blocking system infinite queue Easier to solve often we assume this Blocking system finite queue Customers leave forever if the queue is full 22
Basic Principles and Terminology Physical Layout of Servers Arriving Customers Departing Customers Parallel Servers Arriving Customers Departing Customers Serial Servers 23
Basic Principles and Terminology Characteristics of the Output Process Charakteristiky výstupního toku požadavků (i) Queueing discipline or serving discipline ( ( ( ( ( ( Obsluha a její režim / Fronta a její režim First-come-first-served (FCFS) / First-in-first-out (FIFO) Last-come-first-served (LCFS) / First-in-last-out (FILO) Priority based (preemptive or non-preemptive) Processor sharing (1/k of time to each of k customers) Random Default Assumption: FCFS/FIFO 24
Basic Principles and Terminology Characteristics of the Output Process Charakteristiky výstupního toku požadavků (ii) Service time distribution M: ( Markovian or Memoryless exponential service times D:( Deterministic, constant service times Ek:( Erlang distribution of order k of service times G:( General probability distribution of service times Default Assumption: Exponential service times 25
Basic Principles and Terminology Web and Database Servers Example Pool of m application servers (e.g. Tomcat) submits a job to a central database server Application server 1 Application server 2 Central Database Server Application server m 26
Basic Principles and Terminology Web and Database Servers Example We assume the Poisson arrival process for the requests. So we obtain a state-dependent Poisson arrival process with the rate (m k) k < m (k) = 0 k m 27
Basic Principles and Terminology Kendall Notation A / B / X / Y / Z A:( Customer arrival pattern ( ( (Interarrival time distribution) B:( Service pattern (Service time distribution) X:( Number of parallel servers Y: ( System capacity Z:( Queueing discipline Default values:( Y =, Z = FCFS Example: ( M / M / 1 = M / M / 1 / / FCFS ( ( ( ( (Poisson arrivals, Exp. service times, 1 server) 28
Basic Principles and Terminology Plan of Study We will focus on M/M/m systems We must therefore study The Exponential Distribution (interarrival & service times) The Poisson Process (interarrival times are Exponential) Birth & Death Markov chains with continuous time (the number of customers in the system) We will also look at a M/G/ system Poisson arrivals, General service time, many servers But we will look at some general results first... 29
Little s Theorem and Related Results Little s Theorem and Related Results 30
Little s Theorem and Related Results Ergodicity Two ways of calculating the average value of a process: Time average Expected value X t = 1 t 1X Z t 0 X( ) d EX(t) = k P[X(t) =k] k=0 Definition A random process X is ergodic if the two averages are equal (have the same limit) as t 31
Little s Theorem and Related Results Little s Theorem Theorem N = λ T where ( ( N (=( average number of customers in the system ( ( λ ( =( average arrival rate of customers ( ( T( =( average time a customer spends in the system Very general no assumptions about Interarrival and service time distribution Queueing policy Number of parallel servers 32
Little s Theorem and Related Results Proof of Little s Theorem Assume FCFS (FIFO) policy Define ( ( A(t)( =( Number of arrivals during time interval (0,t) ( ( D(t)( =( Number of departures during (0,t) ( ( N(t)( =( Number of customers in the system at time t Assume we start wit empty system at time 0, then!!!!!!! N(t)( =( A(t) D(t) ( ( ( ( 33
Little s Theorem and Related Results Proof of Little s Theorem Z t 0 Number of arrivals or departures 0 N( ) d = Z t 0 N(t) = A(t) D(t) T1 T2 t1 t2 t3 [A( ) D( )] d A(t)... arrivals D(t)... departures tk(...( arrival time of k th customer Tk(...( time spent in the system ( ( by the k th customer Time t Area between the curves: departed in the system = t D(t) X k=1 T k 1 + A(t) X k=d(t)+1 (t t k ) 1 34
Little s Theorem and Related Results Before we got the total number of customers up to time t Z t 0 N( ) d = Z t 0 [A( ) D( )] d = D(t) X k=1 T k 1 + A(t) X k=d(t)+1 (t t k ) 1 The time average of the number of customers Nt is Z " # t X D(t) XA(t) N t = 1 t 0 N( ) d = = " D(t) X k=1 k=1 T k + T k + k=d(t)+1 A(t) X k=d(t)+1 (t t k ) (t t k ) # 1 t 1 A(t) A(t) t Nt = Tt time average of the time spent by a customer λt time average of the arrival rate 35
Little s Theorem and Related Results Proof of Little s Theorem We have ( ( ( ( ( ( ( ( Nt =Tt λt ( ( Nt(...( time average of the number of customers ( ( Tt(...( time average of the time spent by a customer ( ( λt(...( time average of the arrival rate For ergodic processes the time average ( ( Nt( N = Expectation in steady state, as t Let t to get ( ( ( ( ( ( ( ( N =T λ Note: Most queueing systems are ergodic. 36
Little s Theorem and Related Results Resource Utilization Definition Resource utilization of a queueing system is the fraction of time the system is used = Time a server is occupied Time available 37
Little s Theorem and Related Results Resource Utilization Note With m servers, N customers during (t, t+t ), arrival rate λ each server serves on average N /m = (λt / m) customers. If the average service time is (1/μ) then = Time a server is occupied Time available = ( T/m) (1/µ) T = mµ 38
Little s Theorem and Related Results Traffic Intensity Definition Traffic Intensity (offered load) of a queueing system is the product of the average arrival rate λ and the average service time (1/μ): = µ 39
Little s Theorem and Related Results Flow Conservation Law Proposition For a stable queueing system rate of customers leaving = rate of customers entering λout = λin 40