Tuesday, September 22, 2009

Release It! Design and Deploy Production-Ready Software


Release It! Design and Deploy Production-Ready Software by Michael T. Nygard is a very practical read on building production-ready software. There is an entirely under-rated skill set related to building a system for production and this book shows some of what it takes to build systems. Creating a quality software application is not just clever algorithms and easy-to-use screens, it also includes redundancy, planning, upgrades, extensibility, uptime, etc.

One highlight:
Avoid fiddling:
Human intervention leads to problems. Eliminate the need for
recurring human intervention. Your system should run at least for a
typical deployment cycle without manual disk cleanups or nightly
restarts.
And I loved this sidebar on Object-Pooling. You don't hear much about this anymore.

In early versions of Java (around the 1.2 time frame), the idea that long-lived objects were good gained currency. I specifically remember being told that "creating an object is the second most expensive thing you can do in Java." (the first being creation of a new thread). The answer, supposedly, was to avoid creating objects whenever possible. Instead you were supposed to keep objects around and reuse them.

Whether that was ever true is the subject of heated debate in the Java community. Either way, with the current JVMs, object pooling is not the answer. Some systems have gone to ridiculous lengths to avoid creating new objects. They add so much complexity and bookkeeping that any possible performance gains will be wiped out.

The following table shows timing from a simple application that uses a NameFormatter to format 50,000 names. In the "pooled" configuration, the Jakarta "commons-pool" package is used to make an object pool to reuse the NameFormatter. In the "unpooled" configuration, 50,000 individual NameFormatters are created. The data clearly shows that the bookkeeping overhead of the pool overwhelms the expense of constructing the objects. (All tests are against JDK 1.4.2)


OSCPU SpeedOverhead PooledOverhead Disposable
Windows XP Pro1.86 GHz20.30%10.17%
Linux 2.6.142.66 GHz31.46%23.42%
Mac OS 10.4.41.67 GHz24.69%15.69%


Reserve object pooling for objects that really are expensive to create, such as network connections, database connections, and worker threads.

0 comments: