Java Performance Workshop with Peter Lawrey

Peter Lawrey at IT Days I’ve just come back from a Java Performance Workshop held by Peter Lawrey at Cluj-Napoca IT Days. Peter Lawrey is a well-known Java StackOverflow user and the creator of Java Chronicle open-source library. Of Java and low latency Little’s Law defines concurrency as: To increase throughput we can either: increase server resources (scaling vertically or horizontally) decrease latency (improve performance) While enterprise applications are usually designed for scaling, trading systems focus on lowering latencies. As surprising as it may sound, most trading systems, I’ve heard of, are… Read More

How does the bytecode enhancement dirty checking mechanism work in Hibernate 4.3

Introduction Now that you know the basics of Hibernate dirty checking, we can dig into enhanced dirty checking mechanisms. While the default graph-traversal algorithm might be sufficient for most use-cases, there might be times when you need an optimized dirty checking algorithm and instrumentation is much more convenient than building your own custom strategy. Using Ant Hibernate Tools Traditionally, The Hibernate Tools have been focused on Ant and Eclipse. Bytecode instrumentation has been possible since Hibernate 3, but it required an Ant task to run the CGLIB or Javassist bytecode enhancement routines.

The simple scalability equation

Queuing Theory The queueing theory allows us to predict queue lengths and waiting times, which is of paramount importance for capacity planning. For an architect, this is a very handy tool since queues are not just the appanage of messaging systems. To avoid system over loading we use throttling. Whenever the number of incoming requests surpasses the available resources, we basically have two options: discarding all overflowing traffic, therefore decreasing availability queuing requests and wait (for as long as a time out threshold) for busy resources to become available This behavior applies… Read More

Professional connection pool sizing with FlexyPool

Introduction I previously wrote about the benefits of connection pooling and why monitoring it is of crucial importance. This post will demonstrate how FlexyPool can assist you in finding the right size for your connection pools. Know your connection pool The first step is to know your connection pool settings. My current application uses XA transactions, therefore we use Bitronix transaction manager, which comes with its own connection pooling solution. Accord to the Bitronix connection pool documentation we need to use the following settings: minPoolSize: the initial connection pool size maxPoolSize: the… Read More

FlexyPool, reactive connection pooling

Introduction When I started working on enterprise projects we were using J2EE and the pooling data source was provided by the application server. Scaling up meant buying more powerful hardware to support the increasing request demand. The vertical scaling meant that for supporting more requests, we would have to increase the connection pool size accordingly. Horizontal scaling Our recent architectures shifted from scaling up to scaling out. So instead of having one big machine hosting all our enterprise services, we now have a distributed service network. This has numerous advantages: Each JVM… Read More

The anatomy of Connection Pooling

Introduction All projects I’ve been working on have used database connection pooling and that’s for very good reasons. Sometimes we might forget why we are employing one design pattern or a particular technology, so it’s worth stepping back and reason on it. Every technology or technological decision has both upsides and downsides, and if you can’t see any drawback you need to wonder what you are missing. The database connection life-cycle Every database read or write operation requires a connection. So let’s see how database connection flow looks like: The flow goes… Read More

Caching best practices

Introduction There is an irresistible attraction to writing custom caching solutions since it seems to be the easiest path to “improving” the overall application performance. Well, caching is a great technique, but there are few steps to consider before even considering it.

The regex that broke a server

Introduction I’ve never thought I would see an unresponsive server due to a bad regex matcher but that’s just happened to one of our services, yielding it unresponsive. Let’s assume we parse some external dealer car info. We are trying to find all those cars with “no air conditioning” among various available input patterns (but without matching patterns such as “mono air conditioning”).

A beginner’s guide to MongoDB performance turbocharging

Introduction This is the second part of our MongoDB time series tutorial, and this post will be dedicated to performance tuning. In my previous post, I introduced you into our virtual project requirements. In short, we have 50M time events, spanning from the 1st of January 2012 to the 1st of January 2013, with the following structure: We’d like to aggregate the minimum, the maximum, and the average value as well as the entries count for the following discrete time samples: all seconds in a minute all minutes in an hour all… Read More

How to fetch entities multiple levels deep with Hibernate

Introduction It’s quite common to retrieve a root entity along with its children associations on multiple levels. In our example, we need to load a Forest with its Trees and Branches and Leaves, and we will try to see have Hibernate behaves for three collection types: Sets, Indexed Lists, and Bags.