Capacity Models For New Machines

Your computing world is changing. To handle the next projected peak, your sales team has suggested you upgrade your computer to the new model, which they claim is three times faster than your old computer. How do you model a machine you have no experience with?Norwich

Regardless of the sincerity of the sales team and their dedication to truth, the claim that the new machine is three times faster is wrong in the same fundamental way that assuming your SAT scores predict your ability to write a best selling novel. Every time you switch hardware, some parts are faster, some hardly change at all, and occasionally, some parts can run more slowly. It’s how your unique application uses those parts that will determine how much more work the new system will handle.

So where to begin?

Start with the simple things. Do all the calculations that you can do simply and easily first. If they work out, then move on to the more detailed and complex work. If they don’t work out, then you have to rethink your answer, and you’ve just saved yourself the time you would have wasted on detailed analysis.

For example, that three times faster number they gave you is usually heavily weighted toward the CPU performance.  So capacity plan your current system for your peak load and check to see if it will “fit” into your new system.

Let’s say the next projected seasonal peak is 5X busier than a moderately busy day you metered recently. On that day the system was about 30% busy. Do the math (5* 30% = 150%) to see that your old system would be 150% CPU busy at peak.  The new machine is 3X as fast as your old machine, and it only has to be 1.5x faster to (barely) handle the load. Chances are you are good to go CPU wise.

If the numbers had been uncomfortably close (e.g., the new machine was 1.7X faster than the old one), then more testing and checking would be in order. Remember, the closer you are to the edge of a performance cliff, the more precisely you have to know your position to stay safe. If it looks like the device in question is going to be over 50% busy, consult this post on queuing theory effects to get a rough estimate of the response time penalty you will pay.

Now, dig though each part of the machine to make sure this upgrade will do the job.  Do one thing at a time. Take good notes. Write your capacity report as you go.

The Hard Truth About Scaling

For any computer, application, or process you’re ever likely to encounter, the following describes the transaction path:

  1. Bits go in.
  2. Bits are transformed by the CPU.
  3. You may have to wait as bits are sent to, or requested from, local storage or some other computer.
  4. Bits go out.

It is in step three that your dreams of magical performance increases and simple scaling go to die. See Amdahl’s Law and Liebig’s Law Of The Minimum. Compared to pushing bits around in memory, waiting for data requested from local storage and other computers is tremendously slow. Also, when you upgrade a system, the time to fetch bits from local storage, or another computer, rarely keeps up with the overall speed increase the sales team promised you.

For example, if a process needs to read one record from disk for every transaction, then that IO is may be the biggest throughput limit. Even when you upgrade to a faster CPU, the disk runs at about the same speed, and so the transaction duration does not scale well as you see below.waiting

So, to handle 5X the load with your new machine you may need to add more processes. Any given process can only do so many transactions per second, and that number may not scale up to match the overall speed increase the salesperson claimed for the reasons outlined above. Let’s work through an example.

A Trick For Estimating Process Throughput

Many of the applications I’ve worked with had the ability to dynamically add new processes if incoming workload required it. A trick I’ve used to find the maximum throughput of a process is to start fewer than are normally required and then wait for the user workload to build as the day progresses. I’d watch closely for signs that the transactions are backing up and, when I felt I’d hit the maximum throughput, then I’d start the regular number of processes. Lastly, I do a bit of simple math to calculate the throughput of a process.

  • With 2 processes I hit max throughput at 100 TX/sec. That gives me: 100 / 2 = 50 TX/sec per process and I know that each transaction takes about 20ms total time as 1000ms / 50 = 20ms
  • During testing each process used ~150ms/sec of CPU. That gives me: 150ms/50TX= 3ms CPU/transaction
  • The CPU on the new machine is three times as fast. That gives me: 3ms / 3 = 1ms of CPU estimated per transaction on the new machine
  • Each transaction on the new machine will spend 2ms less time computing so the average transaction time will be 20ms – 2ms = 18ms
  • So that works out to a max throughput of ~55 transactions per second as 1000ms / 18ms = 55.5555

It can be tempting to display lots of decimal places in the numbers you come up with as that gives the illusion of precision. However, the numbers you started with are typically not all that precise. Furthermore, if the future of your company hangs on a tenth of a transaction per second then you are cutting it way too close for anyone’s comfort.

 

 

So, on the old machine, each process could handle 50TX/sec, and on the new machine each process can theoretically handle 55TX/sec. Now you see why you’ll need more processes to handle the load even though the machine is much faster.

Communications

Just like waiting for bits from local storage, waiting for bits from another computer can take up a big chunk of the overall transaction response time.commwait

