Introduction Now that I covered Hibernate batch support for INSERT, UPDATE and DELETE statements, it’s time to analyze SELECT statements result set batch fetching. JDBC ResultSet fetching The JDBC ResultSet offers a client-side Proxy cursor for fetching the current statement return data. When the statement gets executed, the result must be transferred from the database cursor to the client-side one. This operation can either be done at once or on demand.
Introduction In my previous post, I explained the Hibernate configurations required for batching INSERT and UPDATE statements. This post will continue this topic with DELETE statements batching. Domain model entities We’ll start with the following entity model:
Introduction JDBC has long been offering support for DML statement batching. By default, all statements are sent one after the other, each one in a separate network round-trip. Batching allows us to send multiple statements in one-shot, saving unnecessary socket stream flushing. Hibernate hides the database statements behind a transactional write-behind abstraction layer. An intermediate layer allows us to hide the JDBC batching semantics from the persistence layer logic. This way, we can change the JDBC batching strategy without altering the data access code. Configuring Hibernate to support JDBC batching is not… Read More
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
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.
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
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
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
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
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.