Efficient Java I/O: byte[], ByteBuffers, and OutputStreams
More info than you ever wanted to know about Java I/O performance
Java/C++ Networking Microbenchmark
Yet another nio/bio benchmark, again, bio works for small number of simultaneous clients.
ConnectionFactories and Caching with Spring and ActiveMQ
In my previous two posts on ActiveMQ and Spring I’ve shown how to implement both asynchronous and synchronous messaging using MessageListenerContainers and JmsTemplates. Since then I have continued to tweak and improve my use of Spring’s JMS support and have uncovered a few more details about the ConnectionFactories supplied by both ActiveMQ and Spring and how they play together nicely and not so nicely. Some of this info is new while some was covered in my second post and lead to an edit in my initial post but I will reiterate that information here to keep it all in one place.
Python messaging: ActiveMQ and RabbitMQ
A simple but but comparison of ActiveMQ and RabbitMQ. This, combined with Reddit’s experience makes me pretty wary of using RabbitMQ.
ActiveRecord Naming Conventions with Spring JDBC
One of the best choices we made at my current job was splitting the web development from the heavy message processing system, allowing the former to be written in Ruby on Rails and the latter to be written in Java. However, for ease of development, we allowed the two code bases share a single database. What then to do about database naming conventions? Those familiar with ActiveRecord will know that it is very particular about its database naming conventions so it was up to the Java code to play nicely. The first solution to present itself required hardcoding database names in each Java object but a more elegant solution seemed possible and, after the discovery of one small but important 3rd party project, it revealed itself.
Approximating Java Case Objects without Project Lombok
Over the past few months Dick Wall of the Java Posse has been talking up Project Lombok and for good reason. As he points out, its great for reducing boilerplate code in basic Java data objects. However, the more important point that Dick makes is that it prevents stupid errors, particularly when adding new object fields later on in the development cycle. The only unfortunate issue is that Project Lombok requires a compiler hack that can be rather confusing to those not using a supported IDE or for those coding outside of an IDE. However, Apache Commons provides an elegant solution to this issue.
Comet & Java: Threaded Vs Nonblocking I/O
Blocking I/O might be faster but NIO scales to more concurrent users.
Performance Stats
I recently did a very quick and dirty load test using apache bench against four Java server designs.
1) create new Thread() per connection and call .start() on it - 2532.25 req/s
2) create new Runnable() and submit to a CachedThreadPool - 4174.17 req/s
3) create new Runnable() and submit to a FixedThreadPool - 4418.25 req/s
4) using Netty - 4267.12 req/s
Take home lesson here is don’t create a new thread for each request, the overhead of new Thread() is huge.
Additionally Runtime.getRuntime().availableProcessors() * 2 seems to be a nice performance sweet spot for the number of worker threads. This is the default in Netty and it eked out just a touch more performance than the raw number of available processors in the FixedThreadPool test.
Introduction to Asynchronous I/O (NIO.2) using the Grizzly Framework
I can’t wait for NIO.2 in JDK 7
That misery called meditation: What seven days of silence did to my head.
I can’t wait for my second week long retreat. Less than a month away now.


