FlexyPool, Reactive Connection Pooling
Join the DZone community and get the full member experience.
Join For Freeintroduction
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 is tuned according to the hosted service intrinsic behaviour. web nodes employ the concurrent low pause collector , while batch services use the throughput collector
- deploying a batch service doesn’t affect the front services
- if one service goes down it won’t affect the rest
database connection provisioning
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 .
there’s a new guy in town
flexypool is a data source proxy offering better monitoring and failover for the following connection pools:
we concluded that sizing connection pools is not an upfront design decision. in large enterprise systems you need adaptability and monitoring is the first step to taking the right decisions.
advance monitoring
name | description |
---|---|
concurrentconnectioncount |
this indicates how many connections are being used at once. |
concurrentconnectionrequestcount |
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. |
failover strategies
when all pooled connections are being used, a new connection acquire 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 a better insight into connection usage so you’ll be better equipped when deciding the proper pools size.
flexypool was design 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
-
increment pool on timeout
this strategy will increment the target connection pool maximum size on connection acquire timeout.
the connection pool has a minimum size and on demand it can grow up to its maximum size . the overflow is a buffer of extra connections allowing the connection pool to grow beyond its initial maximum size . whenever a connection acquire timeout is detected, the current request won’t fail if the pool hasn’t grown to its maximum overflow size .
-
retrying attempts
this strategy is useful for those connection pools lacking a connection acquiring retry mechanism
stay tuned. my next article will demonstrate how flexypool can assist you finding the right pool size.
Published at DZone with permission of Vlad Mihalcea. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
What ChatGPT Needs Is Context
-
Microservices With Apache Camel and Quarkus (Part 3)
-
Transactional Outbox Patterns Step by Step With Spring and Kotlin
-
Essential Architecture Framework: In the World of Overengineering, Being Essential Is the Answer
Comments