Why can't I have a waffle?

Or, What does "scale" really mean?

If you interact with technical people, you will inevitably hear the word scale. They will say something like, "it doesn't scale well", or, "we need to make sure that this can scale up". Maybe you aren't sure what this means, but you nodded your head anyway. Well, let me tell you what they are talking about.

In simple terms, the idea of scalability is how well the software can handle a large increase in its workload. In other words, does the software run well with 100 records, but it starts to choke when you have 10,000 records? Does the software work well when 10 people are logged in, but it slows to a crawl when there are 1,000 people logged in? Software is said to scale well if it was designed to handle these changes in demand.

On the other hand, there are some specific types of computer problems that cause exponentially increasing demand. In that case, its not (directly) the fault of the software, but the software vendor may be promising something they can't deliver.

What does that have to do with waffles? Well, have you ever noticed that most breakfast places don't serve waffles? And, the ones that do seem to charge a lot of money for just one? It turns out that waffles are a perfect analogy for those intractable software problems. As every restauranteur can tell you...

Waffle irons don't scale well (but griddles do).

In order to illustrate this point, let me tell you a story about two employees, one employee is asked to update the company cafeteria, the other is is asked to update the company software.

One lovely day, the boss makes two "executive decisions". The first is that the cafeteria should start serving waffles. "Our employees need a good breakfast so that they have energy during the day," the boss asserts, "Everybody loves waffles. We should provide waffles in our cafeteria." He goes to the secretary, Wanda, and tells her to take care of it.

The other decision has to do with the company contact database. The boss is annoyed because there isn't a field in the database for 'Home Fax Number'. One of his golfing buddies has a fax machine at home, but when he tried to put the number in the database, there wasn't any room for it. There were only fields for 'Work Phone Number', 'Work Fax Number', 'Home Phone Number' and 'Mobile Phone Number' and all of those were already full. He goes to the junior database manager, Dave, and tells him to take care of it.

Now, neither Wanda nor Dave are stupid people. They know that they will have to do some research to figure out what is really needed. So they start asking questions.

Wanda's Waffles

