Book Review: .NET Performance Testing and Optimization by Paul Glavich and Chris Farrell
I recently got the chance to review the book .NET Performance Testing and Optimization by Paul Glavich and Chris Farrell published by Simple Talk Publishing. Since I am usually a "performance aware" coder and try to think about performance right from the start, I was looking forward to this book with the hopes to learn a few new tricks, techniques and tools. Having read it now, I am not disappointed.
About the Book
The book is divided in 13 chapters dealing with the following topics:
Chapter 1, with the What and the Why section sets the stage by introducing concepts and terminology such as the different forms of testing, profiling and explains why it's important to quantify and measure code performance.
The second chapter deals with performance targets and helps you understand important things to measure and optimize, such as the (average) response times and the "time to first byte". It also talks about the load on your application you want to target such as the number of concurrent users, peak usage and growth of the application.
Chapter 3 deals with what information you need to collect to make good judgment calls about performance. It discusses the importance of a base line test for comparison, talks about the things you can measure such as CPU and memory usage, response times, requests per second (for web applications) and more. It also helps your recognize patterns in memory usage for normal applications and those with memory leaks. The chapter closes off with a description of many of the performance counters found in Windows that can be monitored with Performance Monitor.
Chapter 4 - Implementing Your Test Rig guides you through setting up your systems and network for performance tests and profiling. It deals with general network issues and shows you how to install and configure Visual Studio Team Test (or higher) and how to distribute and configure the workstation, the controllers and the agents. A useful chapter if you're new to this, although I find it lacking some detail here and there. And although Chapter 3 already introduced you to the many counters that can be tracked with Performance Monitor, this chapter introduces that tool as if it hasn't been mentioned before.
Chapter 5 gets a bit more practical and shows you how to record and replay web tests using Visual Studio. These tests can be part of performance tests. Again, a bit more detail would have been nice. You can figure out most of the stuff shown in this walk through yourself, but often it's the details behind the tests that are more important. More pointers to what to watch for, what to measure and what to ignore would have been welcome. I did like the tip about using Fiddler to record (some) of your tests. This can be especially handy with remote clients that have performance problems but don't have access to Visual Studio.
In the next chapter, Chapter 6 - Application Profiling - you get introduced to a number of tools for performance and memory profiling: Red Gate's own ANTS Memory and Performance profilers, Microfocus DevPartner Studio Professional 9.1 and Visual Studio 2008. Although you might expect that a lot of time is spent discussing Red Gate's tools, I found the balance between the three tools to be quite fair. A very useful section in this chapter is "What to look for" near the end of the chapter as it shows you a number of key indicators for problems and a resolution.
Despite the usefulness of that section, I was hoping to see a more in-depth explanation of these tools. The guidance is pretty basic, showing you how to profile your application but a much more detailed explanation of the results and how to interpret them would have been great. The problem with topics like this is probably to come up with good examples. They are either a bit contrived or too simple, or require a lot of code and setup to demonstrate. This in turn makes it difficult to show how to really use these tools, and you pretty much have to wait until you have a real problem in your own application. This is not something specific to this book but something I've seen in other books about performance as well.
Chapter 8 deals with memory profiling. It provides a lot of valuable insight in how garbage collection in .NET works. Since garbage collection is crucial to high performance applications, it's important to understand when and how it occurs, and this chapter digs deep in the internal working, showing you how the three garbage collection generations work and when they execute. You'll see how memory leaks can occur and how to find them using a number of tools, including ANTS, Studio Professional 9.1, Visual Studio and CLRProfiler, a free tool developed by Microsoft. Unfortunately, this tool works against the 2.0 run-time of the .NET framework only.
Chapter 9 discusses the performance testing process and provides tips on how to embed performance optimizations in your overall development strategy.
The next chapter deals with common areas for performance improvements. You learn a few tricks to optimize data access, how to use caching and cache dependencies (for example against SQL Server), discusses the risks of reflection and ORM frameworks, and talks about other potential performance areas such as the network, string manipulation, asynchronous web pages, data binding, caching and more.
Chapter 11 deals with things you need to consider when developing an application that needs to be load balanced and talks about topics such as shared state server, shared configuration options and briefly about Azure as the ultimate load balanced platform.
The chapter on Internet Information Services adds a lot of value in that it shows you some of the inner workings of IIS, crucial knowledge for building and maintaining high performing applications. Even if you're not an administrator responsible for managing IIS servers, this chapter provides a lot of background you can use in developing your ASP.NET applications.
This is a pretty decent book about performance in .NET, with a strong focus on web applications. If you're not a performance expert already, you'll take away a lot from this book. With the tips, tricks and background information you learn from this book you will be able to create high performing applications. My worries about a strong focus on the Red Gate tools was ungrounded; most of the tools get equal attention.
However, I wouldn't be me if I didn't have something to complain about or wish for. First of all, the book could have been edited better. It doesn't always flow naturally and introduces concepts that were already introduced in prior chapters. Also, the discussion of multiple tools in the same chapter causes some chapters to flow a bit illogical. A number of chapters could have a bit more depth, especially the ones dealing with the various tools and how to interpret the results they generate. Figuring out the basic operations of a tool is something you can easily accomplish yourself, but really understanding what the tools are telling you and how to respond to that is very important. If you read this book, be sure to follow the chapters with the tools that are discussed so you can do some more exploring yourself.
The book's strong focus on optimizing web applications does not reflect in the title or in the text on the back cover. Although a lot of the techniques you learn from this book are applicable in Web and other .NET applications, a lot of the optimizations such as those presented in Chapter 13, are for web applications only. Being a web developer myself, this was no problem for me, but it's something to be aware of.
Finally, the book itself could be improved a bit. Within seconds after opening it, the pages for the TOC fell out. The code font is a bit too large causing unnecessary wrapping and a more consistent theme for screen shots would give the book a more professional appearance. Screen shots from Windows 7 with the transparent Aero theme and drop shadows around Windows borders just doesn't translate well to print. Also, referring to "purple bars" (page 48) in a black and white book confuses matters, something you'll have no trouble with in the eBook version. Finally, the ugly font and capitalization of URLs doesn't make them very easy to retype in a browser.
Final score: 4 out of 5 stars
Where to Next?
Wonder where to go next? You can post a comment on this article.
Links in this Document
|Written by||Imar Spaanjaars|
|Date Posted||06/23/2010 19:13|
Talk Back! Comment on Imar.Spaanjaars.Com
I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.
When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.
If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the Doc ID of the document.
Please correct the following errors:
Unfortunately, something went wrong and your message or comments have not been submitted successfully.
There's a fair chance things broke down because you tried to post something that looks like HTML. Things that look like HTML include (X)HTML, obviously, XML, ASP.NET markup and c# generics syntax as all of them use the < and > characters.
If that's the case, try altering your message and remove anything that looks like an angled bracket. You can replace them with [ and ] for example so you can still make it look like HTML to some extend.
If, on the other hand, you were trying to spam this web site, I am pretty glad I caught you in the act and stopped you from doing so ;-)
Also, please don't use links in your posts; I had to block them to filter out most of the junk mail I am receiving.