
Transactions and Concurrency Control
Are you struggling with performance issues in your Spring, Jakarta EE, or Java EE application?
What if there were a tool that could automatically detect what caused performance issues in your JPA and Hibernate data access layer?
Wouldn’t it be awesome to have such a tool to watch your application and prevent performance issues during development, long before they affect production systems?
Well, Hypersistence Optimizer is that tool! And it works with Spring Boot, Spring Framework, Jakarta EE, Java EE, Quarkus, Micronaut, or Play Framework.
So, rather than fixing performance issues in your production system on a Saturday night, you are better off using Hypersistence Optimizer to help you prevent those issues so that you can spend your time on the things that you love!
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.
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:
But all those services end up calling the database and that’s always done through a database connection. A database server can offer only a limited number of concurrent connections, so connection provisioning is mandatory.
The current connection pooling solutions offer limited monitoring and failover support. This is what we’ve been struggling with lately and that’s why I decided to build FlexyPool.
FlexyPool is a data source proxy offering better monitoring and failover for the following connection pools:
We concluded that sizing connection pools are not an upfront design decision. In large enterprise systems, you need adaptability and monitoring is the first step to taking the right decisions.
| Name | Description |
|---|---|
| concurrentConnectionsHistogram |
This indicates how many connections are being used at once. |
|
concurrentConnectionRequestsHistogram |
This indicates how many connection are being requested at once. |
|
connectionAcquireMillis |
A time histogram of the target data source connection acquire interval. |
|
connectionLeaseMillis |
The lease time is the duration between the moment a connection is acquired and the time it gets released. |
|
maxPoolSizeHistogram |
A histogram of the target pool size. |
|
overallConnectionAcquireMillis |
A time histogram of the total connection acquire interval. |
|
overflowPoolSizeHistogram |
A histogram of the pool size overflowing. |
|
retryAttemptsHistogram |
A histogram of the retry attempts number. |
When all pooled connections are being used, a new connection acquires request will wait for a limited amount of time before giving up. This prevents system overloading but to avoid rejecting connection requests you have to properly configure the connection pool size. You will also have to consider traffic spikes and take into consideration all other services competing for the limited amount of database connections. The monitored data can provide you with a better insight into connection usage so you’ll be better equipped when deciding the proper pool size.
FlexyPool was designed to be reactive, so it can better adapt to traffic spikes. For this, it offers a configurable failover strategy mechanism.
A Strategy is a connection acquiring safety mechanisms, a resort that’s called when a connection is not successfully fetched from the target Connection Pool.
FlexyPool comes with the following default strategies
If you enjoyed this article, I bet you are going to love my Book and Video Courses as well.
My next article will demonstrate how FlexyPool can assist you finding the right pool size.