Wanda does a quiet survey of all of the employees she can get hold of, and she quickly discovers that not everyone loves waffles. One employee (there's always one) says that he would eat waffles more than once a day. About 10 others say that they might eat waffles a few times a week, and about 10 more say that they would only eat waffles a few times a month, or less.

Then Wanda looks online. A good commercial waffle maker can make about 25 waffles per hour. Based on the results of her survey that is more than enough waffles for everyone. She also finds out that she will need a high-voltage outlet and a few feet of counter space for the waffle iron, batter, etc. She even thinks ahead and makes sure that she can provide a variety of toppings.

Now, there isn't a lot of space in the cafeteria. So, Wanda hires a contractor and they figure out that they can take some room away from the sandwich prep area to install the special outlet, the waffle iron, the batter and the toppings. With a plan in place, Wanda goes back to her boss and tells him that they will have waffles next Friday.

Dave's Data

Dave is only the junior database manager, but he is trying to impress the boss, so he starts thinking about how he can do his task really well. Instead of just adding one field, he thinks about all of the possible types of phone numbers people wants to store. In the end, he comes up with this list of fields to add:

  • work phone
  • work mobile
  • work pager
  • work fax
  • home phone
  • home pager
  • home mobile
  • home fax
  • main phone
  • main mobile
  • main fax
  • main pager
  • other phone
  • other pager
  • other mobile
  • other fax

The current phone fields allow up to 26 characters in order to accommodate spaces, parentheses, dashes, extensions, etc. Dave sets up his new fields the same way. [1]

Dave goes to his boss and tells him that he will roll out his new changes on Friday.

Waffle Day

Friday morning rolls around and Wanda comes in early and goes to the cafeteria to make sure that everything goes smoothly. The machine has been installed and tested, and she has plenty of batter and toppings.

Soon enough the boss comes in. And, he has told all of the employees to come down. And, he has invited some of his favorite customers. And, he has invited some of his golf buddies!

The boss does a head count, and turns to Wanda and says, "We need 53 waffles, please."

After a moment of hesitation, Wanda explains that they can only make one waffle at a time, and 53 waffles will take over two hours.

I'm sure you can imagine what happens next. I will spare you the gory details, but let's just say that almost everyone left hungry and frustrated.

Home Fax

Meanwhile, Dave is ready to roll out his changes. He is really hoping that he can cheer up the boss with what he has done. He presses the button and sends out an email announcing the change...

About half an hour later, the problems start. Co-workers can't use the web interface for the software. The iPhone app is crashing when it opens. Clients are starting to see problems with the ticketing system!

A bunch of employees are pulled off of their work to diagnose the problem. It appears that the amount of memory that the software needs has just increased four-fold! Each web page request needs more memory and takes longer. The iPhone app is taking longer to synchronize new data and search through customers! As the minutes tick by, more and more fingers are starting to point at Dave.

Both Wanda and Dave have learned a hard lesson...

Griddles scale well (waffle irons don't)

What Wanda really needed was a griddle. If you remember, the boss' original goal wasn't waffles, it was breakfast, and griddles are really good at breakfast because they can make more than one type of food at the same time. I'm sure this seems very obvious, but bear with me while I explain why it is important.

Let's say that a griddle has eight spaces available to cook different things. That doesn't sound like a lot, but imagine if you had to make 53 orders of pancakes instead of waffles.

pancakes pancakes pancakes pancakes
pancakes pancakes pancakes pancakes

Since you can cook eight orders of pancakes at one time, you could make 53 orders in about 20 minutes. That's a lot better than two hours! But, the benefits of a griddle don't stop there because you can make more than pancakes.

pancakes bacon pancakes eggs
eggs hash home fries (empty)

Each order can take a space on the griddle, and when that order is done, something else can immediately start. A griddle is an excellent compromise between space and speed. And, did you see that empty space? It's not really a problem, because it probably won't stay empty for long. You can use it as soon as the next order comes in (as long as it is not for a waffle).

Dave's Griddle

What Dave built was a lot of waffle irons. Each field in his database took up a certain amount of space, even if it was not being used. Dave also needed a griddle, metaphorically. What he really needed was a normalized database. Instead of creating a new field for each type of phone number, he could have just created a very small table that held labels.

table: phone_labels
label_id label
1 Work Phone
2 Work Fax
3 Home Phone
4 Mobile Phone
5 Home Fax

Then he could have created another table to link customers to certain phone numbers and labels.

table: phone_numbers
customer_id label_id phone_number
1 1 1 (555) 123-4567 x89
1 4 1 (555) 123-4567
2 1 555-987-6543 x210
2 2 555-987-6544
2 3 555-111-2222
2 4 555-111-0123
2 5 555-111-2223

As you can see, customer number 1 has a Work Phone and a Mobile Phone. He only takes up two spaces on the "griddle". Customer number 2 is the boss' golf buddy. He has a row for all five phone labels. Each customer takes as much, or as little, space as necessary.

More importantly, this set up scales very well. If the boss wants yet another label, Dave doesn't have to add a new field that will almost always be empty. Instead he can just add one row to the labels table, and a few rows to the phone numbers table for the few customers that need that new label.

But, what if I want waffles?

As I said in the beginning, there are some things that don't scale well, no matter how hard you try. If your customer wants waffles, then you need to get enough waffle irons to handle peak demand, and you need to charge enough to pay for all of that space and equipment even when most of it isn't being used.

There are "waffle" problems in software development also. A simple example is distance. The internet may seem really fast, but it does take an appreciable amount of time for a signal to travel halfway around the world. If you expect your webpages to be viewed by people all over the planet, and those pages contain large files, like images, sound or video. Then you may have to pay for a special service that keeps those files in several locations closer to your customers. And, just like the waffle irons you will pay something for that service even when it is not being used.


[1] If you think this setup isn't very plausible, I can tell you that I dealt with this exact data structure recently with some popular CRM software, which will remain nameless.