skip to main | skip to sidebar

Aug 13, 2008

Dealing with bottlenecks

I was very interested in what Kent Alstad had to say about bottlenecks so I pulled out what I could get from his talk and tried to fill in the gaps. After a bit of study on my own here's my take on it.

First we know that there are always bottlenecks in distributed applications (web or otherwise) and though they may not initially be apparent, under enough load they will show themselves.

There are three main types of bottlenecks:

  • Memory bound – Too much data being cached or too much data being held in processes at one time for the specific amount of RAM on a system.
  • CPU bound – Too many processes and/or one or more intensive processes consuming the the all available CPU time.
  • IO bound – Processes fighting for their turn to read and write data as well as different processes contending for access to the same data.
Once you hit your first bottleneck you can fix it in hardware or in software or both.

Hardware/Design solutions to bottlenecks:

  • Scaling up – Increasing performance by improving hardware: adding faster/more processors, faster/more drives, more memory.
  • Scaling out – Increasing performance using distributed architecture (adding more servers); more servers share the load by processing different pieces of a process or having a piece of the process duplicated on two or more servers. This approach often requires that software changes be made to distribute the load across the servers. Also JavaScript and Ajax are often used to scale out by distributing some processing to the client; remember to include client-side compute time in your performance analysis, not just server side compute time.

Software Solutions to Bottlenecks:

  • Cashing – avoid reprocessing/re-querying data by storing the results in memory for future use.
  • Finding inefficiencies in database design and stored procedures and correcting them.
  • Normalizing/flattening data to decrease query time.
  • Profiling code to determine the slowest methods and then performance-tuning that piece of code to make it faster.
Remember: No matter how scaled-up or scaled-out you are, there is always another bottleneck.