You can do the same basic trick that we just did with local storage to find the max throughput of a given key process. When doing this work, make sure to lookout for comm errors.  You can’t eliminate all comm errors, especially if the Internet is involved, but keep an eye on them as you are gathering your data.  If there seems to be a significant increase in comm errors while you are gathering your data, that can have a big affect on throughput.

Look at the communications capacity to see if it can handle the projected peak load, which is 5X the traffic that your old system handled on a moderately busy day. Also be sure there is room for this increased traffic on whatever parts of the corporate network these packets flow through.

Local Storage

At the time of this writing, local storage, typically rotating magnetic disks, are the slowest part of any system and the most likely thing to bottleneck.disk

When upgrading, think of each disk not only as storage space, but as a device that can only give you a finite number of IO’s per second.  A new 2TB disk that can perform 200 IOs/sec is not the same as four older 500MB disks that can each perform 150 IOs/sec, but together the four older disks can perform 600 IO/sec.

A single process waiting for disk IO will notice a speed improvement when it is using the faster 2TB disk, but all the processes doing IO will overwhelm the 2TB disk long before they overwhelm the four 500MB disks.

When moving files to the disks of the new system, remember that the size of the file tells you nothing about how many IO’s per second the application does to it.  If your operating system gives you per-file IO data, then use it to balance the IO load among your disks. If there are no per-file meters, then you need to have a chat with the programmers and take your best guess as to how much IO is going to each file. Once you decide on a plan, move only a small number of files at a time and see how each move goes.

The other thing to consider when balancing disk IO is the IO load of periodically scheduled jobs like backups, overnight processing, end-of-month reports, etc. I’ve seen systems that were rebalanced nicely for production that became a nightmare when these background jobs were run. These background jobs don’t care about response time, but they do have to finish in a certain window of time. Bad things happen when these jobs linger into the daytime and mess up the live user response times. I’ve never seen a perfect solution to this problem, so favor the live users and balance the best you can.

Memory

Check to see that the memory that comes with the new system is at least as big as the old system. In general, if your old computer had enough memory for a moderately busy day, then it will be fine at peak load. However, I’ve seen a couple of cases where the memory usage scaled up and down with the load, so look at the memory usage over time on your old system and see how it changes over the day, and from day to day. Memory upgrades are sold in such huge chunks that you don’t have to be very precise in estimating memory needs. If you need more, the next step up will be a huge improvement.


For more info on performance modeling see: The Every Computer Performance Book at  Amazon, Powell’s Books, and on iTunes.


 

Advertisements

Don’t Get Carried Away

No matter how good you get at capacity planning, don’t forget that it is just a very detailed guess about the future, so try not to over promise like the gentlemen below.

Source: “Fantastic Four Giant” #5. Invented by Stan Lee and Jack Kirby

 

Capacity Planning: It’s Not JUST About The Peak

Even though capacity planners naturally tend to focus on the peak minute of the peak hour of the peak day, remember that most complex commercial systems have other stresses in their lives. There are the additional things to factor in. For example:

  • Off-peak downtimes where some fraction of the hardware is offline and the total load is carried by what remains
  • Backups
  • Nightly reports and other batch jobs
  • Activity that is calendar driven like any special end of week, month, quarter, year work that has to be done
  • How the available computing power is degraded during site upgrades
  • What happens when a part of your computing world briefly goes offline and then the backed up work surges in like a tsunami

Man vs. Machine

It’s usually easy to spot machine generated loads in performance data.machine

Above you see the classic performance signature of machine driven work, a nearly instant-on load with no normal change in intensity as the day progresses. Also, the work runs through the system at a relentless pace because there is no think time.

Sometimes a well thought out solution that works during a peak day kills you at night, kills you on the weekend, or kills you at the end of the month or quarter. Don’t just meter the peaks. Meter all year, and notice when these timed or special events happen. The boss may decide to include these special events in your capacity planning, or they may just decide to take the chance that any special event will happen during a conveniently low demand time. Different businesses are willing to make different tradeoffs between money spent and risks mitigated.

The Human Response

bossWhen you present your capacity plan be prepared for at least one round of adjustments. Even with the safety margin and max utilization values built into the calculations, some managers will still be uncomfortable with your results.

Sometimes you are too close to a limit, and the boss will have you add resources to the plan. Sometimes a resource is seen as “too idle”, and that will bother them. Sometimes your results do not support their empire building goals or cost savings targets, and you’ll be asked to change the plan.

