A Fun Little Math Problem in System Optimization

Recently, a company with whom we work had a Web site that wasn't as fast as they wanted.  So they ran a series of tests using Apache's benchmarking tool:

  • Running a simple "Hello World" page: 500 pages/second
  • "Hello World" plus turning on "feature A": 50 pages/second
  • "Hello World" plus both "feature A" and "feature B": 5 pages/second

So, what feature should be optimized first to get the "biggest bang for the buck"?

This is a great example where your first intuition is probably wrong.  How long does each feature take?

  • "Hello World" = 500 pages/second -> 0.002 seconds/page
  • "Hello World" + "Feature A" = 50 pages/sec -> 0.02 seconds/page
  • "Hello World" + "Feature A" + "Feature B" =  5 pages/sec -> 0.2 seconds/page

Solving for each individual feature:

  • "Hello World" = 0.002 seconds to execute
  • "Feature A" = 0.018 seconds to execute
  • "Feature B" = 0.180 seconds to execute

"Feature A" takes 9% of the total time while "Feature B" takes 90% of the total time!  So even if you optimized Feature A so that it took absolutely no time at all, you'll find:

  • "Hello World" + "Feature B" = 0.182 seconds -> 5.49 pages/sec

So for your biggest bang for the buck, you need to work on Feature B first.

Tags:

Related Insights