1% Example 10: Basic layered queueing network tutorial
2% This example demonstrates a simple client-server application with two tiers
6% Create the layered network model
7model = LayeredNetwork(
'ClientDBSystem');
10P1 = Processor(model,
'ClientProcessor', 1, SchedStrategy.PS);
11P2 = Processor(model,
'DatabaseProcessor', 1, SchedStrategy.PS);
14T1 = Task(model,
'ClientTask', 10, SchedStrategy.REF).on(P1);
15T1.setThinkTime(Exp.fitMean(5.0)); % 5-second think time
16T2 = Task(model,
'DatabaseTask', Inf, SchedStrategy.INF).on(P2);
18% Create entries that represent service interfaces
19E1 = Entry(model,
'ClientEntry').on(T1);
20E2 = Entry(model,
'DatabaseEntry').on(T2);
22% Define activities that specify the work performed and synchronous calls
23% Client activity: processes request and calls database
24A1 = Activity(model,
'ClientActivity', Exp.fitMean(1.0)).on(T1);
25A1.boundTo(E1).synchCall(E2, 2.5); % 2.5 database calls on average
27% Database activity: processes database request
28A2 = Activity(model,
'DatabaseActivity', Exp.fitMean(0.8)).on(T2);
29A2.boundTo(E2).repliesTo(E2);
31% Solve the layered network
using the LN solver with MVA
32solver = LN(model, @(m) MVA(m));
33AvgTable = solver.avgTable();
36% This example illustrates key layered queueing network concepts:
37% - Hierarchical structure: Clients make requests to servers
38% - Synchronous calls: Client requests block until database responds
39% - Call multiplicity: Single client request triggers multiple database operations
40% - Performance analysis: End-to-end response times including call dependencies