Adjustments can be made, but do what you can to make sure the plan sticks to the truth. If your boss tries to force you to lie or profoundly fudge the numbers or “reframe the truth”, do your best to resist.

This post started as an excerpt from The Every Computer Performance Book, which you can find on Amazon and iTunes.

When To Do Capacity Planning

calendarEvery organization is different. Some are nimble, some ponderous and slow, some have money to burn, and some won’t see new hardware for years. You need to factor these realities into your plans as capacity planning is only helpful when it is done with enough lead time to fix the discovered future bottlenecks. Some things to consider:

  • There are times when money is available in your budget and usually a time by which you have to spend it or lose it. Any purchases you plan for have to hit this window.
  • How long does it typically take your company to complete a major purchase once the decision has been made to buy? A new computer that arrives two weeks after the seasonal peak doesn’t do you any good.
  • How fast can your vendor build, deliver and install the thing you need? Some things you can have tomorrow; some things take months to build and deliver.
  • Do you want to wait for the newest/fastest machine just on the horizon or go with last year’s model now?
  • Are there any company-wide spending edicts in place?
  • When is the end of the quarter for key vendors? Buying hardware at the end of the quarter (especially the fourth quarter) puts you in a better bargaining position.

With time all things are possible, so the best advice is to start as soon as you can.

Capacity Planning For Tough Times

fire-moneyThere are two situations where you create capacity plans that assume you have less computing resources than you have now: disaster recovery and budget cutting. In both cases the first thing that needs to be done is make some hard business decisions about suffering and money.

Suffering

Is your company willing to let the users feel a little response time pain if a key system or device fails in order to save some money? Every company I’ve ever worked for had a different answer, and that answer changed depending on the market they live in, and their current financial situation.

As a capacity planner, you are looking for a clear statement about response time and throughput goals such as:

  • If X fails, our customers shouldn’t feel a thing even if it happens on the busiest day of the year.
  • If X fails, our customers shouldn’t feel a thing on an average day. We are willing to gamble that this will not happen on the busiest day of the year.

In the above bullets X is the thing you are considering doing without and could be as small as a comm line or as large as a whole datacenter.

Money

At the end of the day, it is all about money. If you are asked to capacity plan for less hardware, and the chief consideration is money, then you need to know:

  • How much money is the company trying to save?
  • Where are they looking for savings: hardware cost, software licensing, facilities, etc.?
  • What are the savings per unit of hardware, software, floor space, etc.?

In many ways this is like playing the game Monopoly™ when you are low on cash. Suddenly you need to pay rent, so you have to return your buildings to the bank for the cash you need. You will select those buildings based on what they are worth and what they could make in rent as the game goes forward. The same is true in capacity planning. If the boss says he needs to save $200,000 in costs, then you need to know what eliminating a given machine will save you.

Dealing With Disaster

fireWhen planning for disaster, decide what part(s) of your world will be suddenly unavailable, and then mathematically shift the load to the still-working parts of your world.

For example, your overall projected peak load is 150 transactions per second (TPS), and you have three front end machines that each take 1/3 of that load. To capacity plan for handling that peak load with one of the front end machines down, just divide the peak load by two machines rather than three. So at peak the two remaining machines will each need to handle 150TPS / 2 = 75TPS.

On a normal, non-peak day, each front end machine handles about 25TPS during the busiest part of the day, and the measured utilization of system resources is what you are going to use to scale up the load. To get the scaling factor you need for your capacity plan, divide your per-machine projected peak load by the measured load.

If at peak everything is working normally, each front end machine will be handling 150TPS / 3 = 50TPS, and thus it will be doing twice the work 50TPS / 25TPS = 2X of your metered day.

If at peak one front end machine emits a puff of greasy black smoke and dies, then the remaining two machines will each be handling 150TPS / 2 = 75TPS, and thus they will each be doing three times the work 75TPS / 25TPS = 3X of your metered day.

When doing this work, you can also scale the disaster up to the datacenter level (What if a hurricane takes out our North Carolina datacenter?) or down to a single communications line. You just have to figure out if X breaks, what fraction of the pre-failure load will the remaining hardware have to pick up. Then add that to the projected peak for which you are capacity planning and do the math.

There are as many disaster scenarios as there are things that can break. You might get overwhelmed thinking of all the possible combinations, but remember, you don’t have to plan for all scenarios, just the worst ones. If you need to plan for various troubles that will leave System X carrying 110%, or 250%, or 300% of the metered load, do the math for the worst case first. If the system can handle a 300% load increase, it can clearly handle 250% or 110% easily.

Budget Cuts

