LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
tut10_lqn_basics.m
1% Example 10: Basic layered queueing network tutorial
2% This example demonstrates a simple client-server application with two tiers
3
4clear solver AvgTable
5
6% Create the layered network model
7model = LayeredNetwork('ClientDBSystem');
8
9% Create processors
10P1 = Processor(model, 'ClientProcessor', 1, SchedStrategy.PS);
11P2 = Processor(model, 'DatabaseProcessor', 1, SchedStrategy.PS);
12
13% Create tasks
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);
17
18% Create entries that represent service interfaces
19E1 = Entry(model, 'ClientEntry').on(T1);
20E2 = Entry(model, 'DatabaseEntry').on(T2);
21
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
26
27% Database activity: processes database request
28A2 = Activity(model, 'DatabaseActivity', Exp.fitMean(0.8)).on(T2);
29A2.boundTo(E2).repliesTo(E2);
30
31% Solve the layered network using the LN solver with MVA
32solver = LN(model, @(m) MVA(m));
33AvgTable = solver.avgTable();
34AvgTable
35
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