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.