sp

Maximizing resource efficiency

This post belongs to a small series on the dangers of blindly pursuing efficiency in software development. The main post is The cost of efficiency. This post discusses the downside of maximizing resource usage to be efficient.

Given the definition of efficiency — “doing things right without errors or unnecessary waste of resources” — it seems like a logical conclusion that all of our resources should be working at 100%. Resources are scarce and expensive, so we want to use them as much as possible: a machine on the factory floor that isn’t running is waste. Does that mean people not being occupied 100% of the time is waste too?

People aren’t resources, though. Yet most of us still treat busyness — maximizing that utilization percentage — as a worthwhile goal in itself. Not aiming for 100% utilization? “That is not efficient!”

Fortunately, the manufacturing industry has done a lot of research into efficiency and maximum utilization. This post digs into some of that theory and mechanics — fair warning, there’s some math ahead.

Resource utilization in manufacturing

The classic 1913 paper by engineer Ford W. Harris already laid out the relationship between maximum resource utilization and cost. People typically only see the cost of excess capacity — unused resources — as waste, while the cost of delay and queuing is frequently overlooked. Even Harris pointed this out back then. Cost is more than just the cost of resources.

cost-of-max-utilization “There are not many men who understand the theory underlying the economic size of lots” – Ford W. Harris, 1913

In his 1961 paper, John Kingman published the equation now known as Kingman’s Law, which establishes the relationship between capacity utilization and wait time. Depending on the variance in arrival frequency and process duration, there’s always a point — as you approach maximum capacity — where queue size, and with it wait time, starts to increase exponentially. (Variance here means: tasks varying in size and complexity, and tasks arriving at irregular times.)

wait-time-capacity “The Single Server Queue in Heavy Traffic” (1961)

The curve’s position depends on that variance: less variation shifts the curve down without changing its shape. In other words, the lower the variation, the more predictable the system, and the higher the capacity utilization we can sustain for the same wait time.

kingmans law “Variation is the enemy of efficiency, and max capacity usage is its ally.”

A nice example of the impact of variance on queues can be seen in this video of an experiment at Japan’s Nagoya University on the nature of traffic jams. Cars all driving at the same speed in a simple circle shouldn’t be a problem, but the moment one car brakes, you can see the queue form. Notice how quickly it spreads, and how much longer it takes to dissolve.

This is also why we shouldn’t get too hung up on the manufacturing examples. In manufacturing, it’s often possible, and desirable, to reduce variabi**lity. In product development — and especially in software development — variance is typically high. It’s extremely hard to have every task clearly defined and predictably sized. In product development, we often don’t even want predictability, because predictability can hinder innovation: innovation needs the freedom to explore and experiment, and limiting variance stifles exactly that.1

The cost of queues is easy to miss, even in manufacturing. Add to that the fact that software development’s high variability — and its need for innovation — is rarely acknowledged; it’s still widely seen as “just translating requirements into code”.

A simple example

It’s probably hard to grasp the complete picture from those mathematical descriptions, so let’s make it concrete with our three-star restaurant “Triple D” again.

Suppose completing an order in our restaurant takes on average 5 minutes. This would mean that the ideal arrival time, of new orders coming in would also be 5 minutes. This perfect scenario would look like this

Time OrderId Orders in waiting [Queue] Orders in progress [Cook] Completed Orders
17h00 A - A  
17h02 - - A  
17h05 B - B A
17h10 C - C A,B
17h15 - - - A,B,C

In this example there were never any orders in the waiting queue — the cook was 100% in use from 17h00 until 17h15. A more realistic example is that all three orders arrive at the same time. Typically, all the orders for a table arrive together and should be delivered together, making them a batch that’s only complete once every item is done.

Time OrderId Orders in waiting Orders in progress Completed Orders
17h00 A,B,C B,C A  
17h05 - C B A
17h10 - - C A,B
17h15 - - - A,B,C

Even though all three orders were placed at the same time, the last one finishes after 15 minutes — so the whole batch, and everyone at that table, waits 15 minutes. That’s still reasonable. But imagine more tables, with a new batch of orders arriving every 10 minutes:

Time BatchId OrderId Orders in waiting Orders in progress Completed Orders Completed Batch
17h00 Table1 A,B,C,D B,C,D A    
17h05 - - C,D B A  
17h10 Table2 E,F,G,H D, E,F,G,H C A,B  
17h15 - - E,F,G,H D A,B,C  
17h20 Table3 I,J,K,L F,G,H,I,J,K,L E A,B,C,D Table1
17h25 - - G,H,I,J,K,L F E  
17h30 Table4 M,N,O,P H,I,J,K,L,M,N,O,P G E,F  
17h35 - M,N,O,P I,J,K,L,M,N,O,P,M,N,O,P H E,F,G  
17h40 Table5 Q,R,S,T J,K,L,M,N,O,P I E,F,G,H Table2

The first table, with four orders this time, gets served after twenty minutes. The second table gets served after thirty. Every new batch arrives faster than the kitchen can clear the last one, so the queue — and the wait — keeps growing. That’s Kingman’s law in action:

W ≈ ρ / (1 - ρ)

where W is the expected wait time and ρ is the utilization — how close to 100% capacity the kitchen is running.

Conclusion

Because the work behind a software product isn’t physically visible, it’s easy to pile up too much of it at once. Queues and WIP are waste. We shouldn’t just focus on what we can see — people typing a lot — but try to visualize the entire flow of the system. The goal is to optimize the flow of the system, not the utilization of individuals.

The blog posts in this series: