Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Thinking about Kanban, I realized that the queuing-theory behind the SW-development-methodology obviously also applies to concurrent software. Now I'm looking for whether this kind of thinking is explicitly applied in some area.

A simple example: We usually want to limit the number of threads to avoid cache-thrashing (WIP-Limits).

In the paper about the disruptor pattern[1], one statement that I found interesting was that producer/consumers are rarely balanced so when using queues, either consumers wait (queues are empty), or producers produce more than is consumed, resulting in either a full capacity-constrained queue or an unconstrained one blowing up and eating away memory. Both, in lean-speak, is waste, and increases lead-time.

Does anybody have examples of WIP-Limits, reducing/eliminating queues, pull or single piece flow being applied in programming?

share|improve this question
On the manufacturing line, if a person has to wait a non-trivial amount of time to get inputs they need, or to get the card for what they produce, they may go over to the blocking workstation and help with that work. / With threads, when a thread blocks on (reading or writing) a queue, it releases the CPU core to go work on other threads. / If you think of CPU cores as "people", then you'll see that what's happening is an extreme form of "going to help where it's most needed." – Jeff Grigg Oct 31 '11 at 16:29

Typical application of WIP limit in programming is any type of pool:

  • Thread pool
  • Connection pool
  • Object pool
  • etc.

You know that your resources are somehow constrained and you can constrain them be allowing only specific number of resources. Any other work item requesting a resource must wait till any resource in use is returned back in the pool.

It also solves problems with expensive construction of resources and it can be further improved to solve management of resources when only small number of work items is generated (the size of the pool can dynamically change between allowed thresholds).

share|improve this answer
Thanks for this example. Thinking about this, I also remembered the Fail Fast pattern in Peter Nygard's "Release It". In addition to the WIP limit on the pool, one can limit the queue and fail a call if it is likely to time out or take longer than acceptable. – Christoph Nov 1 '11 at 18:12

I just recently came across the KanbanFlow pattern which seems almost identical to the Disruptor PDF you posted. You can see a simulation of the idea here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.