1% Example 10: Basic layered queueing network tutorial
2% This example demonstrates a simple client-server application with two tiers
7% Create the layered network model
8model = LayeredNetwork(
'ClientDBSystem');
11P1 = Processor(model,
'ClientProcessor', 1, SchedStrategy.PS);
12P2 = Processor(model,
'DBProcessor', 1, SchedStrategy.PS);
15T1 = Task(model,
'ClientTask', 10, SchedStrategy.REF).on(P1);
16T1.setThinkTime(Exp.fitMean(5.0)); % 5-second think time
17T2 = Task(model,
'DBTask', Inf, SchedStrategy.INF).on(P2);
19% Create entries that represent service interfaces
20E1 = Entry(model,
'ClientEntry').on(T1);
21E2 = Entry(model,
'DBEntry').on(T2);
23% Define activities that specify the work performed and synchronous calls
24% Client activity: processes request and calls DB
25A1 = Activity(model,
'ClientActivity', Exp.fitMean(1.0)).on(T1);
26A1.boundTo(E1).synchCall(E2, 2.5); % 2.5 DB calls on average
28% DB activity: processes database request
29A2 = Activity(model,
'DBActivity', Exp.fitMean(0.8)).on(T2);
30A2.boundTo(E2).repliesTo(E2);
32% Solve the layered network
using the LN solver with MVA
33solverLN = LN(model, @(m) MVA(m,
'verbose',
false),
'verbose',
false);
34AvgTableLN = solverLN.getAvgTable();
37% Solve
using LQNS solver
38solverLQNS = SolverLQNS(model);
39AvgTableLQNS = solverLQNS.getAvgTable();
42% This example illustrates key layered queueing network concepts:
43% - Hierarchical structure: Clients make requests to servers
44% - Synchronous calls: Client requests block until database responds
45% - Call multiplicity: Single client request triggers multiple database operations
46% - Performance analysis: End-to-end response times including call dependencies
47% - Multiple solution methods: Both LN (iterative) and LQNS (analytical) solvers