moneyWhen looking to reduce equipment costs, you have to figure out how to do more, with less. It is almost never the case that there is some easily applied magic fix. Instead, typically, workload has to be moved to fewer systems which entails some unforeseen consequences and some risk to the stability and availability of your computing world. It can be done, but there are some things to which you need to pay attention:

  • Computers are not interchangeable homes for processes as they have different hardware that can support different versions of operating systems. Clearly applications designed for the X operating system won’t run on the Y operating system. That’s obvious. What is often missed, is there can be compatibility problems between version 10.1 and 10.2 of operating system X. Sometimes the hardware you plan to keep can only run 10.2, but the third-party code you depend on has a nasty bug in their 10.2 release and so you need to hold at 10.1.
  • Computers need to connect to the world, and some of them may require specific hardware that is only available on specific machines and versions of operating systems.
  • There are always the issues posed by who “owns” each machine and how that that machine is accounted for in the budget. Even if you save the company $50,000, if that money is not in the right part of the budget, it doesn’t solve your problem.
  • There may be legal limits preventing you from having unencrypted data on certain networks or security constraints that prevent certain people with admin-level privileges from access to certain systems.
  • Whatever plan you come up with can’t screw up your disaster recovery plans.
  • If you’re planning to turn off some piece of hardware, then you need to account for everything going through that machine. Frequently, there is more interconnectivity and dependency than you see at first.
  • Processes have all sorts of connections, communication paths, and shared resources. Some of these run much slower when accessed across the net vs. locally. Some can only work if the processes are on the same machine.
  • Whatever files or databases you move will need storage space and a sensible way to back them up.
  • Speaking of files, it is amazing how many files a process needs, with some of them only accessed on special occasions. When you change the file structure it is not at all unusual to find critical files that have been completely forgotten by the local experts. Also, changes to directory and file access permissions (read, write, execute) can cause trouble. Plan to spend considerable time hunting files, finding connections, and debugging the results of the move.
  • When moving a process between machines with different CPU speeds, if the two machines are made by the same vendor, they can usually give you a reasonable number to scale the CPU utilization. If moving to a different vendor’s machine, you might just have to do your own testing.

Doing the work of moving workload, processes, files, and networks is a deeply detail-oriented, complex task. Start by creating your plan with what you know, then spend time checking all the things on this list and whatever else you think of. Most of your plan will work, some of it won’t. Adjust and recheck all your assumptions. Repeat this plan/recheck process until it all seems to work while keeping your boss in the loop to be sure the money saved is sufficient and the politics are working out as well.

This post was built on an excerpt from The Every Computer Performance Book, which you can find on Amazon and iTunes.

Capacity Planning Guarantees You Can’t Make

Capacity planning should never be sold as a guarantee that all will be well at the next peak. No matter how good a performance person you are, you can’t offer that guarantee. monstersWhy? You cannot prove a negative. For example, you can’t prove there are no monsters waiting to get you while you sleep because no matter how carefully you check, you might overlook some spot (like the closet) where they are hiding.

Liebig’s Law clearly shows that even a small and obscure part of the transaction path can become a major bottleneck if given enough work to do.

Capacity planning is more like a pre-trip checklist to ensure you have what you need, and all systems on this list are good-to-go. Invariably, you will go on that trip, and somewhere along the way you’ll discover you forgot X, don’t have enough Y, and for the first time ever you need Z. That’s all bad news, but remember that your capacity planning effort found bottlenecks that would have limited your throughput even more.

Even if you use load testing to add to your confidence, no load test is perfect, so you still can’t honestly guarantee a trouble-free peak.

So, do capacity planning to the best of your ability with the things you do know about, load test to the best of your abilities, but make no absolute promises. If you get caught short on some resource, take the time before the next big peak to learn about that resource and to do a more complete plan next time. Unless this is the last peak before you retire, you need to think long-term.

The Every Computer Performance Book

coverThis short, occasionally funny, book covers Performance Monitoring, Capacity Planning, Load Testing, Performance Modeling and gives advice on how to get help and present your results effectively.

It works for any application running on any collection of computers you have. It teaches you how to discover more about your meters than the documentation reveals. It only requires the simplest math on your part, yet it allows you to easily use fairly advanced techniques. It is relentlessly practical, buzzword free, and written in a conversational style.

Most of the entries in this blog begin with what I put in the book. The book is available from Amazon in paperback and from Apple in iBook format. Both are priced at ~$9 USD. Why so cheap? Because I retired early (mostly due to my computer performance work) and so I wanted to give back what I learned in the hopes that the next generation can do the same.