Skip to content
Tutorials Center
My learning

Topics

Lesson 25 of 29 ยท Projects

Project: Kanban Flow Simulator

Build a Kanban flow simulator in JavaScript: compare WIP limits, measure cycle time and throughput, then forecast delivery with a Monte Carlo simulation.

"Limit work in progress" is the most famous Kanban advice and the one teams trust least until they see it work. In this project you will build a small simulator of a two-column Kanban board and watch what different WIP limits do to cycle time and throughput. Then you will use the same kind of randomness the other way round: take a team's real throughput history and forecast when a pile of work will be done, as a range with probabilities instead of a single date.

You need the ideas from Kanban and WIP Limits and Velocity, Burndown and Cumulative Flow. Both TryIts are plain JavaScript with a seeded random number generator, so every run prints the same numbers. The simulation is an illustrative model with simple, stated assumptions. It shows why WIP limits tend to help; it does not prove what your own team's numbers would be, and Jira cannot run it for you.

What we will build

A board Ready, Dev and Review columns.
WIP limits Pull new work only when there is room.
Flow metrics Cycle time, lead time, throughput.
Forecast Monte Carlo from real history.

Measure first, then forecast with ranges.

1 / 2

The words: cycle time, lead time, throughput

Three measurements describe flow, and it is worth keeping them apart:

  • Lead time runs from the moment a request arrives until it is done. It is what the customer feels.
  • Cycle time runs from the moment the team starts the work until it is done. It is what the team controls.
  • Throughput is how many items are finished per unit of time (per day or per week).
  • WIP (work in progress) is how many items are started but not finished.

They are linked by Little's law: on average, WIP = throughput x cycle time. If throughput stays about the same, the only way to shorten cycle time is to reduce WIP. That is the whole case for WIP limits in one line.

Step 1: Simulate the board

The model has these rules, all deliberately simple:

  • A new request arrives on 80 percent of days (a seeded random choice). That is more than the team can finish, as in many real teams.
  • Each item needs 2 to 6 units of development work, then 1 to 3 units of review work.
  • The team has 4 units of capacity per day. All active items (in Dev or Review) share it equally, but no item can use more than 1 unit a day.
  • Juggling costs efficiency: every active item beyond 4 reduces total efficiency by 4 percent, down to a floor of 60 percent. This stands in for context switching.
  • The Dev column starts new work only while it has fewer items than its WIP limit. Finished development moves to Review only if Review has room, otherwise it waits (blocked).

The simulator runs 80 days for four board setups and prints the flow metrics. The averages for cycle and lead time only count items that finished.

JS WIP limits and flow

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Read the table carefully. With no limits, the team starts everything, shares its attention across more than 20 items on average, and finishes only 18 in 80 days, each taking about 25 days once started. With Dev 4 / Review 2 it finishes 35 items and cycle time falls to about 12 days. Tightening further to Dev 2 / Review 1 gives the shortest cycle time (about 7 days) but throughput drops to 31, because people sometimes have nothing to pull or wait for review space.

So there is a sweet spot, and too-low limits hurt as well. Also look at the lead time column: with demand above capacity, requests wait in the Ready queue however you set the limits. WIP limits make the started work flow faster; they cannot create capacity. Their honest value is that they move the waiting out of the half-finished work (where it hides and ages) into a visible, prioritizable queue.

Try changing ARRIVAL_CHANCE to 0.5 and run again: when the team is not overloaded, the limits barely matter. That is realistic too. WIP limits earn their keep under pressure.

Step 2: Forecast with Monte Carlo

Teams want to know "when will it be done?". A single date from a velocity average is a coin toss. A better approach uses Monte Carlo simulation: take the weekly throughput the team actually achieved, and replay the future thousands of times by picking random past weeks. Each trial gives one possible number of weeks. The spread of results is the forecast.

The assumption behind it is that the near future will look like the recent past: the same team, similar work, similar disturbances. If that stops being true (a new team member, a big change of scope), collect new data. The method also needs items of roughly similar size, which is another reason to split stories small.

JS Monte Carlo delivery forecast

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The "naive" answer of 8 weeks (30 items divided by the 3.83 average) is only about a 50 percent bet: the 50th percentile is also 8 weeks. If a stakeholder needs more certainty, tell them 9 weeks for roughly 85 percent confidence, or 10 weeks for 95 percent. Quote ranges and confidence levels, not a single date. The second forecast flips the question: in six weeks the team will, with 85 percent confidence, finish at least 19 items.

Note how the percentile for "at least N items" is read from the other end of the sorted list; being very sure means choosing the pessimistic tail.

Extending the project

  1. Add a third column (Testing) and watch where the bottleneck appears.
  2. Record each item's daily column and draw a text cumulative flow diagram; see Velocity, Burndown and Cumulative Flow.
  3. Add expedite items that jump the queue and ignore the WIP limit, then measure how they hurt everything else.
  4. Use the simulated done list as the history for the Monte Carlo forecast instead of the hard-coded weeks.
  5. Add a "blocked" probability: each day, an active item may be blocked for a few days and does no work.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. According to Little's law, if throughput stays the same, how can cycle time be shortened?

    Average WIP equals throughput times cycle time. With throughput fixed, less WIP means shorter cycle time.
  2. 2. What is the difference between lead time and cycle time?

    Lead time covers the customer's whole wait from request to delivery. Cycle time covers only the time from starting the work to finishing it.
  3. 3. Why is a very low WIP limit not always best in the simulation?

    The tightest setting gave the shortest cycle time but fewer finished items. A limit that is too low starves the flow.
  4. 4. How should a Monte Carlo forecast be reported to stakeholders?

    Simulation produces a distribution of outcomes. Quote the percentile that matches the risk the stakeholder can accept.

Summary

  • Lead time is the customer's wait, cycle time is the team's working time, throughput is items finished per period and WIP is items started but not finished.
  • Little's law links them: lowering WIP shortens cycle time when throughput is stable.
  • In the simulation, moderate WIP limits raised throughput and cut cycle time under overload; extremely low limits starved the flow.
  • WIP limits do not create capacity, but they make waiting visible and keep started work moving.
  • Monte Carlo forecasting replays real throughput history to give a range of outcomes with confidence levels.
  • The simulator is a teaching model with stated assumptions, not a measurement of any real team.

Next, forecast a release from sprint history in Project: Release Forecast from Velocity.